module demo.parallelsquare air 0 lang 0.1 features [arrays, effects, ownership, tasks] fn @square(%s: slice_mut) -> void effects [] entry: %c_1 = const.usize 0 %len_2 = slice.len %s br @while_3(%c_1) while_3(%i_6: usize): %cmp_8 = lt.usize %i_6, %len_2 cbr %cmp_8, @body_9(), @after_4() after_4: ret step_5(%i_7: usize): %one_16 = const.usize 1 %i_17 = add.checked.usize %i_7, %one_16 br @while_3(%i_17) body_9: %e_10 = borrow.index %s, %i_6 %v_11 = load %e_10 borrow.end %e_10 %e_12 = borrow.index %s, %i_6 %v_13 = load %e_12 borrow.end %e_12 %t_14 = mul.checked.u64 %v_11, %v_13 %e_15 = borrow.index %s, %i_6 store %e_15, %t_14 borrow.end %e_15 br @step_5(%i_6) fn @main() -> array effects [task.spawn] entry: %buf_1 = local.alloc array local.zero %buf_1 %c_2 = const.u64 1 %buf_3 = borrow.mut %buf_1 %c_4 = const.usize 0 %e_5 = borrow.index %buf_3, %c_4 store %e_5, %c_2 borrow.end %e_5 borrow.end %buf_3 %c_6 = const.u64 2 %buf_7 = borrow.mut %buf_1 %c_8 = const.usize 1 %e_9 = borrow.index %buf_7, %c_8 store %e_9, %c_6 borrow.end %e_9 borrow.end %buf_7 %c_10 = const.u64 3 %buf_11 = borrow.mut %buf_1 %c_12 = const.usize 2 %e_13 = borrow.index %buf_11, %c_12 store %e_13, %c_10 borrow.end %e_13 borrow.end %buf_11 %c_14 = const.u64 4 %buf_15 = borrow.mut %buf_1 %c_16 = const.usize 3 %e_17 = borrow.index %buf_15, %c_16 store %e_17, %c_14 borrow.end %e_17 borrow.end %buf_15 %buf_18 = borrow.mut %buf_1 %s_19 = slice.make %buf_18 %c_20 = const.usize 2 %l_21, %r_22 = slice.split %s_19, %c_20 %sc_23 = task.scope.begin %t_24 = task.spawn %sc_23, @square(%l_21) %t_25 = task.spawn %sc_23, @square(%r_22) task.join %t_24 task.join %t_25 task.scope.end %sc_23 borrow.end %r_22 borrow.end %l_21 borrow.end %s_19 borrow.end %buf_18 %buf_26 = local.load %buf_1 ret %buf_26