; expect: run ; result: 42 ; phase: 1 ; spec: docs/spec/07a-air-instructions.md ยง2 module runtime.copies air 0 lang 0.1 features [arrays, effects, ownership] type @Pair = struct { flag: bool, values: array } type @Choice = enum { empty, full(@Pair) } type @Holder = struct { choice: @Choice, rows: array, 2> } fn @read(%h: @Holder) -> u16 effects [] entry: %local_1 = local.alloc @Holder %item_8 = local.alloc @Pair local.store %local_1, %h %local_2 = local.load %local_1 %choice_3 = struct.get @Holder.choice, %local_2 enum.switch @Choice %choice_3, empty -> @case_empty_4, full -> @case_full_5 case_empty_4: %c_7 = const.u16 1 br @endmatch_21(%c_7) case_full_5(%p_6: @Pair): local.store %item_8, %p_6 %item_9 = local.load %item_8 %flag_10 = struct.get @Pair.flag, %item_9 cbr %flag_10, @then_11(), @else_12() then_11: %item_13 = borrow.ref %item_8 %values_14 = borrow.field @Pair.values, %item_13 %c_15 = const.usize 0 %e_16 = borrow.index %values_14, %c_15 %v_17 = load %e_16 borrow.end %e_16 borrow.end %values_14 borrow.end %item_13 br @endif_19(%v_17) else_12: %c_18 = const.u16 1 br @endif_19(%c_18) endif_19(%if_20: u16): br @endmatch_21(%if_20) endmatch_21(%match_22: u16): %local_23 = borrow.ref %local_1 %rows_24 = borrow.field @Holder.rows, %local_23 %c_25 = const.usize 0 %e_26 = borrow.index %rows_24, %c_25 %c_27 = const.usize 0 %e_28 = borrow.index %e_26, %c_27 %v_29 = load %e_28 borrow.end %e_28 borrow.end %e_26 borrow.end %rows_24 borrow.end %local_23 %t_30 = add.checked.u16 %match_22, %v_29 %local_31 = borrow.ref %local_1 %rows_32 = borrow.field @Holder.rows, %local_31 %c_33 = const.usize 1 %e_34 = borrow.index %rows_32, %c_33 %c_35 = const.usize 1 %e_36 = borrow.index %e_34, %c_35 %v_37 = load %e_36 borrow.end %e_36 borrow.end %e_34 borrow.end %rows_32 borrow.end %local_31 %t_38 = add.checked.u16 %t_30, %v_37 ret %t_38 fn @main() -> u16 effects [] entry: %state_10 = local.alloc @Holder %snapshot_12 = local.alloc @Holder %c_1 = const.bool true %c_2 = const.u16 14 %arr_3 = array.splat array %c_2 %s_4 = struct.make @Pair(%c_1, %arr_3) %c_5 = const.u16 14 %arr_6 = array.splat array %c_5 %e_7 = enum.make @Choice.full(%s_4) %arr_8 = array.splat array, 2> %arr_6 %s_9 = struct.make @Holder(%e_7, %arr_8) local.store %state_10, %s_9 %state_11 = local.load %state_10 local.store %snapshot_12, %state_11 %c_13 = const.u16 99 %state_14 = borrow.mut %state_10 %rows_15 = borrow.field @Holder.rows, %state_14 %c_16 = const.usize 0 %e_17 = borrow.index %rows_15, %c_16 %c_18 = const.usize 0 %e_19 = borrow.index %e_17, %c_18 store %e_19, %c_13 borrow.end %e_19 borrow.end %e_17 borrow.end %rows_15 borrow.end %state_14 %snapshot_20 = borrow.ref %snapshot_12 %rows_21 = borrow.field @Holder.rows, %snapshot_20 %c_22 = const.usize 0 %e_23 = borrow.index %rows_21, %c_22 %c_24 = const.usize 0 %e_25 = borrow.index %e_23, %c_24 %v_26 = load %e_25 borrow.end %e_25 borrow.end %e_23 borrow.end %rows_21 borrow.end %snapshot_20 %c_27 = const.u16 14 %cmp_28 = ne.u16 %v_26, %c_27 cbr %cmp_28, @then_29(), @else_30() then_29: %c_31 = const.u16 1 ret %c_31 else_30: br @endif_32() endif_32: %state_33 = borrow.ref %state_10 %rows_34 = borrow.field @Holder.rows, %state_33 %c_35 = const.usize 1 %e_36 = borrow.index %rows_34, %c_35 %c_37 = const.usize 0 %e_38 = borrow.index %e_36, %c_37 %v_39 = load %e_38 borrow.end %e_38 borrow.end %e_36 borrow.end %rows_34 borrow.end %state_33 %c_40 = const.u16 14 %cmp_41 = ne.u16 %v_39, %c_40 cbr %cmp_41, @then_42(), @else_43() then_42: %c_44 = const.u16 2 ret %c_44 else_43: br @endif_45() endif_45: %snapshot_46 = local.load %snapshot_12 local.store %state_10, %snapshot_46 %c_47 = const.u16 7 %state_48 = borrow.mut %state_10 %rows_49 = borrow.field @Holder.rows, %state_48 %c_50 = const.usize 1 %e_51 = borrow.index %rows_49, %c_50 %c_52 = const.usize 1 %e_53 = borrow.index %e_51, %c_52 store %e_53, %c_47 borrow.end %e_53 borrow.end %e_51 borrow.end %rows_49 borrow.end %state_48 %snapshot_54 = local.load %snapshot_12 %read_55 = call @read(%snapshot_54) ret %read_55