module demo.region air 0 lang 0.1 features [arrays, capabilities, effects, heap, ownership, regions, resources] fn @main(%heap: cap) -> u64 effects [mem.alloc] entry: region.create %heap, ok -> @ok_1, err -> @err_3 ok_1(%ok_2: region): %c_5 = const.u64 0 %r_6 = borrow.ref %ok_2 %c_7 = const.u64 10 region.new %r_6, %c_7, ok -> @ok_8, err -> @err_10 err_3(%err_4: alloc_error): trap ok_8(%ok_9: mut): %v_12 = load %ok_9 %c_13 = const.u64 10 %t_14 = add.checked.u64 %v_12, %c_13 store %ok_9, %t_14 %v_15 = load %ok_9 %t_16 = add.checked.u64 %c_5, %v_15 borrow.end %ok_9 br @endmatch_17(%t_16) err_10(%err_11: alloc_error): br @endmatch_17(%c_5) endmatch_17(%total_18: u64): %c_19 = const.usize 4 %c_20 = const.u64 2 region.array %r_6, %c_19, %c_20, ok -> @ok_21, err -> @err_23 ok_21(%ok_22: slice_mut): %c_25 = const.u64 8 %c_26 = const.usize 0 %e_27 = borrow.index %ok_22, %c_26 store %e_27, %c_25 borrow.end %e_27 %c_28 = const.usize 0 %e_29 = borrow.index %ok_22, %c_28 %v_30 = load %e_29 borrow.end %e_29 %t_31 = add.checked.u64 %total_18, %v_30 %c_32 = const.usize 1 %e_33 = borrow.index %ok_22, %c_32 %v_34 = load %e_33 borrow.end %e_33 %t_35 = add.checked.u64 %t_31, %v_34 borrow.end %ok_22 borrow.end %r_6 region.reset %ok_2 region.destroy %ok_2 ret %t_35 err_23(%err_24: alloc_error): trap