diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index 4677da77f..d2f8348ba 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -79,3 +79,4 @@ jobs: sbt 'testOnly gensym.wasm.TestConcolic' sbt 'testOnly gensym.wasm.TestDriver' sbt 'testOnly gensym.wasm.TestStagedEval' + sbt 'testOnly gensym.wasm.TestStagedConcolicEval' diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_add.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_add.wat new file mode 100644 index 000000000..9d7fa0445 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_add.wat @@ -0,0 +1,910 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 0 + i32.const 1036 + call $array_new + i32.store offset=1040 + i32.const 0 + i32.load offset=1040 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 0 + local.get 0 + i32.const 12 + i32.add + call $array_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + alloc + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + alloc + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + free + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_addAt2.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_addAt2.wat new file mode 100644 index 000000000..953891da9 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_addAt2.wat @@ -0,0 +1,1078 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 1032 + call $array_new + drop + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + i32.const 0 + i32.load offset=1032 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 8 + i32.const 0 + i32.load offset=1032 + local.get 0 + i32.const 8 + i32.add + i32.const 1 + call $array_add_at + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1032 + call $array_destroy + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_add_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $array_add + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + br_if 1 (;@3;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + call $expand_capacity + i32.store offset=12 + block ;; label = @3 + local.get 3 + i32.load offset=12 + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=12 + i32.store offset=28 + br 2 (;@1;) + end + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + i32.store offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=8 + call $memmove + drop + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1028 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1028 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1028 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1028 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1028 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1028 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1028 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1028 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "a\00") + (data (;1;) (i32.const 1028) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_contains.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_contains.wat new file mode 100644 index 000000000..ad83e7f65 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_contains.wat @@ -0,0 +1,997 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=12 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + local.get 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_contains + i32.store offset=8 + local.get 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_contains + i32.store offset=4 + local.get 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $array_contains + i32.store + i32.const 2 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_deepCopy.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_deepCopy.wat new file mode 100644 index 000000000..38429cc0e --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_deepCopy.wat @@ -0,0 +1,1154 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + i32.const 1040 + call $array_copy_deep + drop + i32.const 0 + i32.load offset=1040 + call $array_size + i32.const 0 + i32.load offset=1036 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 0 + local.get 0 + i32.const 12 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 2 + call $array_destroy_cb + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_destroy_cb (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + call_indirect (type 2) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + call $array_destroy + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_copy_deep (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 28 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 1) + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 4 + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 0) + local.set 2 + local.get 3 + i32.load offset=12 + local.get 2 + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=24 + call_indirect (type 2) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + f32.load offset=8 + f32.store offset=8 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=24 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=12 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $copy (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + i32.load + i32.store + local.get 1 + i32.load offset=8 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $copy $free $malloc $calloc) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_getAt.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_getAt.wat new file mode 100644 index 000000000..9ca50f5e8 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_getAt.wat @@ -0,0 +1,898 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 0 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "e\00c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_indexOf.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_indexOf.wat new file mode 100644 index 000000000..a72630d29 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_indexOf.wat @@ -0,0 +1,910 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 12 + i32.add + call $array_index_of + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + call $array_index_of + drop + i32.const 0 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_index_of (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterAdd.wat new file mode 100644 index 000000000..f8d4b58d6 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterAdd.wat @@ -0,0 +1,1485 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + i32.const 1040 + call $array_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=36 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=24 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $array_add + drop + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1040 + call $array_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $array_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 24 + i32.add + call $array_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 5 + i32.const 0 + i32.load offset=1040 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 3 + local.get 0 + call $array_get_at + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 4 + local.get 0 + call $array_get_at + drop + local.get 0 + i32.load offset=28 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $array_destroy + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_add_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $array_add + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + br_if 1 (;@3;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + call $expand_capacity + i32.store offset=12 + block ;; label = @3 + local.get 3 + i32.load offset=12 + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=12 + i32.store offset=28 + br 2 (;@1;) + end + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + i32.store offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=8 + call $memmove + drop + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $array_iter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $array_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $array_iter_add (type 0) (param i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.set 1 + local.get 2 + i32.load offset=8 + local.set 0 + local.get 2 + i32.load offset=12 + local.tee 3 + local.get 3 + i32.load offset=4 + local.tee 3 + i32.const 1 + i32.add + i32.store offset=4 + local.get 1 + local.get 0 + local.get 3 + call $array_add_at + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00N\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterRemove.wat new file mode 100644 index 000000000..db56de31f --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterRemove.wat @@ -0,0 +1,1348 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=28 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 40 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 36 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 32 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 28 + i32.add + call $array_add + drop + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=36 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=28 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1036 + call $array_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + call $array_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + i32.const 0 + call $array_iter_remove + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 32 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_remove_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + i32.store offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + call $memmove + drop + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $array_iter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $array_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $array_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 7 + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load offset=8 + br_if 0 (;@1;) + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + call $array_remove_at + i32.store offset=4 + block ;; label = @2 + local.get 2 + i32.load offset=4 + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + end + end + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterReplace.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterReplace.wat new file mode 100644 index 000000000..9d2208264 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_iterReplace.wat @@ -0,0 +1,1277 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1048 + call $array_new + drop + local.get 0 + i32.const 1042 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=52 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=40 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 56 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 52 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 48 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 44 + i32.add + call $array_add + drop + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1048 + call $array_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + call $array_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=20 + i32.load + local.get 0 + i32.load offset=48 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 16 + i32.add + call $array_iter_replace + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 12 + i32.add + call $array_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 48 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + call $array_destroy + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_replace_at (type 4) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 4 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 4 + i32.load offset=20 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $array_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $array_iter_init (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $array_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $array_iter_replace (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=4 + call $array_replace_at + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "replacement\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_reduce.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_reduce.wat new file mode 100644 index 000000000..53e62556e --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_reduce.wat @@ -0,0 +1,1061 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (param i32 i32 i32))) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $reduce_add (type 3) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=28 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=28 + i32.load + local.set 2 + br 1 (;@1;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + i32.load + local.set 2 + br 1 (;@1;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.add + i32.store) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1040 + call $array_new + drop + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $array_reduce + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $array_reduce + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.add + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $array_reduce + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.add + local.get 0 + i32.load offset=16 + i32.add + local.get 0 + i32.load offset=12 + i32.add + local.get 0 + i32.load offset=8 + i32.add + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_reduce (type 3) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.load + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + i32.load offset=12 + i32.load + i32.const 0 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + call_indirect (type 3) + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.load + i32.const 1 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=12 + i32.load offset=12 + i32.load offset=4 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + call_indirect (type 3) + end + local.get 3 + i32.const 2 + i32.store + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=12 + i32.load offset=12 + local.get 3 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + call_indirect (type 3) + local.get 3 + local.get 3 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 16 + i32.add + global.set 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $reduce_add $malloc $calloc $free) + (data (;0;) (i32.const 1024) "e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_remove.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_remove.wat new file mode 100644 index 000000000..3f765c6c8 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_remove.wat @@ -0,0 +1,1173 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1032 + call $array_new + drop + local.get 0 + i32.const 1024 + call 0 + i32.store offset=24 + local.get 0 + i32.load offset=24 + i32.const 2 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=24 + i32.const 16 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=24 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + i32.const 0 + i32.load offset=1032 + local.get 0 + i32.load offset=8 + call $array_add + drop + local.get 0 + local.get 0 + i32.load offset=20 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=8 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1032 + local.get 0 + i32.load offset=16 + i32.const 0 + call $array_remove + drop + i32.const 0 + i32.load offset=1032 + call $array_size + local.get 0 + i32.load offset=24 + i32.lt_u + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1032 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_remove (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 12 + i32.add + call $array_index_of + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.const 8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + local.get 3 + i32.load offset=12 + i32.sub + i32.const 2 + i32.shl + i32.store offset=4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + call $memmove + drop + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_index_of (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1028 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1028 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1028 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1028 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1028 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1028 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1028 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1028 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "n\00") + (data (;1;) (i32.const 1028) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_removeAll.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_removeAll.wat new file mode 100644 index 000000000..67a286185 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_removeAll.wat @@ -0,0 +1,870 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 1))) + (import "i32" "sym_assume" (func (;1;) (type 2))) + (import "i32" "sym_assert" (func (;2;) (type 2))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1032 + call $array_new + drop + local.get 0 + i32.const 1024 + call 0 + i32.store offset=24 + local.get 0 + i32.load offset=24 + i32.const 2 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=24 + i32.const 16 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=24 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + i32.const 0 + i32.load offset=1032 + local.get 0 + i32.load offset=8 + call $array_add + drop + local.get 0 + local.get 0 + i32.load offset=20 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=8 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1032 + call $array_remove_all + i32.const 0 + i32.load offset=1032 + call $array_size + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1032 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_remove_all (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1028 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1028 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1028 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1028 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1028 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1028 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1028 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1028 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "n\00") + (data (;1;) (i32.const 1028) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_removeAt.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_removeAt.wat new file mode 100644 index 000000000..e1de2f881 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_removeAt.wat @@ -0,0 +1,1143 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 2 + i32.const 0 + call $array_remove_at + drop + i32.const 3 + i32.const 0 + i32.load offset=1036 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 12 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_remove_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + i32.store offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + call $memmove + drop + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "e\00c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_replaceAt.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_replaceAt.wat new file mode 100644 index 000000000..7a89db927 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_replaceAt.wat @@ -0,0 +1,966 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + i32.const 2 + i32.const 0 + call $array_replace_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_replace_at (type 4) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 4 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 4 + i32.load offset=20 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $array_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "r\00c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_reverse.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_reverse.wat new file mode 100644 index 000000000..5b9b5b766 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_reverse.wat @@ -0,0 +1,996 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + call $array_reverse + i32.const 0 + i32.load offset=1036 + i32.const 0 + local.get 0 + i32.const 12 + i32.add + call $array_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_reverse (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 1 + i32.sub + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + i32.load + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 1 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + local.get 1 + i32.load + i32.store + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const -1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_shallowCopy.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_shallowCopy.wat new file mode 100644 index 000000000..f8c3df0d3 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_shallowCopy.wat @@ -0,0 +1,1039 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + i32.const 1036 + call $array_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 1040 + call $array_copy_shallow + drop + i32.const 0 + i32.load offset=1040 + call $array_size + i32.const 0 + i32.load offset=1036 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $array_get_at + drop + i32.const 0 + i32.load offset=1040 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $array_destroy + i32.const 0 + i32.load offset=1036 + call $array_destroy + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_copy_shallow (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 28 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 4 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call_indirect (type 0) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=12 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + f32.load offset=8 + f32.store offset=8 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=24 + i32.store offset=24 + local.get 2 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_subarray.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_subarray.wat new file mode 100644 index 000000000..a2143b4ca --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_subarray.wat @@ -0,0 +1,1126 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + i32.const 1040 + call $array_new + drop + local.get 0 + i32.const 1032 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=24 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1040 + i32.const 1 + i32.const 3 + local.get 0 + i32.const 20 + i32.add + call $array_subarray + drop + i32.const 3 + local.get 0 + i32.load offset=20 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=20 + i32.const 0 + local.get 0 + i32.const 16 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=20 + i32.const 1 + local.get 0 + i32.const 12 + i32.add + call $array_get_at + drop + local.get 0 + i32.load offset=20 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $array_get_at + drop + local.get 0 + i32.const 36 + i32.add + local.get 0 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 28 + i32.add + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=20 + call $array_destroy + i32.const 0 + i32.load offset=1040 + call $array_destroy + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_subarray (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=16 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 4 + i32.const 3 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.const 1 + i32.const 28 + local.get 4 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @2 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 4 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 4 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 1) + local.set 3 + local.get 4 + i32.load offset=8 + local.get 3 + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=24 + i32.load offset=24 + call_indirect (type 2) + local.get 4 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=24 + i32.load offset=24 + i32.store offset=24 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + i32.store + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=8 + i32.load + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=12 + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 4 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28 + local.set 3 + local.get 4 + i32.const 32 + i32.add + global.set 0 + local.get 3) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterAdd.wat new file mode 100644 index 000000000..dcc8dc546 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterAdd.wat @@ -0,0 +1,1967 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 112 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=108 + i32.const 1048 + call $array_new + drop + local.get 0 + i32.const 1040 + call 0 + i32.store offset=104 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=96 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.const 94 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 94 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 102 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 78 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.const 94 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.const 46 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 46 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.const 46 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.const 46 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.const 70 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.const 54 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.const 62 + i32.add + call $strcmp + i32.const 0 + i32.eq + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 102 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 94 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 86 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 78 + i32.add + call $array_add + drop + i32.const 1052 + call $array_new + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 70 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 62 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 54 + i32.add + call $array_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1052 + call $array_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $array_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 94 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 46 + i32.add + local.get 0 + i32.const 38 + i32.add + call $array_zip_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 46 + i32.add + local.get 0 + i32.const 4 + i32.add + call $array_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.const 4 + i32.add + call $array_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 4 + i32.add + call $array_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 46 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 38 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 5 + i32.const 0 + i32.load offset=1048 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 4 + i32.const 0 + i32.load offset=1052 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + call $array_destroy + i32.const 0 + i32.load offset=1048 + call $array_destroy + local.get 0 + i32.const 112 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_add_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $array_add + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + br_if 1 (;@3;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + call $expand_capacity + i32.store offset=12 + block ;; label = @3 + local.get 3 + i32.load offset=12 + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=12 + i32.store offset=28 + br 2 (;@1;) + end + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + i32.store offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=8 + call $memmove + drop + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_index_of (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $array_zip_iter_init (type 5) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $array_zip_iter_next (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_zip_iter_add (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + local.tee 2 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=8 + call $expand_capacity + br_if 1 (;@3;) + end + local.get 3 + i32.load offset=4 + i32.load + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=4 + call $expand_capacity + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + call $array_add_at + drop + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + call $array_add_at + drop + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterNext.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterNext.wat new file mode 100644 index 000000000..e13a79336 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterNext.wat @@ -0,0 +1,1235 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + i32.const 1044 + call $array_new + drop + local.get 0 + i32.const 1036 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 70 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 62 + i32.add + call $array_add + drop + i32.const 1048 + call $array_new + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 54 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 46 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 38 + i32.add + call $array_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $array_zip_iter_init + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $array_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + br_if 0 (;@3;) + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load offset=4 + call $CHECK_EQUAL_C_STRING + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 70 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.load offset=4 + call $CHECK_EQUAL_C_STRING + end + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 3 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + call $array_destroy + i32.const 0 + i32.load offset=1044 + call $array_destroy + local.get 0 + i32.const 96 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_zip_iter_init (type 4) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $array_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $CHECK_EQUAL_C_STRING (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterRemove.wat new file mode 100644 index 000000000..e7d8e1bc5 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterRemove.wat @@ -0,0 +1,1702 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32))) + (type (;6;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + i32.const 1044 + call $array_new + drop + local.get 0 + i32.const 1036 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 78 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 70 + i32.add + local.get 0 + i32.const 78 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.const 78 + i32.add + call $strcmp + i32.const 0 + i32.eq + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 70 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 62 + i32.add + call $array_add + drop + i32.const 1048 + call $array_new + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 54 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 46 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 38 + i32.add + call $array_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $array_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $array_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 78 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 4 + i32.add + local.get 0 + call $array_zip_iter_remove + drop + end + br 0 (;@2;) + end + end + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.load offset=4 + call $CHECK_EQUAL_C_STRING + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 46 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + i32.const 0 + i32.load offset=1048 + call $array_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + call $array_destroy + i32.const 0 + i32.load offset=1044 + call $array_destroy + local.get 0 + i32.const 96 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_remove_at (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + i32.store offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + call $memmove + drop + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $array_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $array_zip_iter_init (type 5) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $array_zip_iter_next (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_zip_iter_remove (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=4 + call $array_remove_at + drop + local.get 3 + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load + call $array_remove_at + drop + local.get 3 + i32.load offset=8 + i32.const 1 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.const 7 + i32.store offset=12 + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 4) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $CHECK_EQUAL_C_STRING (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterReplace.wat b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterReplace.wat new file mode 100644 index 000000000..4eaaedd89 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/array/array_test_zipIterReplace.wat @@ -0,0 +1,1718 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32 i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 128 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=124 + i32.const 1048 + call $array_new + drop + local.get 0 + i32.const 1040 + call 0 + i32.store offset=120 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=112 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 118 + i32.add + local.get 0 + i32.const 110 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.const 110 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.const 118 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.const 94 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.const 110 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 118 + i32.add + local.get 0 + i32.const 62 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.const 62 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.const 62 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 110 + i32.add + local.get 0 + i32.const 62 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.const 86 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.const 70 + i32.add + call $strcmp + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.const 78 + i32.add + call $strcmp + i32.const 0 + i32.eq + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 118 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 110 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 102 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 94 + i32.add + call $array_add + drop + i32.const 1052 + call $array_new + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 86 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 78 + i32.add + call $array_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 70 + i32.add + call $array_add + drop + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1052 + call $array_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + local.get 0 + i32.const 24 + i32.add + call $array_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + local.get 0 + i32.const 110 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $array_zip_iter_replace + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.const 12 + i32.add + call $array_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.const 12 + i32.add + call $array_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 54 + i32.add + call $array_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + call $array_destroy + i32.const 0 + i32.load offset=1048 + call $array_destroy + local.get 0 + i32.const 128 + i32.add + global.set 0 + i32.const 0) + (func $array_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $array_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $array_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_replace_at (type 4) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 4 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + local.get 4 + i32.load offset=24 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 4 + i32.load offset=20 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $array_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $array_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=12 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=4) + (func $array_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $array_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_zip_iter_replace (type 7) (param i32 i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 5 + global.set 0 + local.get 5 + local.get 0 + i32.store offset=24 + local.get 5 + local.get 1 + i32.store offset=20 + local.get 5 + local.get 2 + i32.store offset=16 + local.get 5 + local.get 3 + i32.store offset=12 + local.get 5 + local.get 4 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=24 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=24 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 5 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 5 + i32.load offset=24 + i32.load + local.get 5 + i32.load offset=20 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=12 + call $array_replace_at + drop + local.get 5 + i32.load offset=24 + i32.load offset=4 + local.get 5 + i32.load offset=16 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=8 + call $array_replace_at + drop + local.get 5 + i32.const 0 + i32.store offset=28 + end + local.get 5 + i32.load offset=28 + local.set 4 + local.get 5 + i32.const 32 + i32.add + global.set 0 + local.get 4) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt1.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt1.wat new file mode 100644 index 000000000..c5db213ce --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt1.wat @@ -0,0 +1,1757 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 28 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 16 + i32.add + i32.const 4 + call $deque_add_at + drop + local.get 0 + i32.const 0 + i32.load offset=1044 + call $deque_get_buffer + i32.store offset=12 + local.get 0 + i32.load offset=12 + i32.load offset=16 + local.get 0 + i32.const 16 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.load offset=20 + local.get 0 + i32.const 24 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=12 + i32.load offset=24 + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 20 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt2.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt2.wat new file mode 100644 index 000000000..e1ff4a51c --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt2.wat @@ -0,0 +1,1779 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + i32.const 1 + call $deque_add_at + drop + local.get 0 + i32.const 0 + i32.load offset=1044 + call $deque_get_buffer + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=20 + i32.store offset=24 + local.get 0 + i32.load offset=24 + local.get 0 + i32.const 32 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 56 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=28 + i32.store offset=16 + local.get 0 + i32.load offset=16 + local.get 0 + i32.const 48 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=12 + i32.store offset=12 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 36 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt3.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt3.wat new file mode 100644 index 000000000..5786e83ac --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt3.wat @@ -0,0 +1,1779 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + i32.const 3 + call $deque_add_at + drop + local.get 0 + i32.const 0 + i32.load offset=1044 + call $deque_get_buffer + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=24 + i32.store offset=24 + local.get 0 + i32.load offset=24 + local.get 0 + i32.const 32 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 52 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=28 + i32.store offset=16 + local.get 0 + i32.load offset=16 + local.get 0 + i32.const 48 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=4 + i32.store offset=12 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 56 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt4.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt4.wat new file mode 100644 index 000000000..f582fa0b6 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt4.wat @@ -0,0 +1,1779 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + i32.const 1 + call $deque_add_at + drop + local.get 0 + i32.const 0 + i32.load offset=1044 + call $deque_get_buffer + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load + i32.load + i32.store offset=24 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=16 + i32.load + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=40 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=36 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=28 + i32.load + i32.store offset=12 + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=56 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt5.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt5.wat new file mode 100644 index 000000000..5a0d3e9dd --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addAt5.wat @@ -0,0 +1,1779 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + i32.const 1 + call $deque_add_at + drop + local.get 0 + i32.const 0 + i32.load offset=1044 + call $deque_get_buffer + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=28 + i32.load + i32.store offset=24 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=56 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load + i32.load + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=52 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=20 + i32.load + i32.store offset=16 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=36 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=4 + i32.load + i32.store offset=12 + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addFirst.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addFirst.wat new file mode 100644 index 000000000..611b44929 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addFirst.wat @@ -0,0 +1,1118 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add_first + drop + i32.const 3 + i32.const 0 + i32.load offset=1036 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.load offset=1036 + call $deque_capacity + i32.store offset=12 + local.get 0 + i32.const 0 + i32.load offset=1036 + call $deque_get_buffer + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.get 0 + i32.const 24 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.get 0 + i32.const 20 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.const 3 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.get 0 + i32.const 16 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addLast.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addLast.wat new file mode 100644 index 000000000..3beb0a614 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_addLast.wat @@ -0,0 +1,1081 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add_last + drop + i32.const 3 + i32.const 0 + i32.load offset=1036 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.load offset=1036 + call $deque_get_buffer + i32.store offset=12 + local.get 0 + local.get 0 + i32.load offset=12 + i32.load + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 24 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=12 + i32.load offset=4 + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 20 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 16 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_bufferExpansion.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_bufferExpansion.wat new file mode 100644 index 000000000..a148d47ee --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_bufferExpansion.wat @@ -0,0 +1,1233 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 1040 + call $deque_conf_init + i32.const 0 + i32.const 4 + i32.store offset=1040 + i32.const 1040 + i32.const 1056 + call $deque_new_conf + drop) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1056 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=36 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 56 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 52 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 48 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 44 + i32.add + call $deque_add_last + drop + local.get 0 + i32.const 0 + i32.load offset=1056 + call $deque_capacity + i32.store offset=32 + i32.const 4 + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 40 + i32.add + call $deque_add_first + drop + local.get 0 + i32.const 0 + i32.load offset=1056 + call $deque_capacity + i32.store offset=32 + i32.const 8 + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.load offset=1056 + call $deque_get_buffer + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load + i32.load + i32.store offset=24 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=48 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=4 + i32.load + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=56 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=8 + i32.load + i32.store offset=16 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=52 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=44 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=28 + i32.load + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=40 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + local.get 0 + local.get 0 + i32.load offset=28 + i32.load offset=16 + i32.load + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.get 0 + i32.load offset=36 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66608)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) "0\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_capacity.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_capacity.wat new file mode 100644 index 000000000..8fcc078d3 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_capacity.wat @@ -0,0 +1,1070 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 24 + i32.add + call $deque_conf_init + local.get 0 + i32.const 2 + i32.store offset=24 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + call $deque_new_conf + drop + i32.const 2 + local.get 0 + i32.load offset=20 + call $deque_capacity + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 16 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 12 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 8 + i32.add + call $deque_add + drop + i32.const 4 + local.get 0 + i32.load offset=20 + call $deque_capacity + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_contains.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_contains.wat new file mode 100644 index 000000000..e7e49fbe2 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_contains.wat @@ -0,0 +1,1181 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=4 + local.get 0 + i32.const 1024 + call 0 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 20 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 16 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 4 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 24 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=28 + i32.load offset=8 + local.get 2 + i32.load offset=20 + i32.add + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + block ;; label = @3 + local.get 2 + i32.load offset=28 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=16) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_copyDeep.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_copyDeep.wat new file mode 100644 index 000000000..2c21c9f14 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_copyDeep.wat @@ -0,0 +1,1484 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (type (;7;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 4 + call $malloc + i32.store offset=40 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=36 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=32 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=28 + i32.store + local.get 0 + i32.load offset=36 + local.get 0 + i32.load offset=24 + i32.store + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=20 + i32.store + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.load offset=40 + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.load offset=36 + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.load offset=32 + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + local.get 0 + i32.const 16 + i32.add + call $deque_copy_deep + drop + local.get 0 + local.get 0 + i32.load offset=16 + call $deque_size + i32.store offset=12 + i32.const 3 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + i32.const 0 + local.get 0 + i32.const 8 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=16 + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=16 + i32.const 2 + local.get 0 + call $deque_get_at + drop + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + i32.const 2 + call $deque_destroy_cb + local.get 0 + i32.load offset=40 + call 5 + local.get 0 + i32.load offset=36 + call 5 + local.get 0 + i32.load offset=32 + call 5 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_destroy_cb (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_remove_all_cb + local.get 2 + i32.load offset=12 + call $deque_destroy + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $deque_remove_all_cb (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_foreach + local.get 2 + i32.load offset=12 + call $deque_remove_all + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $deque_foreach (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store + local.get 2 + i32.load offset=12 + i32.load offset=16 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=8 + call_indirect (type 2) + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $deque_remove_all (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 7) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=20 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_copy_deep (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 32 + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=12 + local.get 2 + i32.store offset=16 + block ;; label = @2 + local.get 2 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=28 + call_indirect (type 2) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=24 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=28 + i32.store offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.load offset=16 + local.get 3 + i32.load offset=20 + call $copy_buffer + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $copy (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + i32.load + i32.store + local.get 1 + i32.load offset=8 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $copy $free $malloc $calloc) + (data (;0;) (i32.const 1024) "z\00y\00x\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_copyShallow.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_copyShallow.wat new file mode 100644 index 000000000..5fceef6b2 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_copyShallow.wat @@ -0,0 +1,1281 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 32 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 28 + i32.add + call $deque_copy_shallow + drop + local.get 0 + local.get 0 + i32.load offset=28 + call $deque_size + i32.store offset=24 + i32.const 3 + local.get 0 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=28 + i32.const 0 + local.get 0 + i32.const 20 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=28 + i32.const 1 + local.get 0 + i32.const 16 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=28 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=20 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=36 + local.get 0 + i32.load offset=16 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=28 + call $deque_destroy + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=20 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_copy_shallow (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call_indirect (type 1) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=20 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=24 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=28 + i32.store offset=28 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.load offset=16 + i32.const 0 + call $copy_buffer + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + local.get 2 + i32.load + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter1.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter1.wat new file mode 100644 index 000000000..858e8dca0 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter1.wat @@ -0,0 +1,1355 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (func $pred1 (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.le_s + i32.const 1 + i32.and) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 28 + i32.add + call $pred1 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 24 + i32.add + call $pred1 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 20 + i32.add + call $pred1 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 40 + i32.add + call $pred1 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 36 + i32.add + call $pred1 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 32 + i32.add + call $pred1 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1040 + i32.const 1 + local.get 0 + i32.const 16 + i32.add + call $deque_filter + drop + i32.const 3 + local.get 0 + i32.load offset=16 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=16 + call $deque_get_buffer + i32.store offset=12 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.const 40 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.load offset=4 + local.get 0 + i32.const 36 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 32 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + call 5 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $deque_filter (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $deque_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.const 8 + i32.add + call $deque_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + call $deque_add + drop + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred1 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter2.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter2.wat new file mode 100644 index 000000000..1edb393cf --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter2.wat @@ -0,0 +1,1354 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (func $pred2 (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.gt_s + i32.const 1 + i32.and) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 28 + i32.add + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 24 + i32.add + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 20 + i32.add + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 40 + i32.add + call $pred2 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 36 + i32.add + call $pred2 + br_if 0 (;@1;) + local.get 0 + i32.const 32 + i32.add + call $pred2 + i32.const 0 + i32.ne + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1040 + i32.const 1 + local.get 0 + i32.const 16 + i32.add + call $deque_filter + drop + local.get 0 + local.get 0 + i32.load offset=16 + call $deque_get_buffer + i32.store offset=12 + i32.const 3 + local.get 0 + i32.load offset=16 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.const 28 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.load offset=4 + local.get 0 + i32.const 24 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.load offset=8 + local.get 0 + i32.const 20 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + call 5 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $deque_filter (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $deque_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.const 8 + i32.add + call $deque_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + call $deque_add + drop + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred2 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter3.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter3.wat new file mode 100644 index 000000000..25f755fc4 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filter3.wat @@ -0,0 +1,1332 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (func $pred3 (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 5 + i32.gt_s + i32.const 1 + i32.and) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 28 + i32.add + call $pred3 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 24 + i32.add + call $pred3 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 20 + i32.add + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 40 + i32.add + call $pred3 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 36 + i32.add + call $pred3 + br_if 0 (;@1;) + local.get 0 + i32.const 32 + i32.add + call $pred3 + i32.const 0 + i32.ne + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1040 + i32.const 1 + local.get 0 + i32.const 16 + i32.add + call $deque_filter + drop + local.get 0 + local.get 0 + i32.load offset=16 + call $deque_get_buffer + i32.store offset=12 + i32.const 1 + local.get 0 + i32.load offset=16 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.const 20 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=16 + call 5 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_get_buffer (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16) + (func $deque_filter (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $deque_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.const 8 + i32.add + call $deque_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + call $deque_add + drop + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred3 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut1.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut1.wat new file mode 100644 index 000000000..cd1e9402f --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut1.wat @@ -0,0 +1,1974 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (func $pred1 (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.le_s + i32.const 1 + i32.and) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=4 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 12 + i32.add + call $pred1 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 8 + i32.add + call $pred1 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 4 + i32.add + call $pred1 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 24 + i32.add + call $pred1 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 20 + i32.add + call $pred1 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 16 + i32.add + call $pred1 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $deque_add_last + drop + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 1 + call $deque_filter_mut + drop + i32.const 3 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=36 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=36 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + block ;; label = @6 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=32 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $deque_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + call $deque_size + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.add + local.get 2 + i32.load offset=12 + i32.and + i32.store offset=8 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + br_if 0 (;@5;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.const 0 + call $deque_remove_at + drop + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred1 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut2.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut2.wat new file mode 100644 index 000000000..7a05d4d06 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut2.wat @@ -0,0 +1,1977 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (func $pred2 (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.gt_s + i32.const 1 + i32.and) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=4 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 12 + i32.add + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 8 + i32.add + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 4 + i32.add + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 24 + i32.add + call $pred2 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 20 + i32.add + call $pred2 + br_if 0 (;@1;) + local.get 0 + i32.const 16 + i32.add + call $pred2 + i32.const 0 + i32.ne + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $deque_add_last + drop + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 1 + call $deque_filter_mut + drop + i32.const 3 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=36 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=36 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + block ;; label = @6 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=32 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $deque_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + call $deque_size + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.add + local.get 2 + i32.load offset=12 + i32.and + i32.store offset=8 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + br_if 0 (;@5;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.const 0 + call $deque_remove_at + drop + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred2 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut3.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut3.wat new file mode 100644 index 000000000..2c1498575 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_filterMut3.wat @@ -0,0 +1,1947 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (func $pred3 (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 5 + i32.gt_s + i32.const 1 + i32.and) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=4 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.const 12 + i32.add + call $pred3 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 8 + i32.add + call $pred3 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 4 + i32.add + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 24 + i32.add + call $pred3 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 20 + i32.add + call $pred3 + br_if 0 (;@1;) + local.get 0 + i32.const 16 + i32.add + call $pred3 + i32.const 0 + i32.ne + i32.const -1 + i32.xor + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $deque_add_last + drop + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + i32.const 1 + call $deque_filter_mut + drop + i32.const 1 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store + i32.const 0 + i32.load offset=1040 + local.get 0 + call $deque_remove_first + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=36 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=36 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + block ;; label = @6 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=32 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $deque_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + call $deque_size + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.add + local.get 2 + i32.load offset=12 + i32.and + i32.store offset=8 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + br_if 0 (;@5;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.const 0 + call $deque_remove_at + drop + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred3 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getAt.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getAt.wat new file mode 100644 index 000000000..348fc5335 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getAt.wat @@ -0,0 +1,1124 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + local.get 0 + i32.const 12 + i32.add + call $deque_get_at + drop + local.get 0 + i32.const 0 + i32.load offset=1036 + i32.const 42 + local.get 0 + i32.const 8 + i32.add + call $deque_get_at + i32.store offset=4 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 8 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=20 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getFirst.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getFirst.wat new file mode 100644 index 000000000..f622cfc84 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getFirst.wat @@ -0,0 +1,1143 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $deque_get_first + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getLast.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getLast.wat new file mode 100644 index 000000000..7d21853ea --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_getLast.wat @@ -0,0 +1,1155 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $deque_get_last + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterAdd.wat new file mode 100644 index 000000000..f6ddbde95 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterAdd.wat @@ -0,0 +1,2160 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $deque_add + drop + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=52 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=48 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=36 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + call $deque_iter_init + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 6 + i32.const 0 + i32.load offset=1044 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + call $deque_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=44 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 32 + i32.add + call $deque_iter_add + drop + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.const 3 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 16 + i32.add + call $deque_iter_index + i32.const 1 + i32.sub + i32.eq + i32.const 1 + i32.and + call 2 + end + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 7 + i32.const 0 + i32.load offset=1044 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 4 + local.get 0 + i32.const 4 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=20 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $deque_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + i32.load offset=24 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.add + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=24 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_iter_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $deque_add_at + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=4 + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_iter_index (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4 + i32.const 1 + i32.sub) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterNext.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterNext.wat new file mode 100644 index 000000000..32742da33 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterNext.wat @@ -0,0 +1,1379 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=36 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 56 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 52 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 48 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 44 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $deque_add + drop + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=52 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=48 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=36 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1040 + call $deque_iter_init + local.get 0 + i32.const 0 + i32.store offset=20 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 16 + i32.add + call $deque_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 12 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + call 2 + br 0 (;@2;) + end + end + call $teardown_tests + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=20 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $deque_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + i32.load offset=24 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.add + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=24 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterRemove.wat new file mode 100644 index 000000000..f3029b9e4 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_iterRemove.wat @@ -0,0 +1,2148 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1040 + call $deque_new + i32.store offset=1044) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $deque_add + drop + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=36 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=32 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=24 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=20 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1040 + call $deque_iter_init + local.get 0 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + call $deque_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.const 3 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 8 + i32.add + i32.const 0 + call $deque_iter_remove + drop + end + block ;; label = @3 + block ;; label = @4 + local.get 0 + i32.load offset=4 + i32.const 2 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + i32.const 5 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + br 1 (;@3;) + end + i32.const 6 + i32.const 0 + i32.load offset=1040 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.const 3 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 0 + i32.const 8 + i32.add + call $deque_iter_index + i32.eq + i32.const 1 + i32.and + call 2 + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=36 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=36 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + block ;; label = @6 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=32 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $deque_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + i32.load offset=24 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.add + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=24 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=4 + local.get 2 + i32.const 16 + i32.add + call $deque_remove_at + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + br_if 0 (;@2;) + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const -1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=24 + i32.const 1 + i32.store offset=8 + block ;; label = @3 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + end + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $deque_iter_index (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4 + i32.const 1 + i32.sub) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeAll.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeAll.wat new file mode 100644 index 000000000..18c1cf6ca --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeAll.wat @@ -0,0 +1,1194 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + call $deque_remove_all + local.get 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $deque_get_first + i32.store offset=8 + local.get 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $deque_get_last + i32.store + i32.const 8 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 8 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_remove_all (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeFirst.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeFirst.wat new file mode 100644 index 000000000..43347be1b --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeFirst.wat @@ -0,0 +1,1263 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $deque_get_first + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $deque_remove_first + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $deque_get_first + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeLast.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeLast.wat new file mode 100644 index 000000000..e1129bc37 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_removeLast.wat @@ -0,0 +1,1278 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add_first + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $deque_add_last + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $deque_get_last + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $deque_remove_last + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $deque_get_last + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_reverse.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_reverse.wat new file mode 100644 index 000000000..c09fe70cf --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_reverse.wat @@ -0,0 +1,1269 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + call $deque_reverse + i32.const 0 + i32.load offset=1036 + i32.const 0 + local.get 0 + i32.const 12 + i32.add + call $deque_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $deque_get_at + drop + i32.const 0 + i32.load offset=1036 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $deque_get_at + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=20 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_reverse (type 2) (param i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=44 + local.get 1 + local.get 1 + i32.load offset=44 + i32.load + i32.store offset=32 + local.get 1 + local.get 1 + i32.load offset=44 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 1 + local.get 1 + i32.load offset=44 + i32.load offset=8 + i32.store offset=24 + local.get 1 + i32.const 0 + i32.store offset=40 + local.get 1 + local.get 1 + i32.load offset=32 + i32.const 1 + i32.sub + i32.store offset=36 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=40 + local.get 1 + i32.load offset=32 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 1 + local.get 1 + i32.load offset=24 + local.get 1 + i32.load offset=40 + i32.add + local.get 1 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 1 + local.get 1 + i32.load offset=24 + local.get 1 + i32.load offset=36 + i32.add + local.get 1 + i32.load offset=28 + i32.and + i32.store offset=16 + local.get 1 + local.get 1 + i32.load offset=44 + i32.load offset=16 + local.get 1 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=44 + i32.load offset=16 + local.get 1 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 1 + i32.load offset=44 + i32.load offset=16 + local.get 1 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 1 + i32.load offset=44 + i32.load offset=16 + local.get 1 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 1 + i32.load offset=12 + i32.store + local.get 1 + local.get 1 + i32.load offset=40 + i32.const 1 + i32.add + i32.store offset=40 + local.get 1 + local.get 1 + i32.load offset=36 + i32.const -1 + i32.add + i32.store offset=36 + br 0 (;@2;) + end + end) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_size.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_size.wat new file mode 100644 index 000000000..a4ea6bd77 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_size.wat @@ -0,0 +1,1062 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $deque_add + drop + local.get 0 + i32.const 0 + i32.load offset=1036 + call $deque_size + i32.store offset=8 + i32.const 4 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_trimCapacity.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_trimCapacity.wat new file mode 100644 index 000000000..022703733 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_trimCapacity.wat @@ -0,0 +1,1175 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1036 + call $deque_new + i32.store offset=1040) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=4 + local.get 0 + i32.const 1024 + call 0 + i32.store + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + call $deque_add + drop + i32.const 8 + i32.const 0 + i32.load offset=1036 + call $deque_capacity + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + call $deque_trim_capacity + drop + i32.const 4 + i32.const 0 + i32.load offset=1036 + call $deque_capacity + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_trim_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load + call $upper_pow_two + i32.store offset=4 + block ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=20 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterAdd.wat new file mode 100644 index 000000000..88a1a05f5 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterAdd.wat @@ -0,0 +1,2712 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 112 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=108 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=104 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=80 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 102 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 94 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $deque_add + drop + local.get 0 + i32.const 48 + i32.add + call $deque_new + drop + local.get 0 + i32.load offset=48 + local.get 0 + i32.const 70 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=48 + local.get 0 + i32.const 62 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=48 + local.get 0 + i32.const 54 + i32.add + call $deque_add + drop + local.get 0 + i32.const 1038 + call 0 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store8 offset=42 + local.get 0 + i32.const 0 + i32.store8 offset=43 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=36 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store8 offset=34 + local.get 0 + i32.const 0 + i32.store8 offset=35 + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=48 + call $deque_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $deque_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 94 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 42 + i32.add + local.get 0 + i32.const 34 + i32.add + call $deque_zip_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 42 + i32.add + local.get 0 + i32.const 4 + i32.add + call $deque_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 34 + i32.add + local.get 0 + i32.const 4 + i32.add + call $deque_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 4 + i32.add + call $deque_index_of + drop + i32.const 3 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 42 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=48 + local.get 0 + i32.const 34 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 5 + i32.const 0 + i32.load offset=1044 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 4 + local.get 0 + i32.load offset=48 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=48 + call $deque_destroy + call $teardown_tests + local.get 0 + i32.const 112 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=40 + i32.load offset=4 + local.get 3 + i32.load offset=40 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=40 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=32 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=32 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=36 + call $deque_add_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.load offset=20 + br_if 1 (;@5;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@7;) + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 1 + i32.add + local.set 2 + br 1 (;@6;) + end + i32.const 0 + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=16 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @6 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=32 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 1 + i32.add + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load + local.get 3 + i32.load offset=32 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=28 + i32.load offset=8 + local.get 2 + i32.load offset=20 + i32.add + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + block ;; label = @3 + local.get 2 + i32.load offset=28 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=16) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $deque_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=16 + i32.and + i32.store + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=16 + local.get 3 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=40 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44) + (func $deque_zip_iter_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + i32.load + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + i32.load offset=4 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=8 + call $deque_add_at + drop + local.get 3 + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=8 + call $deque_add_at + drop + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00X\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterNext.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterNext.wat new file mode 100644 index 000000000..e074cf6b8 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterNext.wat @@ -0,0 +1,1593 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 70 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 62 + i32.add + call $deque_add + drop + local.get 0 + i32.const 32 + i32.add + call $deque_new + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.const 54 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.const 46 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.const 38 + i32.add + call $deque_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=32 + call $deque_zip_iter_init + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $deque_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + br_if 0 (;@3;) + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load offset=4 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 70 + i32.add + local.get 0 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.load offset=4 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + end + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 3 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=32 + call $deque_destroy + call $teardown_tests + local.get 0 + i32.const 96 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $deque_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=16 + i32.and + i32.store + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=16 + local.get 3 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=40 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterRemove.wat new file mode 100644 index 000000000..878921070 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterRemove.wat @@ -0,0 +1,2580 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + i32.load offset=48 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=48 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + local.get 0 + i32.load offset=40 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=40 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 70 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 62 + i32.add + call $deque_add + drop + local.get 0 + i32.const 32 + i32.add + call $deque_new + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.const 54 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.const 46 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=32 + local.get 0 + i32.const 38 + i32.add + call $deque_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=32 + call $deque_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $deque_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 78 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 4 + i32.add + local.get 0 + call $deque_zip_iter_remove + drop + end + br 0 (;@2;) + end + end + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.load offset=4 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 46 + i32.add + local.get 0 + i32.load + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 46 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + local.get 0 + i32.load offset=32 + call $deque_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=32 + call $deque_destroy + call $teardown_tests + local.get 0 + i32.const 96 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=36 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=36 + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_first + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + call $deque_remove_last + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.const 1 + i32.shr_u + i32.const 1 + i32.sub + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + block ;; label = @6 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @6 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@6;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=36 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.const 1 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.load + i32.store offset=4 + block ;; label = @5 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + block ;; label = @5 + local.get 3 + i32.load offset=16 + i32.eqz + br_if 0 (;@5;) + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.const 4 + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@3;) + end + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=40 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.sub + i32.const 2 + i32.shl + call $memmove + drop + end + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=12 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=32 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $deque_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=28 + i32.load offset=8 + local.get 2 + i32.load offset=20 + i32.add + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + block ;; label = @3 + local.get 2 + i32.load offset=28 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=16) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $deque_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $deque_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=16 + i32.and + i32.store + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=16 + local.get 3 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=40 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44) + (func $deque_zip_iter_remove (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=8 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load offset=4 + call $deque_remove_at + drop + local.get 3 + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 3 + i32.load + call $deque_remove_at + drop + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterReplace.wat b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterReplace.wat new file mode 100644 index 000000000..3d4fb1fd1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/deque/deque_test_zipIterReplace.wat @@ -0,0 +1,2071 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32 i32 i32) (result i32))) + (type (;8;) (func (param i32 i32 i32 i32 i32) (result i32))) + (func $setup_tests (type 3) + i32.const 0 + i32.const 1044 + call $deque_new + i32.store offset=1048) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1044 + call $deque_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 128 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=124 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=120 + local.get 0 + i32.load offset=120 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=120 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=112 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=112 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=104 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=96 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 118 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 110 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 102 + i32.add + call $deque_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 94 + i32.add + call $deque_add + drop + local.get 0 + i32.const 64 + i32.add + call $deque_new + drop + local.get 0 + i32.load offset=64 + local.get 0 + i32.const 86 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=64 + local.get 0 + i32.const 78 + i32.add + call $deque_add + drop + local.get 0 + i32.load offset=64 + local.get 0 + i32.const 70 + i32.add + call $deque_add + drop + local.get 0 + i32.const 1038 + call 0 + i32.store offset=60 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store8 offset=58 + local.get 0 + i32.const 0 + i32.store8 offset=59 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=52 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store8 offset=50 + local.get 0 + i32.const 0 + i32.store8 offset=51 + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=64 + call $deque_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + local.get 0 + i32.const 24 + i32.add + call $deque_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + local.get 0 + i32.const 110 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 58 + i32.add + local.get 0 + i32.const 50 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $deque_zip_iter_replace + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 58 + i32.add + local.get 0 + i32.const 12 + i32.add + call $deque_index_of + drop + i32.const 1 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 50 + i32.add + local.get 0 + i32.const 12 + i32.add + call $deque_index_of + drop + i32.const 1 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 58 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=64 + local.get 0 + i32.const 50 + i32.add + call $deque_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=64 + call $deque_destroy + call $teardown_tests + local.get 0 + i32.const 128 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $deque_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $deque_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $deque_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $deque_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_replace_at (type 7) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=24 + i32.load offset=8 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + block ;; label = @2 + local.get 4 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=24 + i32.load offset=16 + local.get 4 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + local.get 4 + i32.load offset=24 + i32.load offset=16 + local.get 4 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 4 + i32.load offset=20 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $deque_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + block ;; label = @4 + local.get 3 + i32.load offset=24 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $deque_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=28 + i32.load offset=8 + local.get 2 + i32.load offset=20 + i32.add + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=12 + block ;; label = @3 + local.get 2 + i32.load offset=28 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=16) + (func $deque_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $deque_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=16 + i32.and + i32.store + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=16 + local.get 3 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=40 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44) + (func $deque_zip_iter_replace (type 8) (param i32 i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 5 + global.set 0 + local.get 5 + local.get 0 + i32.store offset=24 + local.get 5 + local.get 1 + i32.store offset=20 + local.get 5 + local.get 2 + i32.store offset=16 + local.get 5 + local.get 3 + i32.store offset=12 + local.get 5 + local.get 4 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=24 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=24 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 5 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 5 + i32.load offset=24 + i32.load + local.get 5 + i32.load offset=20 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=12 + call $deque_replace_at + drop + local.get 5 + i32.load offset=24 + i32.load offset=4 + local.get 5 + i32.load offset=16 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 5 + i32.load offset=8 + call $deque_replace_at + drop + local.get 5 + i32.const 0 + i32.store offset=28 + end + local.get 5 + i32.load offset=28 + local.set 4 + local.get 5 + i32.const 32 + i32.add + global.set 0 + local.get 4) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00X\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_add.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_add.wat new file mode 100644 index 000000000..bc896e3e1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_add.wat @@ -0,0 +1,932 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1036 + call $list_new + drop + i32.const 1040 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1036 + call $list_destroy + i32.const 0 + i32.load offset=1040 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store8 offset=42 + local.get 0 + i32.const 0 + i32.store8 offset=43 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store8 offset=34 + local.get 0 + i32.const 0 + i32.store8 offset=35 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store8 offset=26 + local.get 0 + i32.const 0 + i32.store8 offset=27 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store8 offset=18 + local.get 0 + i32.const 0 + i32.store8 offset=19 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 42 + i32.add + call $list_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 34 + i32.add + call $list_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 26 + i32.add + call $list_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 18 + i32.add + call $list_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAll.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAll.wat new file mode 100644 index 000000000..d75f7c42c --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAll.wat @@ -0,0 +1,1707 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1044 + call $list_add_all + drop + i32.const 8 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_add_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $add_all_to_empty + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load + call $list_add_all_at + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $add_all_to_empty (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.const 16 + i32.add + local.get 2 + i32.const 12 + i32.add + call $link_all_externally + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=20 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add_all_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 12 + i32.add + local.get 3 + i32.const 8 + i32.add + call $link_all_externally + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=4 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + local.get 3 + i32.const 4 + i32.add + call $get_node_at + drop + local.get 3 + i32.const 0 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.load offset=8 + i32.store + br 1 (;@2;) + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.sub + local.get 3 + call $get_node_at + drop + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.store offset=4 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=8 + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=4 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.store offset=8 + end + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + local.get 3 + i32.load offset=20 + i32.load + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $link_all_externally (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.const 1 + i32.const 12 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@4;) + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@5;) + local.get 3 + local.get 3 + i32.load offset=20 + i32.load + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=20 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load + i32.store + br 0 (;@6;) + end + end + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=12 + i32.load + i32.store + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=16 + i32.load + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=16 + i32.load + i32.store offset=8 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.const 1 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAllAt.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAllAt.wat new file mode 100644 index 000000000..8de9b6374 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAllAt.wat @@ -0,0 +1,1658 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + i32.const 2 + call $list_add_all_at + drop + i32.const 4 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 8 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1044 + i32.const 4 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1048 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_add_all_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 12 + i32.add + local.get 3 + i32.const 8 + i32.add + call $link_all_externally + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=4 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + local.get 3 + i32.const 4 + i32.add + call $get_node_at + drop + local.get 3 + i32.const 0 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.load offset=8 + i32.store + br 1 (;@2;) + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.sub + local.get 3 + call $get_node_at + drop + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.store offset=4 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=8 + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=4 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.store offset=8 + end + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + local.get 3 + i32.load offset=20 + i32.load + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $link_all_externally (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.const 1 + i32.const 12 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@4;) + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@5;) + local.get 3 + local.get 3 + i32.load offset=20 + i32.load + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=20 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load + i32.store + br 0 (;@6;) + end + end + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=12 + i32.load + i32.store + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=16 + i32.load + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=16 + i32.load + i32.store offset=8 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.const 1 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAt.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAt.wat new file mode 100644 index 000000000..4cbea7606 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addAt.wat @@ -0,0 +1,1431 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $list_new + drop + i32.const 1052 + call $list_new + drop + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1052 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + i32.const 3 + call $list_add_at + drop + i32.const 5 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 3 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 1 + i32.const 12 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=4 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + call $link_behind + block ;; label = @2 + local.get 3 + i32.load offset=16 + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=4 + i32.store offset=4 + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $link_behind (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + end) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_addFirst.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addFirst.wat new file mode 100644 index 000000000..f962e7c42 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addFirst.wat @@ -0,0 +1,930 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1040 + call $list_new + drop + i32.const 1044 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $list_destroy + i32.const 0 + i32.load offset=1044 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + local.get 0 + i32.const 1032 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $list_add + drop + i32.const 4 + i32.const 0 + i32.load offset=1040 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $list_add_last + drop + i32.const 5 + i32.const 0 + i32.load offset=1040 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "p\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_addLast.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addLast.wat new file mode 100644 index 000000000..d51b29476 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_addLast.wat @@ -0,0 +1,895 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1040 + call $list_new + drop + i32.const 1044 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $list_destroy + i32.const 0 + i32.load offset=1044 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + local.get 0 + i32.const 1032 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 28 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $list_add + drop + i32.const 4 + i32.const 0 + i32.load offset=1040 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $list_add_last + drop + i32.const 5 + i32.const 0 + i32.load offset=1040 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "p\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_contains.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_contains.wat new file mode 100644 index 000000000..0f982140d --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_contains.wat @@ -0,0 +1,1014 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1040 + call $list_new + drop + i32.const 1044 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $list_destroy + i32.const 0 + i32.load offset=1044 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=8 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=8 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=8 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=8 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $list_add + drop + i32.const 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=28 + local.set 1 + local.get 0 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_copyDeep.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_copyDeep.wat new file mode 100644 index 000000000..e3b8c7c55 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_copyDeep.wat @@ -0,0 +1,1422 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $list_copy_deep + drop + i32.const 4 + local.get 0 + i32.load offset=12 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.const 1 + call $list_destroy_cb + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_copy_deep (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=16 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=20 + i32.store offset=24 + local.get 3 + local.get 3 + i32.const 16 + i32.add + local.get 3 + i32.const 12 + i32.add + call $list_new_conf + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.store offset=4 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load + local.get 3 + i32.load offset=36 + call_indirect (type 2) + call $list_add + i32.store offset=8 + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + call $list_destroy + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=44 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $copy (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + i32.load + i32.store + local.get 1 + i32.load offset=8 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $copy $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_copyShallow.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_copyShallow.wat new file mode 100644 index 000000000..262b0a371 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_copyShallow.wat @@ -0,0 +1,1389 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 24 + i32.add + call $list_copy_shallow + drop + i32.const 4 + local.get 0 + i32.load offset=24 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 20 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 16 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.load offset=28 + local.set 1 + local.get 0 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_copy_shallow (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=40 + local.get 2 + local.get 1 + i32.store offset=36 + local.get 2 + local.get 2 + i32.load offset=40 + i32.load offset=12 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=40 + i32.load offset=16 + i32.store offset=28 + local.get 2 + local.get 2 + i32.load offset=40 + i32.load offset=20 + i32.store offset=32 + local.get 2 + local.get 2 + i32.const 24 + i32.add + local.get 2 + i32.const 20 + i32.add + call $list_new_conf + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=44 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=40 + i32.load offset=4 + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=36 + local.get 2 + i32.load offset=20 + i32.store + local.get 2 + i32.const 0 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load + call $list_add + i32.store offset=16 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + call $list_destroy + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=44 + br 3 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 2 + i32.load offset=36 + local.get 2 + i32.load offset=20 + i32.store + local.get 2 + i32.const 0 + i32.store offset=44 + end + local.get 2 + i32.load offset=44 + local.set 1 + local.get 2 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_filter1.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_filter1.wat new file mode 100644 index 000000000..a8a35a7b1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_filter1.wat @@ -0,0 +1,1294 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $pred1 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $list_filter + drop + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + local.get 0 + i32.load offset=8 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=4 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 4 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 4 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + call 5 + call $teardown_test + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_filter (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $list_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 12 + i32.add + call $list_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 2) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load + call $list_add + drop + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $pred1 $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_filter2.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_filter2.wat new file mode 100644 index 000000000..9d004efab --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_filter2.wat @@ -0,0 +1,1410 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $pred2 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.gt_s + i32.const 1 + i32.and) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.const 3 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.const 3 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.const 3 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1064 + i32.const 3 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $list_filter + drop + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=8 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.const 0 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=4 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_filter (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $list_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 12 + i32.add + call $list_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 2) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load + call $list_add + drop + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $pred2 $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_getAt.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_getAt.wat new file mode 100644 index 000000000..b89468ec3 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_getAt.wat @@ -0,0 +1,1195 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 12 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_getLast.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_getLast.wat new file mode 100644 index 000000000..ae2c80004 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_getLast.wat @@ -0,0 +1,1041 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_indexOf.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_indexOf.wat new file mode 100644 index 000000000..fb201dc76 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_indexOf.wat @@ -0,0 +1,1010 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1036 + call $list_new + drop + i32.const 1040 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1036 + call $list_destroy + i32.const 0 + i32.load offset=1040 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=16 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=12 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $list_index_of + drop + i32.const 0 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $list_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=28 + local.set 1 + local.get 0 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_index_of (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + local.get 4 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 4 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 4 + i32.load offset=8 + i32.load + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=16 + call_indirect (type 0) + br_if 0 (;@4;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=4 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 8 + i32.store offset=28 + end + local.get 4 + i32.load offset=28 + local.set 3 + local.get 4 + i32.const 32 + i32.add + global.set 0 + local.get 3) + (func $zero_if_ptr_eq (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const -1 + i32.xor + i32.const 1 + i32.and) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $zero_if_ptr_eq $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterAdd.wat new file mode 100644 index 000000000..941b273f5 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterAdd.wat @@ -0,0 +1,1758 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $list_new + drop + i32.const 1052 + call $list_new + drop + i32.const 0 + i32.const 1042 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1052 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_tests + local.get 0 + i32.const 1026 + call 0 + i32.store offset=56 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=52 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=56 + i32.store + local.get 0 + i32.load offset=56 + i32.const 0 + i32.load offset=1068 + i32.ne + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + call $list_iter_init + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1068 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1068 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1068 + i32.const 0 + i32.load offset=1060 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + call $list_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.load offset=52 + call $list_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 5 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 3 + local.get 0 + i32.const 24 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=24 + i32.load + local.get 0 + i32.load offset=52 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 4 + local.get 0 + i32.const 20 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=20 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + call $list_iter_init + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=52 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=16 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + call $list_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + i32.load + i32.const 0 + i32.load offset=1068 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.load offset=52 + call $list_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=52 + i32.load + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_iter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12) + (func $list_iter_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + call $link_after + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $link_after (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + end) + (func $list_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "x\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterDescAdd.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterDescAdd.wat new file mode 100644 index 000000000..f3fb296ae --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterDescAdd.wat @@ -0,0 +1,1761 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $list_new + drop + i32.const 1052 + call $list_new + drop + i32.const 0 + i32.const 1042 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1052 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 4 + call $malloc + i32.store offset=40 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=36 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=28 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=32 + i32.store + local.get 0 + i32.load offset=36 + local.get 0 + i32.load offset=28 + i32.store + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1068 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1068 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1068 + i32.const 0 + i32.load offset=1060 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1048 + call $list_diter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $list_diter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + i32.const 0 + i32.load offset=1068 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.load offset=40 + call $list_diter_add + drop + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.load offset=36 + call $list_diter_add + drop + end + br 0 (;@2;) + end + end + i32.const 6 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + call $list_get_first + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + call $list_get_last + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 2 + local.get 0 + call $list_get_at + drop + local.get 0 + i32.load offset=36 + i32.load + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 4 + local.get 0 + call $list_get_at + drop + local.get 0 + i32.load offset=40 + i32.load + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=44 + local.set 1 + local.get 0 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $link_behind (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + end) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_diter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12) + (func $list_diter_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load + i32.store offset=4 + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + call $link_behind + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_diter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "y\00x\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterDescRemove.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterDescRemove.wat new file mode 100644 index 000000000..d5c662325 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterDescRemove.wat @@ -0,0 +1,1604 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1044 + call $list_diter_init + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1064 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1064 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + call $list_diter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 0 + i32.load offset=20 + i32.load + i32.const 0 + i32.load offset=1052 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@4;) + local.get 0 + i32.load offset=20 + i32.load + i32.const 0 + i32.load offset=1060 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + end + local.get 0 + i32.const 24 + i32.add + i32.const 0 + call $list_diter_remove + drop + local.get 0 + i32.load offset=20 + call 5 + end + br 0 (;@2;) + end + end + i32.const 2 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 16 + i32.add + call $list_get_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=16 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=44 + local.set 1 + local.get 0 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_diter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12) + (func $list_diter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call $unlinkn + i32.store + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_diter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterRemove.wat new file mode 100644 index 000000000..4ff94d304 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_iterRemove.wat @@ -0,0 +1,1525 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1052 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1064 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 24 + i32.add + call $list_get_at + drop + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1044 + call $list_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $list_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + i32.const 0 + i32.load offset=1060 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 8 + i32.add + i32.const 0 + call $list_iter_remove + drop + end + br 0 (;@2;) + end + end + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=24 + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=24 + call 5 + call $teardown_test + local.get 0 + i32.load offset=28 + local.set 1 + local.get 0 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_iter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12) + (func $list_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call $unlinkn + i32.store + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_mutFilter1.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_mutFilter1.wat new file mode 100644 index 000000000..60891a280 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_mutFilter1.wat @@ -0,0 +1,1260 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32))) + (func $pred1 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + call $list_filter_mut + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $list_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 2) + br_if 0 (;@4;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $pred1 $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_mutFilter2.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_mutFilter2.wat new file mode 100644 index 000000000..c8941f6b1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_mutFilter2.wat @@ -0,0 +1,1380 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $pred2 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.gt_s + i32.const 1 + i32.and) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.const 3 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.const 3 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.const 3 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1064 + i32.const 3 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + call $list_filter_mut + drop + i32.const 1 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $list_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 2) + br_if 0 (;@4;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $pred2 $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_new.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_new.wat new file mode 100644 index 000000000..840afc807 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_new.wat @@ -0,0 +1,756 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1028 + call $list_new + drop + i32.const 1032 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1028 + call $list_destroy + i32.const 0 + i32.load offset=1032 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1028 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1032 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1028 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=12 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1028 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + local.get 0 + i32.load offset=12 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1028 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1028 + i32.const 0 + i32.load offset=1032 + i32.ne + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1024 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1024 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1024 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1024 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1024 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1024 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1024 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1024 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_remove.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_remove.wat new file mode 100644 index 000000000..d4aec2e21 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_remove.wat @@ -0,0 +1,1457 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1056 + i32.const 0 + i32.load offset=1052 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1056 + i32.const 0 + i32.load offset=1064 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + i32.const 0 + call $list_remove + drop + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + call 5 + call $teardown_test + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_remove (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $get_node + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.load + i32.store + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + call $unlinkn + drop + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $get_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load + i32.load + local.get 2 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 3 (;@1;) + end + local.get 2 + local.get 2 + i32.load + i32.load offset=4 + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeAll.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeAll.wat new file mode 100644 index 000000000..ff61bcbba --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeAll.wat @@ -0,0 +1,1082 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_remove_all_cb + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=12 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeAt.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeAt.wat new file mode 100644 index 000000000..b3159fd29 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeAt.wat @@ -0,0 +1,1325 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $list_remove_at + drop + local.get 0 + i32.load offset=12 + call 5 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 12 + i32.add + call $list_remove_at + drop + local.get 0 + i32.load offset=12 + call 5 + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 12 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_remove_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.load + i32.store + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + call $unlinkn + drop + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeFirst.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeFirst.wat new file mode 100644 index 000000000..132e492ab --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeFirst.wat @@ -0,0 +1,1129 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_remove_first + drop + local.get 0 + i32.load offset=12 + call 5 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $unlinkn + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeLast.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeLast.wat new file mode 100644 index 000000000..b0af84e7d --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_removeLast.wat @@ -0,0 +1,1133 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_remove_last + drop + local.get 0 + i32.load offset=12 + call 5 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1060 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call $unlinkn + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_replaceAt.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_replaceAt.wat new file mode 100644 index 000000000..a96885ee8 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_replaceAt.wat @@ -0,0 +1,1288 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $list_new + drop + i32.const 1052 + call $list_new + drop + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1052 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $list_replace_at + drop + local.get 0 + i32.load offset=4 + call 5 + i32.const 0 + i32.load offset=1048 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_replace_at (type 7) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=28 + local.get 4 + local.get 1 + i32.store offset=24 + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + local.get 3 + i32.store offset=16 + local.get 4 + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=20 + local.get 4 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=8 + block ;; label = @1 + local.get 4 + i32.load offset=8 + br_if 0 (;@1;) + local.get 4 + local.get 4 + i32.load offset=12 + i32.load + i32.store offset=4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=24 + i32.store + block ;; label = @2 + local.get 4 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=4 + i32.store + end + end + local.get 4 + i32.load offset=8 + local.set 3 + local.get 4 + i32.const 32 + i32.add + global.set 0 + local.get 3) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "r\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_reverse.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_reverse.wat new file mode 100644 index 000000000..cc7137dd0 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_reverse.wat @@ -0,0 +1,1717 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1044 + call $list_reverse + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $list_get_first + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_reverse (type 1) (param i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=28 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=28 + i32.load + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=28 + i32.load offset=4 + i32.store offset=24 + local.get 1 + local.get 1 + i32.load offset=28 + i32.load offset=8 + i32.store offset=20 + local.get 1 + local.get 1 + i32.load offset=28 + i32.load offset=4 + i32.store offset=16 + local.get 1 + local.get 1 + i32.load offset=28 + i32.load offset=8 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=28 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 1 + local.get 1 + i32.load offset=16 + i32.load offset=4 + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=12 + i32.load offset=8 + i32.store + local.get 1 + i32.load offset=16 + local.get 1 + i32.load offset=12 + call $swap + local.get 1 + local.get 1 + i32.load offset=4 + i32.store offset=16 + local.get 1 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 1 + i32.load offset=28 + local.get 1 + i32.load offset=20 + i32.store offset=4 + local.get 1 + i32.load offset=28 + local.get 1 + i32.load offset=24 + i32.store offset=8 + end + local.get 1 + i32.const 32 + i32.add + global.set 0) + (func $swap (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=28 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + i32.load offset=24 + i32.load offset=4 + local.get 2 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + call $swap_adjacent + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=28 + i32.load offset=8 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=24 + i32.store offset=4 + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=20 + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.store offset=8 + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=4 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=28 + i32.store offset=4 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=12 + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=28 + i32.store offset=8 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=8 + i32.store offset=4 + end + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $swap_adjacent (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=12 + i32.store offset=8 + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=12 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.store offset=4 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=4 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=4 + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + end) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_sort.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_sort.wat new file mode 100644 index 000000000..c1bc94755 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_sort.wat @@ -0,0 +1,1368 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32))) + (type (;6;) (func (param i32 i32))) + (func $setup_tests (type 2) + i32.const 1036 + call $list_new + drop + i32.const 1040 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1036 + call $list_destroy + i32.const 0 + i32.load offset=1040 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1030 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=28 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 40 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 36 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 32 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 28 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1036 + i32.const 1 + call $list_sort + drop + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1036 + call $list_iter_init + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $list_iter_next + drop + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + call $list_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load + i32.load + i32.le_s + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load + i32.store offset=4 + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.load offset=44 + local.set 1 + local.get 0 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $qsort (type 5) (param i32 i32 i32 i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 3 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=16 + local.get 4 + local.get 4 + i32.load offset=16 + i32.store offset=12 + local.get 4 + i32.const 0 + i32.store offset=28 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=40 + i32.const 1 + i32.sub + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + local.get 4 + i32.load offset=28 + i32.store offset=20 + local.get 4 + local.get 4 + i32.load offset=28 + i32.const 1 + i32.add + i32.store offset=24 + block ;; label = @3 + loop ;; label = @4 + local.get 4 + i32.load offset=24 + local.get 4 + i32.load offset=40 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + block ;; label = @5 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=24 + local.get 4 + i32.load offset=36 + i32.mul + i32.add + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=36 + i32.mul + i32.add + local.get 4 + i32.load offset=32 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 4 + local.get 4 + i32.load offset=24 + i32.store offset=20 + end + local.get 4 + local.get 4 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + br 0 (;@4;) + end + end + local.get 4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=36 + i32.mul + i32.add + i32.store offset=8 + local.get 4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=36 + i32.mul + i32.add + i32.store offset=4 + local.get 4 + local.get 4 + i32.load offset=8 + i32.load + i32.store + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=4 + i32.load + i32.store + local.get 4 + i32.load offset=4 + local.get 4 + i32.load + i32.store + local.get 4 + local.get 4 + i32.load offset=28 + i32.const 1 + i32.add + i32.store offset=28 + br 0 (;@2;) + end + end + local.get 4 + i32.const 48 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_to_array (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 3 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 4 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 2 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=12 + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_sort (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 16 + i32.add + call $list_to_array + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.const 4 + local.get 2 + i32.load offset=20 + call $qsort + local.get 2 + i32.const 0 + i32.store offset=4 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@3;) + end + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_iter_init (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12) + (func $list_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_splice.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_splice.wat new file mode 100644 index 000000000..d31f8b929 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_splice.wat @@ -0,0 +1,1633 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $list_splice + drop + i32.const 8 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1080 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 4 + local.get 0 + i32.const 12 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_splice (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + call $list_splice_at + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_splice_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.load + i32.store + local.get 3 + i32.load offset=20 + i32.const 0 + i32.store offset=4 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + local.get 3 + i32.const 12 + i32.add + call $get_node_at + drop + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.sub + local.get 3 + i32.const 8 + i32.add + call $get_node_at + drop + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + call $splice_between + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $splice_between (type 7) (param i32 i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=12 + local.get 4 + local.get 1 + i32.store offset=8 + local.get 4 + local.get 2 + i32.store offset=4 + local.get 4 + local.get 3 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + i32.load offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=8 + local.get 4 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 4 + i32.load offset=12 + i32.load offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + local.get 4 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + local.get 4 + i32.load offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + local.get 4 + i32.load offset=4 + i32.store offset=8 + local.get 4 + i32.load + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=8 + local.get 4 + i32.load + i32.store offset=4 + end + end + local.get 4 + i32.load offset=12 + local.tee 3 + local.get 3 + i32.load + local.get 4 + i32.load offset=8 + i32.load + i32.add + i32.store + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_spliceAt.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_spliceAt.wat new file mode 100644 index 000000000..d977d4613 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_spliceAt.wat @@ -0,0 +1,1607 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + i32.const 2 + call $list_splice_at + drop + i32.const 8 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_first + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $list_get_last + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_splice_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.load + i32.store + local.get 3 + i32.load offset=20 + i32.const 0 + i32.store offset=4 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + local.get 3 + i32.const 12 + i32.add + call $get_node_at + drop + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.sub + local.get 3 + i32.const 8 + i32.add + call $get_node_at + drop + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + call $splice_between + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $splice_between (type 7) (param i32 i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=12 + local.get 4 + local.get 1 + i32.store offset=8 + local.get 4 + local.get 2 + i32.store offset=4 + local.get 4 + local.get 3 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + i32.load offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=8 + local.get 4 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 4 + i32.load offset=12 + i32.load offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + local.get 4 + i32.load offset=12 + i32.load offset=8 + i32.store offset=8 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + local.get 4 + i32.load offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + local.get 4 + i32.load offset=4 + i32.store offset=8 + local.get 4 + i32.load + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=8 + local.get 4 + i32.load + i32.store offset=4 + end + end + local.get 4 + i32.load offset=12 + local.tee 3 + local.get 3 + i32.load + local.get 4 + i32.load offset=8 + i32.load + i32.add + i32.store + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_sublist.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_sublist.wat new file mode 100644 index 000000000..db46acfdd --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_sublist.wat @@ -0,0 +1,1412 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + call $setup_tests + i32.const 0 + i32.load offset=1044 + i32.const 1 + i32.const 2 + local.get 0 + i32.const 12 + i32.add + call $list_sublist + drop + i32.const 2 + local.get 0 + i32.load offset=12 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $list_get_at + drop + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + call $list_destroy + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_sublist (type 7) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=40 + local.get 4 + local.get 1 + i32.store offset=36 + local.get 4 + local.get 2 + i32.store offset=32 + local.get 4 + local.get 3 + i32.store offset=28 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load offset=36 + local.get 4 + i32.load offset=32 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 4 + i32.const 3 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=40 + i32.load offset=12 + i32.store offset=16 + local.get 4 + local.get 4 + i32.load offset=40 + i32.load offset=16 + i32.store offset=20 + local.get 4 + local.get 4 + i32.load offset=40 + i32.load offset=20 + i32.store offset=24 + local.get 4 + local.get 4 + i32.const 16 + i32.add + local.get 4 + i32.const 12 + i32.add + call $list_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 4 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 4 + local.get 4 + i32.load offset=8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=40 + local.get 4 + i32.load offset=36 + local.get 4 + i32.const 4 + i32.add + call $get_node_at + i32.store offset=8 + block ;; label = @2 + local.get 4 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=40 + i32.load offset=20 + call_indirect (type 1) + local.get 4 + local.get 4 + i32.load offset=8 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=36 + i32.store + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load + local.get 4 + i32.load offset=32 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=4 + i32.load + call $list_add + i32.store offset=8 + block ;; label = @4 + local.get 4 + i32.load offset=8 + i32.eqz + br_if 0 (;@4;) + local.get 4 + i32.load offset=12 + call $list_destroy + local.get 4 + local.get 4 + i32.load offset=8 + i32.store offset=44 + br 3 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + local.get 4 + local.get 4 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=12 + i32.store + local.get 4 + i32.const 0 + i32.store offset=44 + end + local.get 4 + i32.load offset=44 + local.set 3 + local.get 4 + i32.const 48 + i32.add + global.set 0 + local.get 3) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_toArray.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_toArray.wat new file mode 100644 index 000000000..384391750 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_toArray.wat @@ -0,0 +1,1348 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $list_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $list_destroy_cb + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_tests + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $list_to_array + drop + local.get 0 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load + i32.const 4 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + local.get 0 + i32.const 4 + i32.add + call $list_get_at + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + local.get 0 + i32.load offset=8 + call 5 + call $teardown_test + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.shr_u + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@4;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@5;) + end + end + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.store offset=12 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const -1 + i32.add + i32.store offset=12 + br 0 (;@4;) + end + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=24 + local.get 3 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @1 + local.get 3 + i32.load offset=12 + br_if 0 (;@1;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=16 + i32.load + i32.store + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $list_to_array (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 3 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 4 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 2 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=12 + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterAdd.wat new file mode 100644 index 000000000..0358c1875 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterAdd.wat @@ -0,0 +1,2337 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (type (;7;) (func (param i32 i32 i32))) + (type (;8;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1052 + call $list_new + drop + i32.const 1056 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1052 + call $list_destroy + i32.const 0 + i32.load offset=1056 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 144 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=140 + call $setup_tests + local.get 0 + i32.const 1044 + call 0 + i32.store offset=136 + local.get 0 + i32.load offset=136 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=136 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=136 + i32.store8 offset=134 + local.get 0 + i32.const 0 + i32.store8 offset=135 + local.get 0 + i32.const 1042 + call 0 + i32.store offset=128 + local.get 0 + i32.load offset=128 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=128 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=128 + i32.store8 offset=126 + local.get 0 + i32.const 0 + i32.store8 offset=127 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=120 + local.get 0 + i32.load offset=120 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=120 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=112 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=112 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=136 + local.get 0 + i32.load offset=128 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=136 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=136 + local.get 0 + i32.load offset=112 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=136 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=136 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=112 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=112 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=96 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=56 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 134 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 126 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 118 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 110 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 102 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 94 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 86 + i32.add + call $list_add + drop + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1056 + call $list_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $list_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 126 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.const 70 + i32.add + call $list_zip_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 78 + i32.add + i32.const 1 + local.get 0 + i32.const 12 + i32.add + call $list_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 70 + i32.add + i32.const 1 + local.get 0 + i32.const 12 + i32.add + call $list_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 118 + i32.add + i32.const 1 + local.get 0 + i32.const 12 + i32.add + call $list_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 78 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 70 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 5 + i32.const 0 + i32.load offset=1052 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 4 + i32.const 0 + i32.load offset=1056 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1056 + call $list_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $list_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=16 + local.get 0 + i32.const 86 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.const 54 + i32.add + call $list_zip_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.const 110 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 8 + i32.add + call $list_get_last + drop + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + call $teardown_test + local.get 0 + i32.load offset=140 + local.set 1 + local.get 0 + i32.const 144 + i32.add + global.set 0 + local.get 1) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1048 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1048 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1048 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1048 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $list_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $list_index_of (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + local.get 4 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 4 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 4 + i32.load offset=8 + i32.load + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=16 + call_indirect (type 0) + br_if 0 (;@4;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=4 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 8 + i32.store offset=28 + end + local.get 4 + i32.load offset=28 + local.set 3 + local.get 4 + i32.const 32 + i32.add + global.set 0 + local.get 3) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $link_after (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + end) + (func $list_zip_iter_init (type 7) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=20) + (func $list_zip_iter_next (type 8) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_zip_iter_add (type 8) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 1 + i32.const 12 + local.get 3 + i32.load offset=24 + i32.load + i32.load offset=16 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 1 + i32.const 12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=12 + call $link_after + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=8 + call $link_after + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=8 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.store offset=8 + end + local.get 3 + i32.load offset=24 + i32.load + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $CHECK_EQUAL_C_STRING (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $zero_if_ptr_eq (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const -1 + i32.xor + i32.const 1 + i32.and) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66608)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $zero_if_ptr_eq $malloc $calloc $free) + (data (;0;) (i32.const 1024) "y\00x\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1048) "0\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterNext.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterNext.wat new file mode 100644 index 000000000..6ae57ab26 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterNext.wat @@ -0,0 +1,1237 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_tests (type 2) + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $list_destroy + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 112 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=108 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 102 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 94 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 70 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 54 + i32.add + call $list_add + drop + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $list_zip_iter_init + local.get 0 + i32.const 0 + i32.store offset=20 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + call $list_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=20 + br_if 0 (;@3;) + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.load offset=16 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 70 + i32.add + local.get 0 + i32.load offset=12 + call $CHECK_EQUAL_C_STRING + end + block ;; label = @3 + local.get 0 + i32.load offset=20 + i32.const 2 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.load offset=16 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load offset=12 + call $CHECK_EQUAL_C_STRING + end + local.get 0 + local.get 0 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + br 0 (;@2;) + end + end + i32.const 3 + local.get 0 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=108 + local.set 1 + local.get 0 + i32.const 112 + i32.add + global.set 0 + local.get 1) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_zip_iter_init (type 5) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=20) + (func $list_zip_iter_next (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $CHECK_EQUAL_C_STRING (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterRemove.wat new file mode 100644 index 000000000..89ebbf04b --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterRemove.wat @@ -0,0 +1,1766 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_tests (type 2) + i32.const 1044 + call $list_new + drop + i32.const 1048 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $list_destroy + i32.const 0 + i32.load offset=1048 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 112 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=108 + call $setup_tests + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=96 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=64 + local.get 0 + i32.load offset=56 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 102 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 94 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 70 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 54 + i32.add + call $list_add + drop + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $list_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $list_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 94 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $list_zip_iter_remove + drop + end + br 0 (;@2;) + end + end + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.load offset=12 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 94 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + i32.const 0 + i32.load offset=1048 + call $list_size + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=108 + local.set 1 + local.get 0 + i32.const 112 + i32.add + global.set 0 + local.get 1) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $list_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $list_zip_iter_init (type 5) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=20) + (func $list_zip_iter_next (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_zip_iter_remove (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=8 + call $unlinkn + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.get 3 + i32.load offset=24 + i32.load offset=12 + call $unlinkn + i32.store offset=8 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $CHECK_EQUAL_C_STRING (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterReplace.wat b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterReplace.wat new file mode 100644 index 000000000..e58fcefd5 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/list/list_test_zipIterReplace.wat @@ -0,0 +1,1847 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32 i32) (result i32))) + (type (;8;) (func (param i32 i32 i32 i32 i32) (result i32))) + (func $setup_tests (type 2) + i32.const 1048 + call $list_new + drop + i32.const 1052 + call $list_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $list_destroy + i32.const 0 + i32.load offset=1052 + call $list_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 128 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=124 + call $setup_tests + local.get 0 + i32.const 1040 + call 0 + i32.store offset=120 + local.get 0 + i32.load offset=120 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=120 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=112 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=112 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=112 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=104 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=96 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=104 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=96 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=112 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=96 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=64 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=64 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=80 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=72 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=56 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=56 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 118 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 110 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 102 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 94 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 86 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 78 + i32.add + call $list_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 70 + i32.add + call $list_add + drop + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1052 + call $list_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $list_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=20 + local.get 0 + i32.const 110 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $list_zip_iter_replace + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $list_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 54 + i32.add + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $list_index_of + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 54 + i32.add + call $list_contains + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.load offset=124 + local.set 1 + local.get 0 + i32.const 128 + i32.add + global.set 0 + local.get 1) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $list_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $list_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $list_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $list_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.load offset=12 + call $list_remove_all + drop + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $list_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $unlinkn + drop + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $list_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $list_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + block ;; label = @1 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.load offset=12 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $list_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $list_index_of (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + local.get 4 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 4 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 4 + i32.load offset=8 + i32.load + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=16 + call_indirect (type 0) + br_if 0 (;@4;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=4 + i32.store + local.get 4 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 8 + i32.store offset=28 + end + local.get 4 + i32.load offset=28 + local.set 3 + local.get 4 + i32.const 32 + i32.add + global.set 0 + local.get 3) + (func $list_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=20) + (func $list_zip_iter_next (type 7) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=8 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $list_zip_iter_replace (type 8) (param i32 i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 5 + local.get 0 + i32.store offset=24 + local.get 5 + local.get 1 + i32.store offset=20 + local.get 5 + local.get 2 + i32.store offset=16 + local.get 5 + local.get 3 + i32.store offset=12 + local.get 5 + local.get 4 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 5 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 5 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + local.get 5 + local.get 5 + i32.load offset=24 + i32.load offset=8 + i32.load + i32.store offset=4 + local.get 5 + local.get 5 + i32.load offset=24 + i32.load offset=12 + i32.load + i32.store + local.get 5 + i32.load offset=24 + i32.load offset=8 + local.get 5 + i32.load offset=20 + i32.store + local.get 5 + i32.load offset=24 + i32.load offset=12 + local.get 5 + i32.load offset=16 + i32.store + block ;; label = @2 + local.get 5 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 5 + i32.load offset=12 + local.get 5 + i32.load offset=4 + i32.store + end + block ;; label = @2 + local.get 5 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 5 + i32.load offset=8 + local.get 5 + i32.load + i32.store + end + local.get 5 + i32.const 0 + i32.store offset=28 + end + local.get 5 + i32.load offset=28) + (func $zero_if_ptr_eq (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const -1 + i32.xor + i32.const 1 + i32.and) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $zero_if_ptr_eq $malloc $calloc $free) + (data (;0;) (i32.const 1024) "i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/pqueue/pqueue_test_enqueue.wat b/benchmarks/pldi2026/Collection-C-normal/pqueue/pqueue_test_enqueue.wat new file mode 100644 index 000000000..af25cc89c --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/pqueue/pqueue_test_enqueue.wat @@ -0,0 +1,1440 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + i32.const 1040 + i32.const 1 + call $pqueue_new + drop + local.get 0 + i32.const 8 + i32.add + i32.const 2 + call $pqueue_conf_init + local.get 0 + i32.const 8 + i32.add + i32.const 1044 + call $pqueue_new_conf + drop + local.get 0 + i32.const 32 + i32.add + global.set 0) + (func $comp2 (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.sub) + (func $comp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.sub + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.sub + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1040 + call $pqueue_destroy + i32.const 0 + i32.load offset=1044 + call $pqueue_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1034 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=24 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=24 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=20 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=20 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $pqueue_push + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $pqueue_top + drop + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $pqueue_push + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $pqueue_top + drop + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + i32.const 1 + local.set 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=16 + i32.load + i32.eq + i32.const 1 + i32.and + br_if 1 (;@1;) + end + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=20 + i32.le_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=16 + i32.load + i32.eq + local.set 1 + end + end + local.get 1 + i32.const 1 + i32.and + call 2 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=40 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=40 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=36 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=36 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=32 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=32 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=28 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=28 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.get 0 + i32.load offset=40 + i32.store offset=1048 + i32.const 0 + local.get 0 + i32.load offset=36 + i32.store offset=1052 + i32.const 0 + local.get 0 + i32.load offset=32 + i32.store offset=1056 + i32.const 0 + local.get 0 + i32.load offset=28 + i32.store offset=1060 + i32.const 0 + i32.load offset=1044 + i32.const 1048 + call $pqueue_push + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $pqueue_top + drop + i32.const 1048 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1056 + call $pqueue_push + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 12 + i32.add + call $pqueue_top + drop + block ;; label = @1 + block ;; label = @2 + i32.const 1048 + i32.const 1056 + call $comp + i32.const 0 + i32.ge_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + i32.const 1 + local.set 1 + local.get 0 + i32.load offset=36 + local.get 0 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + br_if 1 (;@1;) + end + i32.const 0 + local.set 1 + block ;; label = @2 + i32.const 1048 + i32.const 1056 + call $comp + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.load offset=28 + local.get 0 + i32.load offset=12 + i32.load offset=4 + i32.eq + local.set 1 + end + end + end + local.get 1 + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $pqueue_conf_init (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 3 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 4 + i32.store offset=16 + local.get 2 + i32.load offset=12 + i32.const 5 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 8 + i32.store) + (func $pqueue_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + call $pqueue_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + call $pqueue_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $pqueue_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=24 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=28 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $pqueue_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $pqueue_push (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + call $expand_capacity + i32.store offset=12 + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=28 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=20 + i32.store + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=16 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load offset=28 + call_indirect (type 0) + i32.const 0 + i32.gt_s + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + br 1 (;@2;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $pqueue_top (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 6 6 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66608)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $comp2 $comp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) "0\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/pqueue/pqueue_test_pop.wat b/benchmarks/pldi2026/Collection-C-normal/pqueue/pqueue_test_pop.wat new file mode 100644 index 000000000..d5b868e28 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/pqueue/pqueue_test_pop.wat @@ -0,0 +1,1663 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (func $setup_tests (type 3) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + i32.const 1 + call $pqueue_new + drop + local.get 0 + i32.const 8 + i32.add + i32.const 2 + call $pqueue_conf_init + local.get 0 + i32.const 8 + i32.add + i32.const 1052 + call $pqueue_new_conf + drop + local.get 0 + i32.const 32 + i32.add + global.set 0) + (func $comp2 (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.sub) + (func $comp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.sub + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.sub + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1048 + call $pqueue_destroy + i32.const 0 + i32.load offset=1052 + call $pqueue_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_tests + local.get 0 + i32.const 1040 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=16 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=16 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=12 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=12 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=8 + i32.const 8388608 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=8 + i32.const -8388608 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=8 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=12 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 12 + i32.add + call $pqueue_push + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 16 + i32.add + call $pqueue_push + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 8 + i32.add + call $pqueue_push + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 4 + i32.add + call $pqueue_pop + drop + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 4 + i32.add + call $pqueue_pop + drop + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 4 + i32.add + call $pqueue_pop + drop + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + local.get 0 + i32.load offset=40 + i32.store offset=1056 + i32.const 0 + local.get 0 + i32.load offset=36 + i32.store offset=1060 + i32.const 0 + local.get 0 + i32.load offset=32 + i32.store offset=1064 + i32.const 0 + local.get 0 + i32.load offset=28 + i32.store offset=1068 + i32.const 0 + local.get 0 + i32.load offset=24 + i32.store offset=1072 + i32.const 0 + local.get 0 + i32.load offset=20 + i32.store offset=1076 + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 1072 + i32.const 1056 + call $comp + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 1056 + i32.const 1064 + call $comp + i32.const 0 + i32.gt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1052 + i32.const 1056 + call $pqueue_push + drop + i32.const 0 + i32.load offset=1052 + i32.const 1064 + call $pqueue_push + drop + i32.const 0 + i32.load offset=1052 + i32.const 1072 + call $pqueue_push + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + call $pqueue_pop + drop + i32.const 1072 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + local.get 0 + call $pqueue_pop + drop + i32.const 1056 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + local.get 0 + call $pqueue_pop + drop + i32.const 1064 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $pqueue_conf_init (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 3 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 4 + i32.store offset=16 + local.get 2 + i32.load offset=12 + i32.const 5 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 8 + i32.store) + (func $pqueue_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + call $pqueue_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + call $pqueue_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $pqueue_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=24 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=28 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $pqueue_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $pqueue_push (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + call $expand_capacity + i32.store offset=12 + block ;; label = @3 + local.get 2 + i32.load offset=12 + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=28 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=20 + i32.store + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=16 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load offset=28 + call_indirect (type 0) + i32.const 0 + i32.gt_s + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.const 1 + i32.sub + i32.const 1 + i32.shr_u + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=4 + br 1 (;@2;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $pqueue_pop (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load + i32.store + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 1 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.load offset=8 + i32.const 0 + call $pqueue_heapify + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $pqueue_heapify (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=44 + local.get 2 + local.get 1 + i32.store offset=40 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=44 + i32.load + i32.const 1 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=40 + i32.const 1 + i32.shl + i32.const 1 + i32.add + i32.store offset=36 + local.get 2 + local.get 2 + i32.load offset=40 + i32.const 1 + i32.shl + i32.const 2 + i32.add + i32.store offset=32 + local.get 2 + local.get 2 + i32.load offset=40 + i32.store offset=28 + local.get 2 + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=36 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=32 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=40 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=16 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=36 + local.get 2 + i32.load offset=44 + i32.load + i32.ge_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + i32.load offset=32 + local.get 2 + i32.load offset=44 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=44 + i32.load offset=28 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=36 + i32.store offset=40 + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=44 + i32.load offset=28 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=20 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=32 + i32.store offset=40 + end + local.get 2 + i32.load offset=40 + local.get 2 + i32.load offset=28 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=28 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=40 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=44 + i32.load offset=12 + local.get 2 + i32.load offset=40 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=44 + local.get 2 + i32.load offset=40 + call $pqueue_heapify + end + local.get 2 + i32.const 48 + i32.add + global.set 0) + (func $assume (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 6 6 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $comp2 $comp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_enqueue.wat b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_enqueue.wat new file mode 100644 index 000000000..3b74f3b39 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_enqueue.wat @@ -0,0 +1,1325 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_test (type 3) + i32.const 1036 + call $queue_new + drop + i32.const 1040 + call $queue_new + drop) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1036 + call $queue_destroy + i32.const 0 + i32.load offset=1040 + call $queue_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $queue_enqueue + drop + i32.const 2 + i32.const 0 + i32.load offset=1036 + call $queue_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $queue_peek + drop + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $queue_peek + drop + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $deque_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $queue_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $deque_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $queue_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $queue_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $queue_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $deque_new_conf + drop + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=12 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $queue_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $deque_destroy + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_peek (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_get_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $queue_enqueue (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_add_first + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $queue_size (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $deque_size + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_iter.wat b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_iter.wat new file mode 100644 index 000000000..f65b57db5 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_iter.wat @@ -0,0 +1,1466 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_test (type 3) + i32.const 1036 + call $queue_new + drop + i32.const 1040 + call $queue_new + drop) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1036 + call $queue_destroy + i32.const 0 + i32.load offset=1040 + call $queue_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_test + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 40 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 36 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 32 + i32.add + call $queue_enqueue + drop + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i32.const 0 + i32.store offset=20 + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1036 + call $queue_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $queue_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 0 + i32.const 40 + i32.add + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=28 + i32.const 1 + i32.add + i32.store offset=28 + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 0 + i32.const 36 + i32.add + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=24 + i32.const 1 + i32.add + i32.store offset=24 + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 0 + i32.const 32 + i32.add + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=20 + i32.const 1 + i32.add + i32.store offset=20 + end + br 0 (;@2;) + end + end + i32.const 1 + local.get 0 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=8) + (func $deque_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=12 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + i32.load offset=24 + i32.load offset=4 + local.get 2 + i32.load offset=24 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.add + local.get 2 + i32.load offset=16 + i32.and + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.load offset=24 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=24 + i32.load + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $queue_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $deque_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $queue_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $queue_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $queue_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $deque_new_conf + drop + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=12 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $queue_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $deque_destroy + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_enqueue (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_add_first + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $queue_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + call $deque_iter_init + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $queue_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $deque_iter_next + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_poll.wat b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_poll.wat new file mode 100644 index 000000000..174705585 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_poll.wat @@ -0,0 +1,1423 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_test (type 3) + i32.const 1036 + call $queue_new + drop + i32.const 1040 + call $queue_new + drop) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1036 + call $queue_destroy + i32.const 0 + i32.load offset=1040 + call $queue_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $queue_poll + drop + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $queue_peek + drop + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $queue_poll + drop + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $queue_peek + drop + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $deque_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $queue_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $deque_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $queue_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $queue_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $queue_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $deque_new_conf + drop + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=12 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $queue_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $deque_destroy + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_peek (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_get_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $queue_poll (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_remove_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $queue_enqueue (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_add_first + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_zipIterNext.wat b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_zipIterNext.wat new file mode 100644 index 000000000..7439bf9e6 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/queue/queue_test_zipIterNext.wat @@ -0,0 +1,1751 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_test (type 3) + i32.const 1044 + call $queue_new + drop + i32.const 1048 + call $queue_new + drop) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $queue_destroy + i32.const 0 + i32.load offset=1048 + call $queue_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + call $setup_test + local.get 0 + i32.const 1036 + call 0 + i32.store offset=88 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=80 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 70 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 62 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 54 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 46 + i32.add + call $queue_enqueue + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 38 + i32.add + call $queue_enqueue + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $queue_zip_iter_init + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $queue_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + br_if 0 (;@3;) + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 38 + i32.add + local.get 0 + i32.load offset=4 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load offset=4 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + end + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 3 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 96 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $deque_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $deque_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 1) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load offset=8 + i32.load + call $upper_pow_two + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $upper_pow_two (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.const -2147483648 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const -2147483648 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 1 + i32.load offset=8 + br_if 0 (;@2;) + local.get 1 + i32.const 2 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 2 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 4 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.store offset=12 + end + local.get 1 + i32.load offset=12) + (func $deque_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const -2147483648 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.shl + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 4 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 0) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.const 0 + call $copy_buffer + local.get 1 + i32.load offset=8 + i32.load offset=16 + local.get 1 + i32.load offset=8 + i32.load offset=28 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=16 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $deque_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $copy_buffer (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=28 + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.gt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + br 1 (;@3;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=12 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.sub + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=28 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + call $memcpy + drop + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=16 + i32.const 2 + i32.shl + call $memcpy + drop + end + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.const 1 + i32.sub + i32.and + i32.store offset=4 + local.get 3 + i32.load offset=28 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 1) + local.set 2 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.store + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.const 32 + i32.add + global.set 0) + (func $deque_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=12) + (func $deque_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=28 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=12 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=12 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.and + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=40 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=28 + i32.and + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=8 + local.get 3 + i32.load offset=40 + i32.load offset=8 + i32.add + local.get 3 + i32.load offset=16 + i32.and + i32.store + local.get 3 + i32.load offset=36 + local.get 3 + i32.load offset=40 + i32.load + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=32 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.load offset=16 + local.get 3 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + i32.load offset=40 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44) + (func $queue_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $deque_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $queue_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $queue_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $queue_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $deque_new_conf + drop + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=12 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $queue_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $deque_destroy + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $queue_enqueue (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $deque_add_first + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $queue_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=4 + i32.load + call $deque_zip_iter_init + local.get 3 + i32.const 16 + i32.add + global.set 0) + (func $queue_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=4 + call $deque_zip_iter_next + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_capacity.wat b/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_capacity.wat new file mode 100644 index 000000000..a48be8907 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_capacity.wat @@ -0,0 +1,933 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_test (type 2) + i32.const 1052 + call $rbuf_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1052 + call $rbuf_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 160 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=156 + call $setup_test + local.get 0 + i32.const 1046 + call 0 + i32.store offset=108 + local.get 0 + local.get 0 + i32.load offset=108 + i32.store8 offset=106 + local.get 0 + i32.const 0 + i32.store8 offset=107 + local.get 0 + i32.const 1044 + call 0 + i32.store offset=100 + local.get 0 + local.get 0 + i32.load offset=100 + i32.store8 offset=98 + local.get 0 + i32.const 0 + i32.store8 offset=99 + local.get 0 + i32.const 1042 + call 0 + i32.store offset=92 + local.get 0 + local.get 0 + i32.load offset=92 + i32.store8 offset=90 + local.get 0 + i32.const 0 + i32.store8 offset=91 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=84 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store8 offset=82 + local.get 0 + i32.const 0 + i32.store8 offset=83 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=76 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store8 offset=74 + local.get 0 + i32.const 0 + i32.store8 offset=75 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=68 + local.get 0 + local.get 0 + i32.load offset=68 + i32.store8 offset=66 + local.get 0 + i32.const 0 + i32.store8 offset=67 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=60 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store8 offset=58 + local.get 0 + i32.const 0 + i32.store8 offset=59 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=52 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store8 offset=50 + local.get 0 + i32.const 0 + i32.store8 offset=51 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store8 offset=42 + local.get 0 + i32.const 0 + i32.store8 offset=43 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store8 offset=34 + local.get 0 + i32.const 0 + i32.store8 offset=35 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=108 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=100 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=92 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=84 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=76 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=68 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=60 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=52 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=44 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=36 + call $rbuf_enqueue + local.get 0 + i32.const 112 + i32.add + local.tee 1 + i64.const 0 + i64.store + local.get 1 + i32.const 32 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 24 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 16 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 8 + i32.add + i64.const 0 + i64.store + local.get 0 + local.get 0 + i32.load offset=108 + i32.store offset=112 + local.get 0 + local.get 0 + i32.load offset=100 + i32.store offset=116 + local.get 0 + local.get 0 + i32.load offset=92 + i32.store offset=120 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store offset=124 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store offset=128 + local.get 0 + local.get 0 + i32.load offset=68 + i32.store offset=132 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store offset=136 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store offset=140 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store offset=144 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store offset=148 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.load offset=1052 + i32.const 0 + call $rbuf_peek + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=116 + i32.const 0 + i32.load offset=1052 + i32.const 1 + call $rbuf_peek + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store8 offset=26 + local.get 0 + i32.const 0 + i32.store8 offset=27 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store8 offset=18 + local.get 0 + i32.const 0 + i32.store8 offset=19 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 26 + i32.add + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 18 + i32.add + call $rbuf_enqueue + i32.const 0 + i32.load offset=1052 + i32.const 0 + call $rbuf_peek + local.get 0 + i32.const 26 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + i32.const 1 + call $rbuf_peek + local.get 0 + i32.const 18 + i32.add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 12 + i32.add + call $rbuf_dequeue + drop + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 160 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1048 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1048 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1048 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1048 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $rbuf_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $rbuf_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $rbuf_conf_new + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $rbuf_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 10 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $rbuf_conf_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $rbuf_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $rbuf_is_empty (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and) + (func $rbuf_enqueue (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.rem_u + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.rem_u + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end) + (func $rbuf_dequeue (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + call $rbuf_is_empty + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.rem_u + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $rbuf_peek (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "y\00x\00j\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1048) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_dequeue.wat b/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_dequeue.wat new file mode 100644 index 000000000..cb92f968e --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_dequeue.wat @@ -0,0 +1,871 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_test (type 2) + i32.const 1048 + call $rbuf_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $rbuf_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 144 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=140 + call $setup_test + local.get 0 + i32.const 1042 + call 0 + i32.store offset=92 + local.get 0 + local.get 0 + i32.load offset=92 + i32.store8 offset=90 + local.get 0 + i32.const 0 + i32.store8 offset=91 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=84 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store8 offset=82 + local.get 0 + i32.const 0 + i32.store8 offset=83 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=76 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store8 offset=74 + local.get 0 + i32.const 0 + i32.store8 offset=75 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=68 + local.get 0 + local.get 0 + i32.load offset=68 + i32.store8 offset=66 + local.get 0 + i32.const 0 + i32.store8 offset=67 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=60 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store8 offset=58 + local.get 0 + i32.const 0 + i32.store8 offset=59 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=52 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store8 offset=50 + local.get 0 + i32.const 0 + i32.store8 offset=51 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store8 offset=42 + local.get 0 + i32.const 0 + i32.store8 offset=43 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store8 offset=34 + local.get 0 + i32.const 0 + i32.store8 offset=35 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store8 offset=26 + local.get 0 + i32.const 0 + i32.store8 offset=27 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store8 offset=18 + local.get 0 + i32.const 0 + i32.store8 offset=19 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=92 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=84 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=76 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=68 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=60 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=52 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=44 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=36 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=28 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=20 + call $rbuf_enqueue + local.get 0 + i32.const 96 + i32.add + local.tee 1 + i64.const 0 + i64.store + local.get 1 + i32.const 32 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 24 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 16 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 8 + i32.add + i64.const 0 + i64.store + local.get 0 + local.get 0 + i32.load offset=92 + i32.store offset=96 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store offset=100 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store offset=104 + local.get 0 + local.get 0 + i32.load offset=68 + i32.store offset=108 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store offset=112 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store offset=116 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store offset=120 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store offset=124 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store offset=128 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store offset=132 + local.get 0 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load offset=8 + i32.const 10 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 12 + i32.add + call $rbuf_dequeue + drop + local.get 0 + i32.const 96 + i32.add + local.get 0 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 12 + i32.add + i32.const 0 + i32.store + local.get 0 + local.get 0 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.const 144 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $rbuf_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $rbuf_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $rbuf_conf_new + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $rbuf_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 10 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $rbuf_conf_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $rbuf_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $rbuf_is_empty (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and) + (func $rbuf_enqueue (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.rem_u + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.rem_u + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end) + (func $rbuf_dequeue (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + call $rbuf_is_empty + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.rem_u + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "j\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_enqueue.wat b/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_enqueue.wat new file mode 100644 index 000000000..7edd6f10a --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/ring_buffer/ring_buffer_test_enqueue.wat @@ -0,0 +1,797 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_test (type 2) + i32.const 1048 + call $rbuf_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $rbuf_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 144 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=140 + call $setup_test + local.get 0 + i32.const 1042 + call 0 + i32.store offset=92 + local.get 0 + local.get 0 + i32.load offset=92 + i32.store8 offset=90 + local.get 0 + i32.const 0 + i32.store8 offset=91 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=84 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store8 offset=82 + local.get 0 + i32.const 0 + i32.store8 offset=83 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=76 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store8 offset=74 + local.get 0 + i32.const 0 + i32.store8 offset=75 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=68 + local.get 0 + local.get 0 + i32.load offset=68 + i32.store8 offset=66 + local.get 0 + i32.const 0 + i32.store8 offset=67 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=60 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store8 offset=58 + local.get 0 + i32.const 0 + i32.store8 offset=59 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=52 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store8 offset=50 + local.get 0 + i32.const 0 + i32.store8 offset=51 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store8 offset=42 + local.get 0 + i32.const 0 + i32.store8 offset=43 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=36 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store8 offset=34 + local.get 0 + i32.const 0 + i32.store8 offset=35 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store8 offset=26 + local.get 0 + i32.const 0 + i32.store8 offset=27 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store8 offset=18 + local.get 0 + i32.const 0 + i32.store8 offset=19 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=92 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=84 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=76 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=68 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=60 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=52 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=44 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=36 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=28 + call $rbuf_enqueue + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=20 + call $rbuf_enqueue + local.get 0 + i32.const 96 + i32.add + local.tee 1 + i64.const 0 + i64.store + local.get 1 + i32.const 32 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 24 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 16 + i32.add + i64.const 0 + i64.store + local.get 1 + i32.const 8 + i32.add + i64.const 0 + i64.store + local.get 0 + local.get 0 + i32.load offset=92 + i32.store offset=96 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store offset=100 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store offset=104 + local.get 0 + local.get 0 + i32.load offset=68 + i32.store offset=108 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store offset=112 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store offset=116 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store offset=120 + local.get 0 + local.get 0 + i32.load offset=36 + i32.store offset=124 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store offset=128 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store offset=132 + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load offset=12 + i32.const 10 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $rbuf_peek + local.get 0 + i32.const 96 + i32.add + local.get 0 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.const 144 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $rbuf_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $rbuf_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $rbuf_conf_new + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $rbuf_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 10 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=12) + (func $rbuf_conf_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 32 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=8 + i32.load + i32.const 4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + call_indirect (type 0) + local.set 1 + local.get 2 + i32.load + local.get 1 + i32.store offset=16 + block ;; label = @2 + local.get 1 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=20 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=24 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=28 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=4 + local.get 2 + i32.load + i32.const 0 + i32.store + local.get 2 + i32.load + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $rbuf_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=16 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=28 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $rbuf_enqueue (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=12 + i32.const 1 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.rem_u + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=8 + i32.const 1 + i32.add + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.rem_u + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end) + (func $rbuf_peek (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "j\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_add.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_add.wat new file mode 100644 index 000000000..0247db330 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_add.wat @@ -0,0 +1,815 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + i32.const 1036 + call $slist_new + drop + i32.const 1040 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1036 + call $slist_destroy + i32.const 0 + i32.load offset=1040 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_test + local.get 0 + i32.const 1030 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 38 + i32.add + call $slist_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 30 + i32.add + call $slist_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 22 + i32.add + call $slist_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 14 + i32.add + call $slist_add + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + local.get 0 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAll.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAll.wat new file mode 100644 index 000000000..ba67bbfd7 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAll.wat @@ -0,0 +1,1130 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1044 + call $slist_add_all + drop + i32.const 8 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 4 + i32.add + call $slist_get_last + drop + local.get 0 + i32.load offset=8 + i32.load + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.const 16 + i32.add + local.get 2 + i32.const 12 + i32.add + call $link_all_externally + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=12 + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=24 + i32.load offset=8 + local.get 2 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=12 + i32.store offset=8 + end + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + local.get 2 + i32.load offset=20 + i32.load + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $link_all_externally (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.const 1 + i32.const 8 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@4;) + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@5;) + local.get 3 + local.get 3 + i32.load offset=20 + i32.load + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=20 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load + i32.store + br 0 (;@6;) + end + end + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=12 + i32.load + i32.store + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=16 + i32.load + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.const 1 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAllAt.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAllAt.wat new file mode 100644 index 000000000..da979fbc5 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAllAt.wat @@ -0,0 +1,1342 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + i32.const 2 + call $slist_add_all_at + drop + i32.const 4 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 8 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 5 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1048 + i32.const 3 + local.get 0 + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $link_all_externally (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.const 1 + i32.const 8 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=4 + block ;; label = @4 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@4;) + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@5;) + local.get 3 + local.get 3 + i32.load offset=20 + i32.load + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=20 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load + i32.store + br 0 (;@6;) + end + end + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=12 + i32.load + i32.store + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=20 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@5;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=4 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@4;) + end + local.get 3 + i32.load offset=16 + i32.load + local.get 3 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=4 + i32.store + end + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.const 1 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_add_all_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=36 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.const 0 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.const 0 + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + local.get 3 + i32.const 24 + i32.add + local.get 3 + i32.const 28 + i32.add + call $get_node_at + i32.store offset=20 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + block ;; label = @2 + local.get 3 + i32.load offset=36 + local.get 3 + i32.const 16 + i32.add + local.get 3 + i32.const 12 + i32.add + call $link_all_externally + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=28 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.store offset=4 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=16 + i32.store offset=4 + br 1 (;@2;) + end + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.store offset=4 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + local.get 3 + i32.load offset=36 + i32.load + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAt.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAt.wat new file mode 100644 index 000000000..c52a5b385 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addAt.wat @@ -0,0 +1,1223 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $slist_new + drop + i32.const 1052 + call $slist_new + drop + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $slist_destroy + i32.const 0 + i32.load offset=1052 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1024 + call 0 + i32.store offset=24 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=20 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=20 + i32.const 2 + call $slist_add_at + drop + i32.const 5 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 2 + local.get 0 + i32.const 16 + i32.add + call $slist_get_at + drop + local.get 0 + i32.load offset=20 + i32.load + local.get 0 + i32.load offset=16 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=20 + i32.const 4 + call $slist_add_at + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=20 + i32.const 0 + call $slist_add_at + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 12 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=20 + i32.load + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 12 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=20 + i32.load + local.get 0 + i32.load offset=12 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=40 + local.get 3 + local.get 1 + i32.store offset=36 + local.get 3 + local.get 2 + i32.store offset=32 + local.get 3 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.const 0 + i32.store offset=24 + local.get 3 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=32 + local.get 3 + i32.const 24 + i32.add + local.get 3 + i32.const 28 + i32.add + call $get_node_at + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + i32.const 1 + i32.const 8 + local.get 3 + i32.load offset=40 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=44 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=36 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=28 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=40 + i32.load offset=4 + i32.store offset=4 + local.get 3 + i32.load offset=40 + local.get 3 + i32.load offset=16 + i32.store offset=4 + br 1 (;@2;) + end + local.get 3 + local.get 3 + i32.load offset=28 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=28 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store offset=4 + end + local.get 3 + i32.load offset=40 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=44 + end + local.get 3 + i32.load offset=44 + local.set 2 + local.get 3 + i32.const 48 + i32.add + global.set 0 + local.get 2) + (func $get_node_at (type 6) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addFirst.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addFirst.wat new file mode 100644 index 000000000..cba5b8f4c --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addFirst.wat @@ -0,0 +1,868 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + i32.const 1040 + call $slist_new + drop + i32.const 1044 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $slist_destroy + i32.const 0 + i32.load offset=1044 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $slist_add + drop + i32.const 4 + i32.const 0 + i32.load offset=1040 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $slist_add_first + drop + i32.const 5 + i32.const 0 + i32.load offset=1040 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "p\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addLast.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addLast.wat new file mode 100644 index 000000000..68bf82471 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_addLast.wat @@ -0,0 +1,778 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + i32.const 1040 + call $slist_new + drop + i32.const 1044 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $slist_destroy + i32.const 0 + i32.load offset=1044 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $slist_add + drop + i32.const 4 + i32.const 0 + i32.load offset=1040 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $slist_get_last + drop + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $slist_add_last + drop + i32.const 5 + i32.const 0 + i32.load offset=1040 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 4 + i32.add + call $slist_get_last + drop + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "p\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_contains.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_contains.wat new file mode 100644 index 000000000..92f2e335f --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_contains.wat @@ -0,0 +1,774 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + i32.const 1040 + call $slist_new + drop + i32.const 1044 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $slist_destroy + i32.const 0 + i32.load offset=1044 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=12 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 24 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 16 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $slist_add + drop + i32.const 2 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 20 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 12 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 8 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_copyDeep.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_copyDeep.wat new file mode 100644 index 000000000..c129613af --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_copyDeep.wat @@ -0,0 +1,1229 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $slist_copy_deep + drop + i32.const 4 + local.get 0 + i32.load offset=8 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + call $slist_get_at + drop + local.get 0 + i32.load offset=8 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.ne + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.const 2 + call $slist_destroy_cb + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy_cb (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_remove_all_cb + drop + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 6) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_at (type 7) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_copy_deep (type 7) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.const 12 + i32.add + call $slist_new + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=4 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 2) + call $slist_add + i32.store offset=8 + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + call $slist_destroy + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $copy (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + i32.load + i32.store + local.get 1 + i32.load offset=8 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $copy $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_copyShallow.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_copyShallow.wat new file mode 100644 index 000000000..589282cec --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_copyShallow.wat @@ -0,0 +1,1198 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_copy_shallow + drop + i32.const 4 + local.get 0 + i32.load offset=8 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 4 + i32.add + call $slist_get_first + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + call $slist_get_first + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 4 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + call $slist_get_last + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.const 3 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1044 + i32.const 3 + local.get 0 + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + call $slist_destroy + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_copy_shallow (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.const 16 + i32.add + call $slist_new + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load + call $slist_add + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + call $slist_destroy + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=28 + br 3 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter1.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter1.wat new file mode 100644 index 000000000..aba3c6e2a --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter1.wat @@ -0,0 +1,1037 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $pred1 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $slist_filter + drop + i32.const 0 + local.get 0 + i32.load offset=8 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=4 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 4 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_filter (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $slist_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 12 + i32.add + call $slist_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 2) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load + call $slist_add + drop + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred1 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter2.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter2.wat new file mode 100644 index 000000000..f54242881 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter2.wat @@ -0,0 +1,1180 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (func $pred2 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.ge_s + i32.const 1 + i32.and) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 1052 + call $pred2 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1056 + call $pred2 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1060 + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 1064 + call $pred2 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=40 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 40 + i32.add + call $slist_filter + drop + i32.const 2 + local.get 0 + i32.load offset=40 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=12 + local.get 0 + i32.const 0 + i32.store offset=8 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.load offset=40 + call $slist_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + call $slist_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=8 + br_if 0 (;@3;) + local.get 0 + i32.load offset=12 + i32.load + i32.const 0 + i32.load offset=1060 + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load offset=8 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.load offset=12 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load offset=8 + i32.const 1 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + i32.const 0 + call 2 + end + local.get 0 + local.get 0 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_filter (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $slist_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 12 + i32.add + call $slist_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 2) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load + call $slist_add + drop + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_iter_init (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8) + (func $slist_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=16 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred2 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter3.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter3.wat new file mode 100644 index 000000000..db8c4eda0 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filter3.wat @@ -0,0 +1,1248 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32))) + (func $pred3 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_s + i32.const 1 + i32.and) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (func $CHECK_EQ_LIST (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=60 + local.get 2 + local.get 1 + i32.store offset=56 + local.get 2 + i32.load offset=60 + call $slist_size + local.get 2 + i32.load offset=56 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + local.get 2 + i32.load offset=60 + local.get 2 + i32.load offset=56 + call $slist_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.const 16 + i32.add + local.get 2 + i32.const 12 + i32.add + local.get 2 + i32.const 8 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + br 0 (;@2;) + end + end + local.get 2 + i32.const 64 + i32.add + global.set 0) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 5) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 1052 + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1056 + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1060 + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 1064 + call $pred3 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $slist_filter + drop + i32.const 4 + local.get 0 + i32.load offset=8 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $CHECK_EQ_LIST + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_filter (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=24 + call $slist_size + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 12 + i32.add + call $slist_new + drop + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=20 + call_indirect (type 2) + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load + call $slist_add + drop + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_zip_iter_init (type 7) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=20 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=32 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=16) + (func $slist_zip_iter_next (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=28 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=32 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred3 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut1.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut1.wat new file mode 100644 index 000000000..957c3c64a --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut1.wat @@ -0,0 +1,1102 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $pred1 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.eq + i32.const 1 + i32.and) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1052 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $slist_filter_mut + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $slist_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 2) + br_if 0 (;@5;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + call $unlinkn + drop + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=8 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred1 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut2.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut2.wat new file mode 100644 index 000000000..bee22b572 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut2.wat @@ -0,0 +1,1245 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32))) + (func $pred2 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 3 + i32.ge_s + i32.const 1 + i32.and) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 1052 + call $pred2 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1056 + call $pred2 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1060 + call $pred2 + i32.eqz + br_if 0 (;@1;) + i32.const 1064 + call $pred2 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $slist_filter_mut + drop + i32.const 2 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=4 + local.get 0 + i32.const 0 + i32.store + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1044 + call $slist_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $slist_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load + br_if 0 (;@3;) + local.get 0 + i32.load offset=4 + i32.load + i32.const 0 + i32.load offset=1060 + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.load offset=4 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + call 2 + end + block ;; label = @3 + local.get 0 + i32.load + i32.const 1 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + i32.const 0 + call 2 + end + local.get 0 + local.get 0 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $slist_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 2) + br_if 0 (;@5;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + call $unlinkn + drop + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=8 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_iter_init (type 6) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8) + (func $slist_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=16 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred2 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut3.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut3.wat new file mode 100644 index 000000000..42ca07048 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_filterMut3.wat @@ -0,0 +1,1050 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $pred3 (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + i32.const 0 + i32.gt_s + i32.const 1 + i32.and) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 1052 + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1056 + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 1060 + call $pred3 + i32.eqz + br_if 0 (;@1;) + i32.const 1064 + call $pred3 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $slist_filter_mut + drop + i32.const 4 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_filter_mut (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + call $slist_size + br_if 0 (;@2;) + local.get 2 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 2) + br_if 0 (;@5;) + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + call $unlinkn + drop + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=8 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + br 0 (;@3;) + end + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $pred3 $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_get.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_get.wat new file mode 100644 index 000000000..032e33815 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_get.wat @@ -0,0 +1,961 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_getFirst.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_getFirst.wat new file mode 100644 index 000000000..6fc201684 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_getFirst.wat @@ -0,0 +1,842 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_getLast.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_getLast.wat new file mode 100644 index 000000000..914b2543f --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_getLast.wat @@ -0,0 +1,842 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_indexOf.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_indexOf.wat new file mode 100644 index 000000000..f4f6e54d8 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_indexOf.wat @@ -0,0 +1,782 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + i32.const 1036 + call $slist_new + drop + i32.const 1040 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1036 + call $slist_destroy + i32.const 0 + i32.load offset=1040 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_test + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=16 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=12 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 8 + i32.add + call $slist_index_of + drop + i32.const 0 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + call $slist_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_iterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_iterAdd.wat new file mode 100644 index 000000000..740b77678 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_iterAdd.wat @@ -0,0 +1,1459 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $slist_new + drop + i32.const 1052 + call $slist_new + drop + i32.const 0 + i32.const 1042 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $slist_destroy + i32.const 0 + i32.load offset=1052 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + call $setup_test + local.get 0 + i32.const 1026 + call 0 + i32.store offset=56 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=52 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=56 + i32.store + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + call $slist_iter_init + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1064 + i32.const 0 + i32.load offset=1068 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1068 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1068 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=56 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + call $slist_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + i32.load + i32.const 0 + i32.load offset=1064 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.load offset=52 + call $slist_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 5 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 3 + local.get 0 + i32.const 24 + i32.add + call $slist_get_at + drop + local.get 0 + i32.load offset=24 + i32.load + local.get 0 + i32.load offset=56 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + i32.const 4 + local.get 0 + i32.const 20 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=20 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.load offset=12 + local.get 0 + i32.load offset=16 + i32.store + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + call $slist_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + call $slist_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + i32.load + i32.const 0 + i32.load offset=1068 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.load offset=12 + call $slist_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 6 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 64 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8) + (func $slist_iter_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load + i32.store offset=4 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=16 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "x\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_iterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_iterRemove.wat new file mode 100644 index 000000000..f386f204c --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_iterRemove.wat @@ -0,0 +1,1401 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1052 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1056 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1060 + i32.const 0 + i32.load offset=1064 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 40 + i32.add + call $slist_get_at + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + call $slist_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + call $slist_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + i32.const 0 + i32.load offset=1060 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + i32.const 0 + call $slist_iter_remove + drop + end + br 0 (;@2;) + end + end + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=40 + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=40 + call 5 + call $teardown_test + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $unlinkn (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $slist_iter_init (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8) + (func $slist_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $unlinkn + i32.store + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=16 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_new.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_new.wat new file mode 100644 index 000000000..68a3aea57 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_new.wat @@ -0,0 +1,654 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + i32.const 1028 + call $slist_new + drop + i32.const 1032 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1028 + call $slist_destroy + i32.const 0 + i32.load offset=1032 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + local.get 0 + i32.const 0 + i32.store offset=8 + local.get 0 + i32.const 8 + i32.add + call $slist_new + drop + i32.const 0 + i32.load offset=1028 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load offset=1028 + local.get 0 + i32.const 4 + i32.add + call $slist_get_first + drop + i32.const 0 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1028 + local.get 0 + i32.const 4 + i32.add + call $slist_get_last + drop + i32.const 0 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1028 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1028 + local.get 0 + i32.load offset=8 + i32.ne + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1024 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1024 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1024 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1024 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1024 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1024 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1024 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1024 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_remove.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_remove.wat new file mode 100644 index 000000000..2c61ed331 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_remove.wat @@ -0,0 +1,1336 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + local.set 1 + block ;; label = @1 + i32.const 0 + i32.load offset=1056 + i32.const 0 + i32.load offset=1052 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + i32.const 0 + i32.load offset=1056 + i32.const 0 + i32.load offset=1060 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + i32.load offset=1056 + i32.const 0 + i32.load offset=1064 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.const 0 + i32.load offset=1044 + i32.const 1 + local.get 0 + i32.const 8 + i32.add + call $slist_get_at + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + i32.const 0 + call $slist_remove + drop + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + call 5 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_remove (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + call $unlinkn + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $get_node (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=16 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 4 + i32.load offset=16 + i32.load + i32.load + local.get 4 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 4 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + br 0 (;@3;) + end + end + local.get 4 + i32.const 7 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $unlinkn (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeAll.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeAll.wat new file mode 100644 index 000000000..7f2e4f336 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeAll.wat @@ -0,0 +1,918 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 1 + call $slist_remove_all_cb + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 0 + i32.store offset=8 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + local.get 0 + i32.load offset=8 + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_remove_all_cb (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $unlinkn_all + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 7 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $free $malloc $calloc) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeAt.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeAt.wat new file mode 100644 index 000000000..7935ec891 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeAt.wat @@ -0,0 +1,1185 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $slist_remove_at + drop + local.get 0 + i32.load offset=8 + call 5 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 8 + i32.add + call $slist_remove_at + drop + local.get 0 + i32.load offset=8 + call 5 + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 8 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $unlinkn (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_remove_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + call $unlinkn + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeFirst.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeFirst.wat new file mode 100644 index 000000000..2f34f3151 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeFirst.wat @@ -0,0 +1,1015 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_remove_first + drop + local.get 0 + i32.load offset=8 + call 5 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + call $unlinkn + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeLast.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeLast.wat new file mode 100644 index 000000000..c948d55e8 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_removeLast.wat @@ -0,0 +1,1135 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_remove_last + drop + local.get 0 + i32.load offset=8 + call 5 + i32.const 3 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1060 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $unlinkn (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.const 0 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + local.get 2 + i32.const 12 + i32.add + local.get 2 + i32.const 16 + i32.add + call $get_node_at + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=16 + call $unlinkn + i32.store offset=4 + block ;; label = @2 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=4 + i32.store + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_replaceAt.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_replaceAt.wat new file mode 100644 index 000000000..dacb5aec6 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_replaceAt.wat @@ -0,0 +1,1069 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1048 + call $slist_new + drop + i32.const 1052 + call $slist_new + drop + i32.const 0 + i32.const 1040 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1080 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1084 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1064 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1068 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1080 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1084 + i32.store + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $slist_destroy + i32.const 0 + i32.load offset=1052 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + local.get 0 + i32.const 1024 + call 0 + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.get 0 + i32.load offset=8 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + i32.const 2 + local.get 0 + call $slist_replace_at + drop + local.get 0 + i32.load + call 5 + i32.const 0 + i32.load offset=1048 + i32.const 2 + local.get 0 + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_replace_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=40 + local.get 4 + local.get 1 + i32.store offset=36 + local.get 4 + local.get 2 + i32.store offset=32 + local.get 4 + local.get 3 + i32.store offset=28 + local.get 4 + i32.const 0 + i32.store offset=24 + local.get 4 + i32.const 0 + i32.store offset=20 + local.get 4 + local.get 4 + i32.load offset=40 + local.get 4 + i32.load offset=32 + local.get 4 + i32.const 20 + i32.add + local.get 4 + i32.const 24 + i32.add + call $get_node_at + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=16 + i32.eqz + br_if 0 (;@2;) + local.get 4 + local.get 4 + i32.load offset=16 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=20 + i32.load + i32.store offset=12 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=36 + i32.store + block ;; label = @2 + local.get 4 + i32.load offset=28 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=12 + i32.store + end + local.get 4 + i32.const 0 + i32.store offset=44 + end + local.get 4 + i32.load offset=44 + local.set 3 + local.get 4 + i32.const 48 + i32.add + global.set 0 + local.get 3) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "r\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_reverse.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_reverse.wat new file mode 100644 index 000000000..75c83658b --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_reverse.wat @@ -0,0 +1,969 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (func $setup_test (type 2) + i32.const 1040 + call $slist_new + drop + i32.const 1044 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1040 + call $slist_destroy + i32.const 0 + i32.load offset=1044 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + call $setup_test + local.get 0 + i32.const 1034 + call 0 + i32.store offset=88 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=84 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=76 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=72 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=68 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 88 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 84 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 80 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 76 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 72 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 68 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1040 + call $slist_reverse + local.get 0 + local.get 0 + i32.load offset=68 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store offset=36 + local.get 0 + local.get 0 + i32.load offset=76 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=84 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store offset=52 + local.get 0 + i32.const 8 + i32.add + i32.const 0 + i32.load offset=1040 + call $slist_iter_init + local.get 0 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $slist_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.load + i32.const 2 + i32.shl + i32.add + i32.load + local.get 0 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + local.get 0 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + call $teardown_test + local.get 0 + i32.const 96 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_reverse (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=12 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=12 + i32.load + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + br 1 (;@1;) + end + local.get 1 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + local.get 1 + local.get 1 + i32.load offset=12 + i32.load offset=4 + i32.store + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 1 + local.get 1 + i32.load + i32.load offset=4 + i32.store offset=4 + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.store offset=4 + local.get 1 + local.get 1 + i32.load + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.store + br 0 (;@3;) + end + end + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.store offset=4 + end) + (func $slist_iter_init (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=12 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8) + (func $slist_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=16 + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_splice.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_splice.wat new file mode 100644 index 000000000..4e35119c1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_splice.wat @@ -0,0 +1,1180 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $slist_splice + drop + i32.const 8 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1080 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 4 + local.get 0 + i32.const 8 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_splice (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=8 + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + local.get 2 + i32.load offset=4 + i32.load + i32.add + i32.store + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_spliceAt.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_spliceAt.wat new file mode 100644 index 000000000..2e6cfd1cb --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_spliceAt.wat @@ -0,0 +1,1293 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + i32.const 2 + call $slist_splice_at + drop + i32.const 8 + i32.const 0 + i32.load offset=1044 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_first + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + i32.const 0 + i32.load offset=1064 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1068 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_splice_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.load + br_if 0 (;@2;) + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=16 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + call $splice_between + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $splice_between (type 7) (param i32 i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=12 + local.get 4 + local.get 1 + i32.store offset=8 + local.get 4 + local.get 2 + i32.store offset=4 + local.get 4 + local.get 3 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 4 + i32.load offset=8 + i32.load offset=8 + local.get 4 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 4 + i32.load offset=12 + i32.load offset=8 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=8 + i32.load offset=8 + i32.store offset=8 + br 1 (;@2;) + end + local.get 4 + i32.load offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.load offset=8 + local.get 4 + i32.load + i32.store offset=4 + end + end + local.get 4 + i32.load offset=12 + local.tee 3 + local.get 3 + i32.load + local.get 4 + i32.load offset=8 + i32.load + i32.add + i32.store + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 4 + i32.load offset=8 + i32.const 0 + i32.store) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_sublist.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_sublist.wat new file mode 100644 index 000000000..16be5febf --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_sublist.wat @@ -0,0 +1,1163 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 2) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + i32.const 1 + i32.const 2 + local.get 0 + i32.const 8 + i32.add + call $slist_sublist + drop + i32.const 2 + local.get 0 + i32.load offset=8 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + i32.const 1 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + call $slist_destroy + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_sublist (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 0 + i32.store offset=40 + local.get 4 + local.get 1 + i32.store offset=36 + local.get 4 + local.get 2 + i32.store offset=32 + local.get 4 + local.get 3 + i32.store offset=28 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load offset=36 + local.get 4 + i32.load offset=32 + i32.gt_u + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=40 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 4 + i32.const 3 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + i32.const 0 + i32.store offset=24 + local.get 4 + i32.const 0 + i32.store offset=20 + local.get 4 + local.get 4 + i32.const 16 + i32.add + call $slist_new + i32.store offset=12 + block ;; label = @2 + local.get 4 + i32.load offset=12 + i32.eqz + br_if 0 (;@2;) + local.get 4 + local.get 4 + i32.load offset=12 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=40 + local.get 4 + i32.load offset=36 + local.get 4 + i32.const 20 + i32.add + local.get 4 + i32.const 24 + i32.add + call $get_node_at + i32.store offset=12 + block ;; label = @2 + local.get 4 + i32.load offset=12 + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.load offset=16 + call $slist_destroy + local.get 4 + local.get 4 + i32.load offset=12 + i32.store offset=44 + br 1 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=36 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=32 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=20 + i32.load + call $slist_add + i32.store offset=12 + block ;; label = @4 + local.get 4 + i32.load offset=12 + i32.eqz + br_if 0 (;@4;) + local.get 4 + i32.load offset=16 + call $slist_destroy + local.get 4 + local.get 4 + i32.load offset=12 + i32.store offset=44 + br 3 (;@1;) + end + local.get 4 + local.get 4 + i32.load offset=20 + i32.load offset=4 + i32.store offset=20 + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.store + local.get 4 + i32.const 0 + i32.store offset=44 + end + local.get 4 + i32.load offset=44 + local.set 3 + local.get 4 + i32.const 48 + i32.add + global.set 0 + local.get 3) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_toArray.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_toArray.wat new file mode 100644 index 000000000..7fd00e8ce --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_toArray.wat @@ -0,0 +1,1105 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (func $setup_test (type 3) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop + i32.const 0 + i32.const 1038 + call 0 + i32.store offset=1052 + i32.const 0 + i32.const 1036 + call 0 + i32.store offset=1056 + i32.const 0 + i32.const 1034 + call 0 + i32.store offset=1060 + i32.const 0 + i32.const 1032 + call 0 + i32.store offset=1064 + i32.const 0 + i32.const 1030 + call 0 + i32.store offset=1068 + i32.const 0 + i32.const 1028 + call 0 + i32.store offset=1072 + i32.const 0 + i32.const 1026 + call 0 + i32.store offset=1076 + i32.const 0 + i32.const 1024 + call 0 + i32.store offset=1080 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1052 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1056 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1060 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1064 + i32.store + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 4 + call $malloc + i32.store offset=12 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=8 + local.get 0 + i32.const 4 + call $malloc + i32.store offset=4 + local.get 0 + i32.const 4 + call $malloc + i32.store + local.get 0 + i32.load offset=12 + i32.const 0 + i32.load offset=1068 + i32.store + local.get 0 + i32.load offset=8 + i32.const 0 + i32.load offset=1072 + i32.store + local.get 0 + i32.load offset=4 + i32.const 0 + i32.load offset=1076 + i32.store + local.get 0 + i32.load + i32.const 0 + i32.load offset=1080 + i32.store + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=12 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=8 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load offset=4 + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.load + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func $teardown_test (type 3) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + call $setup_test + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $slist_to_array + drop + i32.const 0 + i32.load offset=1044 + i32.const 0 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 2 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load offset=8 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + i32.const 3 + local.get 0 + i32.const 4 + i32.add + call $slist_get_at + drop + local.get 0 + i32.load offset=4 + local.get 0 + i32.load offset=8 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=8 + call 5 + call $teardown_test + local.get 0 + i32.const 16 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $get_node_at (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + local.get 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=20 + local.get 4 + local.get 2 + i32.store offset=16 + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.load offset=20 + local.get 4 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=24 + i32.load offset=4 + i32.store + local.get 4 + i32.load offset=12 + i32.const 0 + i32.store + local.get 4 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 4 + i32.load offset=8 + local.get 4 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=16 + i32.load + i32.store + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=16 + i32.load + i32.load offset=4 + i32.store + local.get 4 + local.get 4 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 4 + i32.const 0 + i32.store offset=28 + end + local.get 4 + i32.load offset=28) + (func $slist_get_at (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 0 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + local.get 3 + i32.const 8 + i32.add + local.get 3 + i32.const 12 + i32.add + call $get_node_at + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=4 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $slist_to_array (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 2) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 2 + i32.const 0 + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=24 + i32.load + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=12 + i32.load + i32.store + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66624)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) "@\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterAdd.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterAdd.wat new file mode 100644 index 000000000..bbe7c0735 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterAdd.wat @@ -0,0 +1,1956 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (func $setup_test (type 2) + i32.const 1052 + call $slist_new + drop + i32.const 1056 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1052 + call $slist_destroy + i32.const 0 + i32.load offset=1056 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 144 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=140 + call $setup_test + local.get 0 + i32.const 1044 + call 0 + i32.store offset=136 + local.get 0 + i32.load offset=136 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=136 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=136 + i32.store8 offset=134 + local.get 0 + i32.const 0 + i32.store8 offset=135 + local.get 0 + i32.const 1042 + call 0 + i32.store offset=128 + local.get 0 + i32.load offset=128 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=128 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=128 + i32.store8 offset=126 + local.get 0 + i32.const 0 + i32.store8 offset=127 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=120 + local.get 0 + i32.load offset=120 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=120 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=112 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=112 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=136 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=112 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=136 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=128 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=80 + local.get 0 + i32.load offset=112 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=136 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=120 + local.get 0 + i32.load offset=112 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=104 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=96 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=88 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 134 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 126 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 118 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 110 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 102 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 94 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 86 + i32.add + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1056 + call $slist_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 126 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.const 70 + i32.add + call $slist_zip_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 78 + i32.add + local.get 0 + i32.const 4 + i32.add + call $slist_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 70 + i32.add + local.get 0 + i32.const 4 + i32.add + call $slist_index_of + drop + i32.const 2 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 118 + i32.add + local.get 0 + i32.const 4 + i32.add + call $slist_index_of + drop + i32.const 3 + local.get 0 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 78 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 70 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 5 + i32.const 0 + i32.load offset=1052 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 4 + i32.const 0 + i32.load offset=1056 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1056 + call $slist_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=8 + local.get 0 + i32.const 86 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 62 + i32.add + local.get 0 + i32.const 54 + i32.add + call $slist_zip_iter_add + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1056 + local.get 0 + call $slist_get_last + drop + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + local.get 0 + call $slist_get_last + drop + local.get 0 + i32.const 110 + i32.add + local.get 0 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 144 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1048 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1048 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1048 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1048 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $slist_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $slist_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=20 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=32 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=16) + (func $slist_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=28 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=32 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $slist_zip_iter_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + i32.const 1 + i32.const 8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 1 + i32.const 8 + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.store offset=4 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load offset=24 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store offset=4 + local.get 3 + i32.load offset=24 + i32.load offset=24 + local.get 3 + i32.load offset=8 + i32.store offset=4 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.get 3 + i32.load offset=12 + i32.store offset=8 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.store offset=8 + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66608)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "y\00x\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1048) "0\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterNext.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterNext.wat new file mode 100644 index 000000000..9afb7e41a --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterNext.wat @@ -0,0 +1,1260 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32))) + (type (;6;) (func (param i32 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_test (type 2) + i32.const 1044 + call $slist_new + drop + i32.const 1048 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1044 + call $slist_destroy + i32.const 0 + i32.load offset=1048 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 112 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=108 + call $setup_test + local.get 0 + i32.const 1036 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=64 + local.get 0 + i32.load offset=64 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=64 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=56 + local.get 0 + i32.load offset=56 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=56 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 102 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 94 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 86 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 78 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 70 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 62 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 54 + i32.add + call $slist_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + i32.const 0 + i32.load offset=1048 + call $slist_zip_iter_init + local.get 0 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 4 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + br_if 0 (;@3;) + local.get 0 + i32.const 102 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 70 + i32.add + local.get 0 + i32.load offset=4 + call $CHECK_EQUAL_C_STRING + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 54 + i32.add + local.get 0 + i32.load offset=4 + call $CHECK_EQUAL_C_STRING + end + local.get 0 + local.get 0 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + i32.const 3 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 112 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_zip_iter_init (type 5) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=20 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=32 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=16) + (func $slist_zip_iter_next (type 6) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=28 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=32 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $CHECK_EQUAL_C_STRING (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterRemove.wat new file mode 100644 index 000000000..6d733ae45 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterRemove.wat @@ -0,0 +1,1858 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32))) + (func $setup_test (type 2) + i32.const 1048 + call $slist_new + drop + i32.const 1052 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1048 + call $slist_destroy + i32.const 0 + i32.load offset=1052 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 144 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=140 + call $setup_test + local.get 0 + i32.const 1040 + call 0 + i32.store offset=136 + local.get 0 + i32.load offset=136 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=136 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=136 + i32.store8 offset=134 + local.get 0 + i32.const 0 + i32.store8 offset=135 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=128 + local.get 0 + i32.load offset=128 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=128 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=128 + i32.store8 offset=126 + local.get 0 + i32.const 0 + i32.store8 offset=127 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=120 + local.get 0 + i32.load offset=120 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=120 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=112 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=112 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=136 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=128 + local.get 0 + i32.load offset=112 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=104 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=88 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + local.get 0 + i32.load offset=88 + i32.ne + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 134 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 126 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 118 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 110 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 102 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 94 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 86 + i32.add + call $slist_add + drop + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1052 + call $slist_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + local.get 0 + i32.const 24 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + local.get 0 + i32.const 126 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $slist_zip_iter_remove + drop + end + br 0 (;@2;) + end + end + local.get 0 + i32.const 126 + i32.add + local.get 0 + i32.load offset=20 + call $CHECK_EQUAL_C_STRING + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.load offset=16 + call $CHECK_EQUAL_C_STRING + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 126 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 118 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 3 + i32.const 0 + i32.load offset=1048 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 2 + i32.const 0 + i32.load offset=1052 + call $slist_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1048 + i32.const 0 + i32.load offset=1052 + call $slist_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + local.get 0 + i32.const 24 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=24 + local.get 0 + i32.const 102 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $slist_zip_iter_remove + drop + end + block ;; label = @3 + local.get 0 + i32.load offset=24 + local.get 0 + i32.const 86 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $slist_zip_iter_remove + drop + end + br 0 (;@2;) + end + end + local.get 0 + i32.const 1041 + i32.store offset=12 + local.get 0 + i32.const 1041 + i32.store offset=8 + i32.const 7 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 12 + i32.add + call $slist_get_first + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 7 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 12 + i32.add + call $slist_get_first + drop + local.get 0 + i32.const 110 + i32.add + local.get 0 + i32.load offset=12 + call $CHECK_EQUAL_C_STRING + i32.const 0 + i32.load offset=1048 + local.get 0 + i32.const 8 + i32.add + call $slist_get_last + drop + local.get 0 + i32.const 110 + i32.add + local.get 0 + i32.load offset=8 + call $CHECK_EQUAL_C_STRING + call $teardown_test + local.get 0 + i32.const 144 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1044 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1044 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1044 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1044 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $unlinkn (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.load + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + end + block ;; label = @1 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.load + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $slist_get_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12) + (func $slist_size (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load) + (func $slist_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $slist_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=20 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=32 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=16) + (func $slist_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=28 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=32 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $slist_zip_iter_remove (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + local.get 3 + i32.load offset=24 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load offset=28 + call $unlinkn + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=32 + call $unlinkn + i32.store offset=8 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.store offset=20 + local.get 3 + i32.load offset=24 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + block ;; label = @2 + local.get 3 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $CHECK_EQUAL_C_STRING (type 7) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1044) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterReplace.wat b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterReplace.wat new file mode 100644 index 000000000..03ad98380 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/slist/slist_test_zipIterReplace.wat @@ -0,0 +1,1710 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (type (;7;) (func (param i32 i32 i32 i32 i32) (result i32))) + (func $setup_test (type 2) + i32.const 1052 + call $slist_new + drop + i32.const 1056 + call $slist_new + drop) + (func $teardown_test (type 2) + i32.const 0 + i32.load offset=1052 + call $slist_destroy + i32.const 0 + i32.load offset=1056 + call $slist_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 160 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=156 + call $setup_test + local.get 0 + i32.const 1044 + call 0 + i32.store offset=152 + local.get 0 + i32.load offset=152 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=152 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=152 + i32.store8 offset=150 + local.get 0 + i32.const 0 + i32.store8 offset=151 + local.get 0 + i32.const 1042 + call 0 + i32.store offset=144 + local.get 0 + i32.load offset=144 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=144 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=144 + i32.store8 offset=142 + local.get 0 + i32.const 0 + i32.store8 offset=143 + local.get 0 + i32.const 1040 + call 0 + i32.store offset=136 + local.get 0 + i32.load offset=136 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=136 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=136 + i32.store8 offset=134 + local.get 0 + i32.const 0 + i32.store8 offset=135 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=128 + local.get 0 + i32.load offset=128 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=128 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=128 + i32.store8 offset=126 + local.get 0 + i32.const 0 + i32.store8 offset=127 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=120 + local.get 0 + i32.load offset=120 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=120 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=120 + i32.store8 offset=118 + local.get 0 + i32.const 0 + i32.store8 offset=119 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=112 + local.get 0 + i32.load offset=112 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=112 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=112 + i32.store8 offset=110 + local.get 0 + i32.const 0 + i32.store8 offset=111 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=104 + local.get 0 + i32.load offset=104 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=104 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=104 + i32.store8 offset=102 + local.get 0 + i32.const 0 + i32.store8 offset=103 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=96 + local.get 0 + i32.load offset=96 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=96 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=96 + i32.store8 offset=94 + local.get 0 + i32.const 0 + i32.store8 offset=95 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=88 + local.get 0 + i32.load offset=88 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=88 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=88 + i32.store8 offset=86 + local.get 0 + i32.const 0 + i32.store8 offset=87 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=80 + local.get 0 + i32.load offset=80 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=80 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=80 + i32.store8 offset=78 + local.get 0 + i32.const 0 + i32.store8 offset=79 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=72 + local.get 0 + i32.load offset=72 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=72 + i32.const 127 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=144 + local.get 0 + i32.load offset=152 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=144 + local.get 0 + i32.load offset=136 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=144 + local.get 0 + i32.load offset=128 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=152 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=144 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=136 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=96 + local.get 0 + i32.load offset=128 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=120 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=112 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=104 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 150 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 142 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 134 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 126 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 118 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 110 + i32.add + call $slist_add + drop + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 102 + i32.add + call $slist_add + drop + local.get 0 + i32.const 32 + i32.add + i32.const 0 + i32.load offset=1052 + i32.const 0 + i32.load offset=1056 + call $slist_zip_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 28 + i32.add + local.get 0 + i32.const 24 + i32.add + call $slist_zip_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=28 + local.get 0 + i32.const 142 + i32.add + call $strcmp + br_if 0 (;@3;) + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.const 16 + i32.add + call $slist_zip_iter_replace + drop + end + br 0 (;@2;) + end + end + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 94 + i32.add + local.get 0 + i32.const 12 + i32.add + call $slist_index_of + drop + i32.const 1 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 86 + i32.add + local.get 0 + i32.const 12 + i32.add + call $slist_index_of + drop + i32.const 1 + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1052 + local.get 0 + i32.const 94 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1056 + local.get 0 + i32.const 86 + i32.add + call $slist_contains + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_test + local.get 0 + i32.const 160 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1048 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1048 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1048 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1048 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1048 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8) + (func $slist_new (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + call $slist_conf_init + local.get 1 + local.get 1 + i32.load offset=12 + call $slist_new_conf + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $slist_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=8 + i32.load offset=4 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load + i32.store offset=12 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $slist_remove_all + drop + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=20 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $slist_remove_all (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + local.get 1 + local.get 1 + i32.load offset=8 + i32.const 0 + call $unlinkn_all + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=4 + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 1 + i32.load offset=8 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.const 7 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $unlinkn_all (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=4 + i32.store offset=12 + block ;; label = @4 + local.get 2 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=20 + call_indirect (type 1) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=24 + local.tee 1 + local.get 1 + i32.load + i32.const -1 + i32.add + i32.store + br 0 (;@3;) + end + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $slist_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $slist_add_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_add_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 1 + i32.const 8 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 0) + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load + local.get 2 + i32.load offset=4 + i32.store + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + i32.store offset=8 + end + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $slist_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 2 + i32.load offset=4 + i32.load + local.get 2 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=4 + i32.store offset=4 + br 0 (;@2;) + end + end + local.get 2 + i32.load) + (func $slist_index_of (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.const 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 3 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + local.get 3 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + br 0 (;@3;) + end + end + local.get 3 + i32.const 8 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $slist_zip_iter_init (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.store offset=4 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=8 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=20 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=24 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=28 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.store offset=32 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.load offset=4 + i32.store offset=16) + (func $slist_zip_iter_next (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 3 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load + i32.store offset=8 + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=20 + i32.store offset=28 + end + block ;; label = @2 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=24 + i32.store offset=32 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=12 + i32.load offset=4 + i32.store offset=12 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.store + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28) + (func $slist_zip_iter_replace (type 7) (param i32 i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 5 + local.get 0 + i32.store offset=24 + local.get 5 + local.get 1 + i32.store offset=20 + local.get 5 + local.get 2 + i32.store offset=16 + local.get 5 + local.get 3 + i32.store offset=12 + local.get 5 + local.get 4 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 5 + i32.load offset=24 + i32.load offset=20 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 5 + i32.load offset=24 + i32.load offset=24 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 1 (;@2;) + end + local.get 5 + i32.const 7 + i32.store offset=28 + br 1 (;@1;) + end + local.get 5 + local.get 5 + i32.load offset=24 + i32.load offset=20 + i32.load + i32.store offset=4 + local.get 5 + local.get 5 + i32.load offset=24 + i32.load offset=24 + i32.load + i32.store + local.get 5 + i32.load offset=24 + i32.load offset=20 + local.get 5 + i32.load offset=20 + i32.store + local.get 5 + i32.load offset=24 + i32.load offset=24 + local.get 5 + i32.load offset=16 + i32.store + block ;; label = @2 + local.get 5 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 5 + i32.load offset=12 + local.get 5 + i32.load offset=4 + i32.store + end + block ;; label = @2 + local.get 5 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 5 + i32.load offset=8 + local.get 5 + i32.load + i32.store + end + local.get 5 + i32.const 0 + i32.store offset=28 + end + local.get 5 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 4) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66608)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "y\00x\00i\00h\00g\00f\00e\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1048) "0\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/stack/stack_test_pop.wat b/benchmarks/pldi2026/Collection-C-normal/stack/stack_test_pop.wat new file mode 100644 index 000000000..b442ca91c --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/stack/stack_test_pop.wat @@ -0,0 +1,1419 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 3) + i32.const 1036 + call $stack_new + drop) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $stack_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $stack_push + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $stack_push + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $stack_push + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $stack_pop + drop + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $stack_peek + drop + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.load offset=8 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_remove_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + end + block ;; label = @2 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.const 1 + i32.sub + local.get 3 + i32.load offset=20 + i32.sub + i32.const 2 + i32.shl + i32.store offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=24 + i32.load offset=12 + local.get 3 + i32.load offset=20 + i32.const 1 + i32.add + i32.const 2 + i32.shl + i32.add + local.get 3 + i32.load offset=12 + call $memmove + drop + end + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load + i32.const -1 + i32.add + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $array_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.sub + local.get 2 + i32.load offset=8 + call $array_remove_at + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $array_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + i32.const 1 + i32.sub + local.get 2 + i32.load offset=4 + call $array_get_at + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $memmove (type 5) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 3 + local.tee 4 + local.get 0 + i32.store offset=44 + local.get 4 + local.get 1 + i32.store offset=40 + local.get 4 + local.get 2 + i32.store offset=36 + local.get 4 + local.get 4 + i32.load offset=44 + i32.store offset=32 + local.get 4 + local.get 4 + i32.load offset=40 + i32.store offset=28 + local.get 4 + i32.load offset=36 + local.set 2 + local.get 4 + local.get 3 + i32.store offset=24 + local.get 3 + local.get 2 + i32.const 15 + i32.add + i32.const -16 + i32.and + i32.sub + local.tee 3 + drop + local.get 4 + local.get 2 + i32.store offset=20 + local.get 4 + i32.const 0 + i32.store offset=16 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=16 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 4 + i32.load offset=16 + i32.add + local.get 4 + i32.load offset=28 + local.get 4 + i32.load offset=16 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + br 0 (;@2;) + end + end + local.get 4 + i32.const 0 + i32.store offset=12 + block ;; label = @1 + loop ;; label = @2 + local.get 4 + i32.load offset=12 + local.get 4 + i32.load offset=36 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=32 + local.get 4 + i32.load offset=12 + i32.add + local.get 3 + local.get 4 + i32.load offset=12 + i32.add + i32.load8_u + i32.store8 + local.get 4 + local.get 4 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + br 0 (;@2;) + end + end + local.get 4 + i32.load offset=24 + drop + local.get 4 + i32.load offset=44) + (func $stack_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $array_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $stack_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $stack_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $stack_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $stack_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $array_new_conf + local.tee 1 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 1 + br_if 0 (;@3;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + br 1 (;@2;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $stack_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $array_destroy + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $stack_push (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $array_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $stack_peek (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $array_get_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $stack_pop (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $array_remove_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/stack/stack_test_push.wat b/benchmarks/pldi2026/Collection-C-normal/stack/stack_test_push.wat new file mode 100644 index 000000000..a32b24462 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/stack/stack_test_push.wat @@ -0,0 +1,1144 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (func $setup_tests (type 3) + i32.const 1036 + call $stack_new + drop) + (func $teardown_tests (type 3) + i32.const 0 + i32.load offset=1036 + call $stack_destroy) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 4) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=28 + call $setup_tests + local.get 0 + i32.const 1028 + call 0 + i32.store offset=24 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=20 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=16 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 24 + i32.add + call $stack_push + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $stack_peek + drop + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 20 + i32.add + call $stack_push + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $stack_peek + drop + local.get 0 + i32.const 20 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 16 + i32.add + call $stack_push + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 12 + i32.add + call $stack_peek + drop + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + call 2 + call $teardown_tests + local.get 0 + i32.const 32 + i32.add + global.set 0 + i32.const 0) + (func $array_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + f32.const 0x1p+1 (;=2;) + f32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 8 + i32.store + local.get 1 + i32.load offset=12 + i32.const 1 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=16) + (func $array_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.const 0x1p+0 (;=1;) + f32.le + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + f32.const 0x1p+1 (;=2;) + f32.store offset=16 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + f32.load offset=4 + f32.store offset=16 + end + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + f32.load offset=16 + i32.const 16777216 + local.get 2 + i32.load offset=24 + i32.load + i32.div_u + f32.convert_i32_u + f32.ge + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + end + local.get 2 + i32.const 2 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.const 2 + i32.shl + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 1) + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=12 + local.get 2 + f32.load offset=16 + f32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=20 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=24 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $array_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $array_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + call $expand_capacity + i32.store + block ;; label = @3 + local.get 2 + i32.load + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + br 2 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + i32.add + local.get 2 + i32.load offset=4 + i32.store + local.get 2 + i32.load offset=8 + local.tee 1 + local.get 1 + i32.load + i32.const 1 + i32.add + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $expand_capacity (type 1) (param i32) (result i32) + (local i32 f32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.const 16777216 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.const 4 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=8 + local.tee 0 + i32.load offset=4 + f32.convert_i32_u + local.get 0 + f32.load offset=8 + f32.mul + local.tee 2 + f32.const 0x1p+32 (;=4.29497e+09;) + f32.lt + local.get 2 + f32.const 0x0p+0 (;=0;) + f32.ge + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.trunc_f32_u + local.set 0 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + end + local.get 1 + local.get 0 + i32.store offset=4 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=8 + i32.load offset=4 + i32.le_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load offset=8 + i32.const 16777216 + i32.store offset=4 + br 1 (;@2;) + end + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=4 + i32.store offset=4 + end + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 2 + i32.shl + local.get 1 + i32.load offset=8 + i32.load offset=16 + call_indirect (type 1) + i32.store + block ;; label = @2 + local.get 1 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 1 + i32.load + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load + i32.const 2 + i32.shl + call $memcpy + drop + local.get 1 + i32.load offset=8 + i32.load offset=12 + local.get 1 + i32.load offset=8 + i32.load offset=24 + call_indirect (type 2) + local.get 1 + i32.load offset=8 + local.get 1 + i32.load + i32.store offset=12 + local.get 1 + i32.const 0 + i32.store offset=12 + end + local.get 1 + i32.load offset=12 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $array_get_at (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load + i32.ge_u + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 8 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.const 2 + i32.shl + i32.add + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12) + (func $array_get_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load + br_if 0 (;@2;) + local.get 2 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + i32.const 1 + i32.sub + local.get 2 + i32.load offset=4 + call $array_get_at + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $memcpy (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 2 + i32.store offset=20 + local.get 3 + local.get 3 + i32.load offset=28 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 3 + i32.const 0 + i32.store offset=16 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=20 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=8 + i32.load8_u + i32.store8 + local.get 3 + local.get 3 + i32.load offset=16 + i32.const 1 + i32.add + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 3 + i32.load offset=28) + (func $stack_conf_init (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $array_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $stack_new (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=28 + local.get 1 + i32.const 8 + i32.add + call $stack_conf_init + local.get 1 + i32.const 8 + i32.add + local.get 1 + i32.load offset=28 + call $stack_new_conf + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func $stack_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $array_new_conf + local.tee 1 + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 1 + br_if 0 (;@3;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + br 1 (;@2;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $stack_destroy (type 2) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $array_destroy + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=12 + call_indirect (type 2) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $stack_push (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $array_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $stack_peek (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $array_get_last + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $assert (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 2) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 4 4 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_add.wat b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_add.wat new file mode 100644 index 000000000..8c13481f3 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_add.wat @@ -0,0 +1,1609 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 1 + i32.const 1036 + call $treeset_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=4 + local.get 0 + i32.const 1024 + call 0 + i32.store + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + call $treeset_add + drop + i32.const 3 + i32.const 0 + i32.load offset=1036 + call $treeset_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $treetable_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treeset_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treeset_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 20 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $treetable_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + i32.const 1 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $treetable_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $treetable_contains_key + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $treetable_size + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_iterNext.wat b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_iterNext.wat new file mode 100644 index 000000000..a552df011 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_iterNext.wat @@ -0,0 +1,1827 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1036 + call $treeset_new + drop + local.get 0 + i32.const 1030 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1028 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=44 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 56 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 52 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 48 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 44 + i32.add + call $treeset_add + drop + local.get 0 + i32.const 0 + i32.store offset=40 + local.get 0 + i32.const 0 + i32.store offset=36 + local.get 0 + i32.const 0 + i32.store offset=32 + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1036 + call $treeset_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + call $treeset_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=56 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=40 + i32.const 1 + i32.add + i32.store offset=40 + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=52 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=36 + i32.const 1 + i32.add + i32.store offset=36 + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=48 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=32 + i32.const 1 + i32.add + i32.store offset=32 + end + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=44 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=28 + i32.const 1 + i32.add + i32.store offset=28 + end + br 0 (;@2;) + end + end + i32.const 1 + local.get 0 + i32.load offset=40 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=36 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $treetable_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treeset_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treeset_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 20 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $treetable_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + i32.const 1 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $treetable_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_iter_init (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + call $treetable_iter_init + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treeset_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_iter_next + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $get_successor_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + call $tree_min + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=12 + i32.store + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=20 + i32.eq + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + local.get 2 + i32.load + i32.load offset=12 + i32.store + br 1 (;@2;) + end + end + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $treetable_iter_init (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_min + local.set 1 + local.get 2 + i32.load offset=12 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $get_successor_node + local.set 1 + local.get 2 + i32.load offset=8 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "d\00c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_iterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_iterRemove.wat new file mode 100644 index 000000000..c74e29062 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_iterRemove.wat @@ -0,0 +1,2689 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + i32.const 1 + i32.const 1036 + call $treeset_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=36 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=32 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=36 + local.get 0 + i32.load offset=32 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 40 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 36 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 32 + i32.add + call $treeset_add + drop + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1036 + call $treeset_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 12 + i32.add + call $treeset_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=36 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 16 + i32.add + i32.const 0 + call $treeset_iter_remove + drop + end + br 0 (;@2;) + end + end + i32.const 2 + i32.const 0 + i32.load offset=1036 + call $treeset_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 36 + i32.add + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=44 + local.set 1 + local.get 0 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $treetable_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treeset_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treeset_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 20 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $treetable_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + i32.const 1 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $treetable_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $treetable_contains_key + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $treetable_size + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $treeset_iter_init (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load + call $treetable_iter_init + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treeset_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_iter_next + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $treetable_iter_remove + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $get_successor_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + call $tree_min + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=12 + i32.store + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=20 + i32.eq + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + local.get 2 + i32.load + i32.load offset=12 + i32.store + br 1 (;@2;) + end + end + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $remove_node (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $transplant + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call $transplant + br 1 (;@2;) + end + local.get 2 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $tree_min + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=20 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + br 1 (;@3;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=20 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=16 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load8_u offset=8 + i32.store8 offset=8 + end + end + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=20 + call $rebalance_after_delete + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=28 + i32.load offset=24 + call_indirect (type 1) + local.get 2 + i32.load offset=28 + local.tee 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $transplant (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12) + (func $rebalance_after_delete (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + loop ;; label = @1 + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + local.set 1 + end + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@4;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + end + br 1 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_iter_init (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_min + local.set 1 + local.get 2 + i32.load offset=12 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $get_successor_node + local.set 1 + local.get 2 + i32.load offset=8 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 6 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load offset=4 + i32.store + end + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $remove_node + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_remove.wat b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_remove.wat new file mode 100644 index 000000000..cf11f2cff --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_remove.wat @@ -0,0 +1,2389 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (type (;6;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 1 + i32.const 1036 + call $treeset_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=4 + local.get 0 + i32.const 1024 + call 0 + i32.store + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + i32.const 0 + call $treeset_remove + drop + i32.const 2 + i32.const 0 + i32.load offset=1036 + call $treeset_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $treetable_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treeset_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treeset_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 20 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $treetable_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + i32.const 1 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $treetable_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_remove (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 3 + local.get 2 + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=4 + local.get 3 + i32.load + call $treetable_remove + i32.const 6 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.const 7 + i32.store offset=12 + br 1 (;@1;) + end + local.get 3 + i32.const 0 + i32.store offset=12 + end + local.get 3 + i32.load offset=12 + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func $treeset_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $treetable_contains_key + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $treetable_size + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $treetable_remove (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $get_tree_node_by_key + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 6 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + call $remove_node + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $remove_node (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $transplant + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call $transplant + br 1 (;@2;) + end + local.get 2 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $tree_min + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=20 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + br 1 (;@3;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=20 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=16 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load8_u offset=8 + i32.store8 offset=8 + end + end + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=20 + call $rebalance_after_delete + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=28 + i32.load offset=24 + call_indirect (type 1) + local.get 2 + i32.load offset=28 + local.tee 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $transplant (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12) + (func $rebalance_after_delete (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + loop ;; label = @1 + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + local.set 1 + end + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@4;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + end + br 1 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_removeAll.wat b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_removeAll.wat new file mode 100644 index 000000000..26cb7ce5d --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_removeAll.wat @@ -0,0 +1,1714 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 1 + i32.const 1036 + call $treeset_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=4 + local.get 0 + i32.const 1024 + call 0 + i32.store + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + call $treeset_remove_all + i32.const 0 + i32.const 0 + i32.load offset=1036 + call $treeset_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 0 + call $treeset_contains + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $treetable_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treeset_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treeset_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 20 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $treetable_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + i32.const 1 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $treetable_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_remove_all (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $treetable_remove_all + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_contains (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + call $treetable_contains_key + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $treetable_size + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $treetable_remove_all (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4 + i32.store + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_size.wat b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_size.wat new file mode 100644 index 000000000..8a8ff3c1d --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treeset/treeset_test_size.wat @@ -0,0 +1,1388 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=12 + i32.const 1 + i32.const 1036 + call $treeset_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=8 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=4 + local.get 0 + i32.const 1024 + call 0 + i32.store + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=4 + local.get 0 + i32.load + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 8 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + i32.const 4 + i32.add + call $treeset_add + drop + i32.const 0 + i32.load offset=1036 + local.get 0 + call $treeset_add + drop + i32.const 3 + i32.const 0 + i32.load offset=1036 + call $treeset_size + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1032 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1032 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1032 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1032 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1032 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call $treetable_conf_init + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treeset_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treeset_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treeset_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 20 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + local.get 2 + i32.const 12 + i32.add + call $treetable_new_conf + i32.store offset=8 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + local.get 2 + i32.load offset=8 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + i32.const 1 + i32.store offset=4 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=16 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treeset_add (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + i32.load + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + call $treetable_add + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treeset_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $treetable_size + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_add (type 4) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 5) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66576)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "c\00b\00a\00") + (data (;1;) (i32.const 1032) "\10\04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_add.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_add.wat new file mode 100644 index 000000000..4a1530595 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_add.wat @@ -0,0 +1,1497 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + i32.const 1 + i32.const 1040 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=24 + i32.lt_s + i32.const 1 + i32.and + call 1 + local.get 0 + i32.load offset=24 + local.get 0 + i32.load offset=16 + i32.lt_s + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 44 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $treetable_destroy + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_get.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_get.wat new file mode 100644 index 000000000..a7f93cbc1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_get.wat @@ -0,0 +1,1591 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + i32.const 1 + i32.const 1040 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 16 + i32.add + call $treetable_get + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 12 + i32.add + call $treetable_get + drop + local.get 0 + i32.load offset=16 + local.get 0 + i32.const 30 + i32.add + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + local.get 0 + i32.load offset=12 + local.get 0 + i32.const 22 + i32.add + call $strcmp + i32.const 0 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $treetable_destroy + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $strcmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 0 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=8 + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 0 + i32.store offset=20 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 2 + i32.load offset=12 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + local.get 2 + i32.load offset=8 + i32.load8_u + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.const 1 + i32.store offset=16 + end + local.get 2 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.add + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + br 0 (;@3;) + end + end + end + local.get 2 + i32.load offset=16) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_get (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $get_tree_node_by_key + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 6 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getFirst.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getFirst.wat new file mode 100644 index 000000000..447bbed27 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getFirst.wat @@ -0,0 +1,1465 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + local.get 0 + i32.const 38 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $treetable_get_first_key + drop + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_get_first_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_min + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 6 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getGreaterThan.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getGreaterThan.wat new file mode 100644 index 000000000..02b8cf4bb --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getGreaterThan.wat @@ -0,0 +1,1713 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + local.get 0 + i32.const 38 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 8 + i32.add + call $treetable_get_greater_than + drop + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_get_greater_than (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $get_tree_node_by_key + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + call $get_successor_node + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 6 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $get_successor_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + call $tree_min + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=12 + i32.store + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=20 + i32.eq + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + local.get 2 + i32.load + i32.load offset=12 + i32.store + br 1 (;@2;) + end + end + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getLast.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getLast.wat new file mode 100644 index 000000000..0e039204e --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getLast.wat @@ -0,0 +1,1465 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + local.get 0 + i32.const 38 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 8 + i32.add + call $treetable_get_last_key + drop + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $tree_max (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_get_last_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_max + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load + i32.store + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 6 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getLessThan.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getLessThan.wat new file mode 100644 index 000000000..388947852 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_getLessThan.wat @@ -0,0 +1,1713 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + local.get 0 + i32.const 38 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 8 + i32.add + call $treetable_get_lesser_than + drop + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=8 + i32.load + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_max (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_get_lesser_than (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $get_tree_node_by_key + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + call $get_predecessor_node + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=8 + i32.load + i32.store + local.get 3 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.const 6 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $get_predecessor_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + call $tree_max + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=12 + i32.store + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=16 + i32.eq + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + local.get 2 + i32.load + i32.load offset=12 + i32.store + br 1 (;@2;) + end + end + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_iterNext.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_iterNext.wat new file mode 100644 index 000000000..855d4e926 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_iterNext.wat @@ -0,0 +1,1756 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 96 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=92 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=88 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=84 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=80 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=76 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=88 + local.get 0 + i32.load offset=84 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=84 + local.get 0 + i32.load offset=76 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=76 + local.get 0 + i32.load offset=80 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=72 + local.get 0 + local.get 0 + i32.load offset=72 + i32.store8 offset=70 + local.get 0 + i32.const 0 + i32.store8 offset=71 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=64 + local.get 0 + local.get 0 + i32.load offset=64 + i32.store8 offset=62 + local.get 0 + i32.const 0 + i32.store8 offset=63 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=56 + local.get 0 + local.get 0 + i32.load offset=56 + i32.store8 offset=54 + local.get 0 + i32.const 0 + i32.store8 offset=55 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=48 + local.get 0 + local.get 0 + i32.load offset=48 + i32.store8 offset=46 + local.get 0 + i32.const 0 + i32.store8 offset=47 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 80 + i32.add + local.get 0 + i32.const 70 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 76 + i32.add + local.get 0 + i32.const 62 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 84 + i32.add + local.get 0 + i32.const 54 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 88 + i32.add + local.get 0 + i32.const 46 + i32.add + call $treetable_add + drop + local.get 0 + i32.const 0 + i32.store offset=40 + local.get 0 + i32.const 0 + i32.store offset=36 + local.get 0 + i32.const 0 + i32.store offset=32 + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i32.const 16 + i32.add + i32.const 0 + i32.load offset=1044 + call $treetable_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.add + local.get 0 + i32.const 8 + i32.add + call $treetable_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + local.get 0 + i32.load offset=8 + i32.store offset=4 + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load offset=88 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=40 + i32.const 1 + i32.add + i32.store offset=40 + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load offset=84 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=36 + i32.const 1 + i32.add + i32.store offset=36 + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load offset=80 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=32 + i32.const 1 + i32.add + i32.store offset=32 + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + i32.load + local.get 0 + i32.load offset=76 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.load offset=28 + i32.const 1 + i32.add + i32.store offset=28 + end + br 0 (;@2;) + end + end + i32.const 1 + local.get 0 + i32.load offset=40 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=36 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=32 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 1 + local.get 0 + i32.load offset=28 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=92 + local.set 1 + local.get 0 + i32.const 96 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $get_successor_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + call $tree_min + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=12 + i32.store + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=20 + i32.eq + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + local.get 2 + i32.load + i32.load offset=12 + i32.store + br 1 (;@2;) + end + end + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $treetable_iter_init (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_min + local.set 1 + local.get 2 + i32.load offset=12 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $get_successor_node + local.set 1 + local.get 2 + i32.load offset=8 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_iterRemove.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_iterRemove.wat new file mode 100644 index 000000000..97ec51093 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_iterRemove.wat @@ -0,0 +1,2538 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 80 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=76 + i32.const 1 + i32.const 1040 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=72 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=68 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=64 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=72 + local.get 0 + i32.load offset=68 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=68 + local.get 0 + i32.load offset=64 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=60 + local.get 0 + local.get 0 + i32.load offset=60 + i32.store8 offset=58 + local.get 0 + i32.const 0 + i32.store8 offset=59 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=52 + local.get 0 + local.get 0 + i32.load offset=52 + i32.store8 offset=50 + local.get 0 + i32.const 0 + i32.store8 offset=51 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + local.get 0 + i32.load offset=44 + i32.store8 offset=42 + local.get 0 + i32.const 0 + i32.store8 offset=43 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 72 + i32.add + local.get 0 + i32.const 58 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 68 + i32.add + local.get 0 + i32.const 50 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 64 + i32.add + local.get 0 + i32.const 42 + i32.add + call $treetable_add + drop + local.get 0 + i32.const 24 + i32.add + i32.const 0 + i32.load offset=1040 + call $treetable_iter_init + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 24 + i32.add + local.get 0 + i32.const 16 + i32.add + call $treetable_iter_next + i32.const 9 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 0 + local.get 0 + i32.load offset=16 + i32.store offset=12 + block ;; label = @3 + local.get 0 + i32.load offset=12 + i32.load + local.get 0 + i32.load offset=68 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + i32.const 0 + local.get 0 + i32.const 24 + i32.add + i32.const 0 + call $treetable_iter_remove + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 6 + local.get 0 + i32.const 24 + i32.add + i32.const 0 + call $treetable_iter_remove + i32.eq + i32.const 1 + i32.and + call 2 + end + br 0 (;@2;) + end + end + i32.const 2 + i32.const 0 + i32.load offset=1040 + call $treetable_size + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 68 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $treetable_destroy + local.get 0 + i32.load offset=76 + local.set 1 + local.get 0 + i32.const 80 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $get_successor_node (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + call $tree_min + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=4 + i32.load offset=12 + i32.store + loop ;; label = @2 + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=20 + i32.eq + local.set 1 + end + block ;; label = @3 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load + i32.store offset=4 + local.get 2 + local.get 2 + i32.load + i32.load offset=12 + i32.store + br 1 (;@2;) + end + end + local.get 2 + local.get 2 + i32.load + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $remove_node (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $transplant + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call $transplant + br 1 (;@2;) + end + local.get 2 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $tree_min + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=20 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + br 1 (;@3;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=20 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=16 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load8_u offset=8 + i32.store8 offset=8 + end + end + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=20 + call $rebalance_after_delete + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=28 + i32.load offset=24 + call_indirect (type 1) + local.get 2 + i32.load offset=28 + local.tee 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $transplant (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12) + (func $rebalance_after_delete (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + loop ;; label = @1 + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + local.set 1 + end + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@4;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + end + br 1 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_iter_init (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.store + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_min + local.set 1 + local.get 2 + i32.load offset=12 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_iter_next (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 9 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load offset=4 + i32.store offset=4 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.load + i32.store + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=8 + i32.store offset=4 + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $get_successor_node + local.set 1 + local.get 2 + i32.load offset=8 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_iter_remove (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 6 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=4 + i32.load offset=4 + i32.store + end + local.get 2 + i32.load offset=8 + i32.load + local.get 2 + i32.load offset=8 + i32.load offset=4 + call $remove_node + local.get 2 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_remove.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_remove.wat new file mode 100644 index 000000000..635184ca1 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_remove.wat @@ -0,0 +1,2250 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=28 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=8 + i32.store8 offset=6 + local.get 0 + i32.const 0 + i32.store8 offset=7 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=40 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=32 + local.get 0 + i32.load offset=36 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 6 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + i32.const 0 + call $treetable_remove + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 32 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=44 + local.set 1 + local.get 0 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $treetable_remove (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=20 + call $get_tree_node_by_key + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 6 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 3 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=16 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.store + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load offset=12 + call $remove_node + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $remove_node (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $transplant + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call $transplant + br 1 (;@2;) + end + local.get 2 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $tree_min + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=20 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + br 1 (;@3;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=20 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=16 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load8_u offset=8 + i32.store8 offset=8 + end + end + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=20 + call $rebalance_after_delete + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=28 + i32.load offset=24 + call_indirect (type 1) + local.get 2 + i32.load offset=28 + local.tee 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $transplant (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12) + (func $rebalance_after_delete (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + loop ;; label = @1 + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + local.set 1 + end + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@4;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + end + br 1 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeAll.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeAll.wat new file mode 100644 index 000000000..8d2dd1335 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeAll.wat @@ -0,0 +1,1523 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store8 offset=26 + local.get 0 + i32.const 0 + i32.store8 offset=27 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store8 offset=18 + local.get 0 + i32.const 0 + i32.store8 offset=19 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=12 + local.get 0 + local.get 0 + i32.load offset=12 + i32.store8 offset=10 + local.get 0 + i32.const 0 + i32.store8 offset=11 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 26 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 18 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + local.get 0 + i32.const 10 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + call $treetable_remove_all + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 40 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 36 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.const 48 + i32.add + global.set 0 + i32.const 0) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $treetable_remove_all (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store offset=8 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=4 + i32.store + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeFirst.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeFirst.wat new file mode 100644 index 000000000..209228b29 --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeFirst.wat @@ -0,0 +1,2274 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + local.get 0 + i32.const 38 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + i32.const 0 + call $treetable_remove_first + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $remove_node (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $transplant + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call $transplant + br 1 (;@2;) + end + local.get 2 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $tree_min + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=20 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + br 1 (;@3;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=20 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=16 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load8_u offset=8 + i32.store8 offset=8 + end + end + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=20 + call $rebalance_after_delete + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=28 + i32.load offset=24 + call_indirect (type 1) + local.get 2 + i32.load offset=28 + local.tee 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $transplant (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12) + (func $rebalance_after_delete (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + loop ;; label = @1 + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + local.set 1 + end + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@4;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + end + br 1 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_remove_first (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 6 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_min + i32.store + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=4 + i32.store + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + call $remove_node + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeLast.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeLast.wat new file mode 100644 index 000000000..64bcf05ce --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_removeLast.wat @@ -0,0 +1,2315 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 64 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=60 + i32.const 1 + i32.const 1044 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=56 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=52 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=48 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=44 + local.get 0 + i32.const 1038 + call 0 + i32.store offset=40 + local.get 0 + local.get 0 + i32.load offset=40 + i32.store8 offset=38 + local.get 0 + i32.const 0 + i32.store8 offset=39 + local.get 0 + i32.const 1036 + call 0 + i32.store offset=32 + local.get 0 + local.get 0 + i32.load offset=32 + i32.store8 offset=30 + local.get 0 + i32.const 0 + i32.store8 offset=31 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=24 + i32.store8 offset=22 + local.get 0 + i32.const 0 + i32.store8 offset=23 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=16 + local.get 0 + local.get 0 + i32.load offset=16 + i32.store8 offset=14 + local.get 0 + i32.const 0 + i32.store8 offset=15 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=56 + local.get 0 + i32.load offset=52 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=52 + local.get 0 + i32.load offset=48 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=48 + local.get 0 + i32.load offset=44 + i32.lt_s + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 48 + i32.add + local.get 0 + i32.const 38 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + local.get 0 + i32.const 30 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 52 + i32.add + local.get 0 + i32.const 22 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 56 + i32.add + local.get 0 + i32.const 14 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1044 + i32.const 0 + call $treetable_remove_last + drop + i32.const 0 + i32.const 0 + i32.load offset=1044 + local.get 0 + i32.const 44 + i32.add + call $treetable_contains_key + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1044 + call $treetable_destroy + local.get 0 + i32.load offset=60 + local.set 1 + local.get 0 + i32.const 64 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1040 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1040 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1040 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1040 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1040 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $get_tree_node_by_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=8 + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + loop ;; label = @2 + local.get 2 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.load + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=16 + i32.store offset=16 + br 1 (;@3;) + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=8 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=16 + br 1 (;@4;) + end + local.get 2 + local.get 2 + i32.load offset=16 + i32.store offset=28 + br 3 (;@1;) + end + end + i32.const 0 + local.set 1 + block ;; label = @3 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.const 0 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + end + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $tree_min (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $tree_max (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + local.get 2 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=8) + (func $treetable_contains_key (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + call $get_tree_node_by_key + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $remove_node (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + local.get 2 + i32.load offset=24 + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $transplant + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=24 + i32.load offset=20 + local.get 2 + i32.load offset=28 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=20 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=24 + i32.load offset=16 + call $transplant + br 1 (;@2;) + end + local.get 2 + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + i32.load offset=20 + call $tree_min + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.store offset=12 + local.get 2 + local.get 2 + i32.load offset=16 + i32.load offset=20 + i32.store offset=20 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=16 + i32.load offset=12 + local.get 2 + i32.load offset=24 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + br 1 (;@3;) + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=20 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=20 + i32.store offset=20 + local.get 2 + i32.load offset=16 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store offset=12 + end + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=16 + call $transplant + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=16 + i32.store offset=16 + local.get 2 + i32.load offset=16 + i32.load offset=16 + local.get 2 + i32.load offset=16 + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load8_u offset=8 + i32.store8 offset=8 + end + end + block ;; label = @1 + local.get 2 + i32.load offset=12 + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=28 + local.get 2 + i32.load offset=20 + call $rebalance_after_delete + end + local.get 2 + i32.load offset=24 + local.get 2 + i32.load offset=28 + i32.load offset=24 + call_indirect (type 1) + local.get 2 + i32.load offset=28 + local.tee 1 + local.get 1 + i32.load offset=8 + i32.const -1 + i32.add + i32.store offset=8 + local.get 2 + i32.const 32 + i32.add + global.set 0) + (func $transplant (type 6) (param i32 i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 2 + i32.store offset=4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 3 + i32.load offset=8 + i32.load offset=12 + local.get 3 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 3 + i32.load offset=4 + local.get 3 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12) + (func $rebalance_after_delete (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + loop ;; label = @1 + i32.const 0 + local.set 1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=8 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + local.set 1 + end + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@4;) + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 1 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + call $rotate_left + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + call $rotate_right + local.get 2 + local.get 2 + i32.load offset=12 + i32.load + i32.store offset=8 + end + end + br 1 (;@1;) + end + end + local.get 2 + i32.load offset=8 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_remove_last (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=8 + local.get 2 + local.get 1 + i32.store offset=4 + local.get 2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load + call $tree_max + i32.store + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 6 + i32.store offset=12 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=4 + i32.const 0 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=4 + local.get 2 + i32.load + i32.load offset=4 + i32.store + end + local.get 2 + i32.load offset=8 + local.get 2 + i32.load + call $remove_node + local.get 2 + i32.const 0 + i32.store offset=12 + end + local.get 2 + i32.load offset=12 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00w\00d\00c\00b\00a\00") + (data (;1;) (i32.const 1040) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_size.wat b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_size.wat new file mode 100644 index 000000000..9b18c1e5f --- /dev/null +++ b/benchmarks/pldi2026/Collection-C-normal/treetable/treetable_test_size.wat @@ -0,0 +1,1349 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (result i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func (param i32 i32 i32) (result i32))) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (import "mem" "alloc" (func (;4;) (type 0))) + (import "mem" "free" (func (;5;) (type 2))) + (func $__original_main (type 3) (result i32) + (local i32 i32) + global.get 0 + i32.const 48 + i32.sub + local.tee 0 + global.set 0 + local.get 0 + i32.const 0 + i32.store offset=44 + i32.const 1 + i32.const 1040 + call $treetable_new + drop + local.get 0 + i32.const 1028 + call 0 + i32.store offset=40 + local.get 0 + i32.const 1026 + call 0 + i32.store offset=36 + local.get 0 + i32.const 1024 + call 0 + i32.store offset=32 + local.get 0 + i32.const 1034 + call 0 + i32.store offset=28 + local.get 0 + local.get 0 + i32.load offset=28 + i32.store8 offset=26 + local.get 0 + i32.const 0 + i32.store8 offset=27 + local.get 0 + i32.const 1032 + call 0 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=20 + i32.store8 offset=18 + local.get 0 + i32.const 0 + i32.store8 offset=19 + local.get 0 + i32.const 1030 + call 0 + i32.store offset=12 + local.get 0 + local.get 0 + i32.load offset=12 + i32.store8 offset=10 + local.get 0 + i32.const 0 + i32.store8 offset=11 + i32.const 0 + local.set 1 + block ;; label = @1 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=36 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + i32.const 0 + local.set 1 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=32 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=36 + local.get 0 + i32.load offset=32 + i32.ne + local.set 1 + end + local.get 1 + i32.const 1 + i32.and + call 1 + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 40 + i32.add + local.get 0 + i32.const 26 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 36 + i32.add + local.get 0 + i32.const 18 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + local.get 0 + i32.const 32 + i32.add + local.get 0 + i32.const 10 + i32.add + call $treetable_add + drop + i32.const 0 + i32.load offset=1040 + call $treetable_size + i32.const 3 + i32.eq + i32.const 1 + i32.and + call 2 + i32.const 0 + i32.load offset=1040 + call $treetable_destroy + local.get 0 + i32.load offset=44 + local.set 1 + local.get 0 + i32.const 48 + i32.add + global.set 0 + local.get 1) + (func $malloc (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 0 + i32.load offset=1036 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=4 + block ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=4 + i32.add + i32.const 105 + i32.store8 + local.get 1 + local.get 1 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 1 + i32.load offset=12 + i32.add + i32.store offset=1036 + local.get 1 + i32.load offset=8 + local.get 1 + i32.load offset=12 + call 4 + local.set 0 + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func $calloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.const 0 + i32.load offset=1036 + i32.store offset=4 + local.get 2 + i32.const 0 + i32.store + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.lt_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load + i32.add + i32.const 0 + i32.store8 + local.get 2 + local.get 2 + i32.load + i32.const 1 + i32.add + i32.store + br 0 (;@2;) + end + end + i32.const 0 + i32.const 0 + i32.load offset=1036 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + i32.add + i32.store offset=1036 + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.mul + call 4 + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 1) + (func $free (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + call 5 + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $treetable_conf_init (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 2 + i32.store offset=4 + local.get 1 + i32.load offset=12 + i32.const 3 + i32.store offset=8 + local.get 1 + i32.load offset=12 + i32.const 4 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.const 0 + i32.store) + (func $treetable_new (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=28 + local.get 2 + local.get 1 + i32.store offset=24 + local.get 2 + i32.const 8 + i32.add + call $treetable_conf_init + local.get 2 + local.get 2 + i32.load offset=28 + i32.store offset=8 + local.get 2 + i32.const 8 + i32.add + local.get 2 + i32.load offset=24 + call $treetable_new_conf + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_new_conf (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + i32.const 1 + i32.const 28 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=16 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.const 24 + local.get 2 + i32.load offset=24 + i32.load offset=8 + call_indirect (type 0) + i32.store offset=12 + block ;; label = @2 + local.get 2 + i32.load offset=12 + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 1) + local.get 2 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=16 + i32.const 0 + i32.store offset=8 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=12 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=24 + i32.load offset=12 + i32.store offset=24 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.store offset=4 + local.get 2 + i32.load offset=20 + local.get 2 + i32.load offset=16 + i32.store + local.get 2 + i32.const 0 + i32.store offset=28 + end + local.get 2 + i32.load offset=28 + local.set 1 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 1) + (func $treetable_destroy (type 1) (param i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load + call $tree_destroy + local.get 1 + i32.load offset=12 + i32.load offset=4 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.load offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + local.get 1 + i32.const 16 + i32.add + global.set 0) + (func $tree_destroy (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + br 1 (;@1;) + end + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=16 + call $tree_destroy + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=20 + call $tree_destroy + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=12 + i32.load offset=24 + call_indirect (type 1) + end + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $treetable_size (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12 + i32.load offset=8) + (func $treetable_add (type 5) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 2 + i32.store offset=16 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=12 + local.get 3 + local.get 3 + i32.load offset=24 + i32.load + i32.store offset=8 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 3 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=8 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.store offset=4 + local.get 3 + local.get 3 + i32.load offset=8 + i32.store offset=12 + block ;; label = @4 + block ;; label = @5 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=16 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.load offset=4 + i32.const 0 + i32.gt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 3 + local.get 3 + i32.load offset=8 + i32.load offset=20 + i32.store offset=8 + br 1 (;@5;) + end + local.get 3 + i32.load offset=8 + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.const 0 + i32.store offset=28 + br 4 (;@1;) + end + end + br 0 (;@3;) + end + end + local.get 3 + i32.const 24 + local.get 3 + i32.load offset=24 + i32.load offset=16 + call_indirect (type 2) + i32.store + block ;; label = @2 + local.get 3 + i32.load + i32.const 0 + i32.ne + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 3 + i32.const 1 + i32.store offset=28 + br 1 (;@1;) + end + local.get 3 + i32.load + local.get 3 + i32.load offset=16 + i32.store offset=4 + local.get 3 + i32.load + local.get 3 + i32.load offset=20 + i32.store + local.get 3 + i32.load + local.get 3 + i32.load offset=12 + i32.store offset=12 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=16 + local.get 3 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.store offset=20 + local.get 3 + i32.load offset=24 + local.tee 2 + local.get 2 + i32.load offset=8 + i32.const 1 + i32.add + i32.store offset=8 + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load offset=12 + local.get 3 + i32.load offset=24 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + i32.store + local.get 3 + i32.load + i32.const 1 + i32.store8 offset=8 + br 1 (;@2;) + end + local.get 3 + i32.load + i32.const 0 + i32.store8 offset=8 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.load offset=20 + local.get 3 + i32.load offset=12 + i32.load + local.get 3 + i32.load offset=24 + i32.load offset=12 + call_indirect (type 0) + i32.const 0 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=16 + br 1 (;@3;) + end + local.get 3 + i32.load offset=12 + local.get 3 + i32.load + i32.store offset=20 + end + local.get 3 + i32.load offset=24 + local.get 3 + i32.load + call $rebalance_after_insert + end + local.get 3 + i32.const 0 + i32.store offset=28 + end + local.get 3 + i32.load offset=28 + local.set 2 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func $rebalance_after_insert (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 1 (;@1;) + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=20 + i32.store offset=4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@6;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@6;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_left + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_right + end + br 1 (;@3;) + end + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.load offset=16 + i32.store offset=4 + block ;; label = @4 + block ;; label = @5 + local.get 2 + i32.load offset=4 + i32.load8_u offset=8 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + br_if 0 (;@5;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=4 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@5;) + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + call $rotate_right + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + i32.const 0 + i32.store8 offset=8 + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=12 + call $rotate_left + end + end + br 0 (;@2;) + end + end + local.get 2 + i32.load offset=12 + i32.load + i32.const 1 + i32.store8 offset=8 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func $rotate_left (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=20 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=16 + i32.store offset=20 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=16 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=16 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=16 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $rotate_right (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + local.get 2 + i32.load offset=8 + i32.load offset=16 + i32.store offset=4 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.load offset=20 + i32.store offset=16 + block ;; label = @1 + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.ne + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load offset=4 + i32.load offset=20 + local.get 2 + i32.load offset=8 + i32.store offset=12 + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=12 + i32.load offset=4 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=8 + i32.load offset=12 + i32.load offset=20 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=20 + br 1 (;@2;) + end + local.get 2 + i32.load offset=8 + i32.load offset=12 + local.get 2 + i32.load offset=4 + i32.store offset=16 + end + end + local.get 2 + i32.load offset=4 + local.get 2 + i32.load offset=8 + i32.store offset=20 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + i32.store offset=12) + (func $cmp (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=24 + local.get 2 + local.get 1 + i32.store offset=20 + local.get 2 + local.get 2 + i32.load offset=24 + i32.load + i32.store offset=16 + local.get 2 + local.get 2 + i32.load offset=20 + i32.load + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.lt_s + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const -1 + i32.store offset=28 + br 1 (;@1;) + end + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.get 2 + i32.load offset=12 + i32.eq + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 0 + i32.store offset=28 + br 1 (;@1;) + end + local.get 2 + i32.const 1 + i32.store offset=28 + end + local.get 2 + i32.load offset=28) + (func $assume (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $assert (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $alloc (type 0) (param i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + local.get 0 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 2 + i32.load offset=12) + (func $dealloc (type 1) (param i32) + global.get 0 + i32.const 16 + i32.sub + local.get 0 + i32.store offset=12) + (func $sym_int (type 2) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.load offset=12) + (table (;0;) 5 5 funcref) + (memory (;0;) 2) + (global (;0;) (mut i32) (i32.const 66592)) + (export "memory" (memory 0)) + (export "__original_main" (func $__original_main)) + (elem (;0;) (i32.const 1) $cmp $malloc $calloc $free) + (data (;0;) (i32.const 1024) "z\00y\00x\00c\00b\00a\00") + (data (;1;) (i32.const 1036) " \04\01\00")) \ No newline at end of file diff --git a/benchmarks/pldi2026/btree/2o1u.wat b/benchmarks/pldi2026/btree/2o1u.wat new file mode 100644 index 000000000..99f628164 --- /dev/null +++ b/benchmarks/pldi2026/btree/2o1u.wat @@ -0,0 +1,2655 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.and + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00h\00")) diff --git a/benchmarks/pldi2026/btree/2o2u.wat b/benchmarks/pldi2026/btree/2o2u.wat new file mode 100644 index 000000000..9922fcc42 --- /dev/null +++ b/benchmarks/pldi2026/btree/2o2u.wat @@ -0,0 +1,2696 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.and + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00h\00i\00")) diff --git a/benchmarks/pldi2026/btree/3o1u.wat b/benchmarks/pldi2026/btree/3o1u.wat new file mode 100644 index 000000000..5f8232df6 --- /dev/null +++ b/benchmarks/pldi2026/btree/3o1u.wat @@ -0,0 +1,2702 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/3o2u.wat b/benchmarks/pldi2026/btree/3o2u.wat new file mode 100644 index 000000000..ec97e5903 --- /dev/null +++ b/benchmarks/pldi2026/btree/3o2u.wat @@ -0,0 +1,2749 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/3o3u.wat b/benchmarks/pldi2026/btree/3o3u.wat new file mode 100644 index 000000000..60d0483be --- /dev/null +++ b/benchmarks/pldi2026/btree/3o3u.wat @@ -0,0 +1,2802 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/4o1u.wat b/benchmarks/pldi2026/btree/4o1u.wat new file mode 100644 index 000000000..6dfc71a31 --- /dev/null +++ b/benchmarks/pldi2026/btree/4o1u.wat @@ -0,0 +1,2755 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/4o2u.wat b/benchmarks/pldi2026/btree/4o2u.wat new file mode 100644 index 000000000..4beac7a48 --- /dev/null +++ b/benchmarks/pldi2026/btree/4o2u.wat @@ -0,0 +1,2808 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/4o3u.wat b/benchmarks/pldi2026/btree/4o3u.wat new file mode 100644 index 000000000..1fac09846 --- /dev/null +++ b/benchmarks/pldi2026/btree/4o3u.wat @@ -0,0 +1,2867 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/5o1u.wat b/benchmarks/pldi2026/btree/5o1u.wat new file mode 100644 index 000000000..1ef41296a --- /dev/null +++ b/benchmarks/pldi2026/btree/5o1u.wat @@ -0,0 +1,2814 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/5o2u.wat b/benchmarks/pldi2026/btree/5o2u.wat new file mode 100644 index 000000000..432244e36 --- /dev/null +++ b/benchmarks/pldi2026/btree/5o2u.wat @@ -0,0 +1,2873 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/5o3u.wat b/benchmarks/pldi2026/btree/5o3u.wat new file mode 100644 index 000000000..058891947 --- /dev/null +++ b/benchmarks/pldi2026/btree/5o3u.wat @@ -0,0 +1,2938 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/6o1u.wat b/benchmarks/pldi2026/btree/6o1u.wat new file mode 100644 index 000000000..7302e3507 --- /dev/null +++ b/benchmarks/pldi2026/btree/6o1u.wat @@ -0,0 +1,2879 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/6o2u.wat b/benchmarks/pldi2026/btree/6o2u.wat new file mode 100644 index 000000000..8c22aa9c1 --- /dev/null +++ b/benchmarks/pldi2026/btree/6o2u.wat @@ -0,0 +1,2944 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/6o3u.wat b/benchmarks/pldi2026/btree/6o3u.wat new file mode 100644 index 000000000..ee7d08bb5 --- /dev/null +++ b/benchmarks/pldi2026/btree/6o3u.wat @@ -0,0 +1,3015 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1038 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + i32.const 1040 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1040 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1038 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/7o1u.wat b/benchmarks/pldi2026/btree/7o1u.wat new file mode 100644 index 000000000..576560feb --- /dev/null +++ b/benchmarks/pldi2026/btree/7o1u.wat @@ -0,0 +1,2950 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.const 1034 + call 0 + i32.const 1036 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/7o2u.wat b/benchmarks/pldi2026/btree/7o2u.wat new file mode 100644 index 000000000..d8c85450a --- /dev/null +++ b/benchmarks/pldi2026/btree/7o2u.wat @@ -0,0 +1,3021 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.const 1034 + call 0 + i32.const 1036 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1038 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + i32.const 1040 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1040 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1038 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/7o3u.wat b/benchmarks/pldi2026/btree/7o3u.wat new file mode 100644 index 000000000..0f7fd87aa --- /dev/null +++ b/benchmarks/pldi2026/btree/7o3u.wat @@ -0,0 +1,3098 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.const 1034 + call 0 + i32.const 1036 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1038 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1038 + call 0 + i32.ne + i32.const 1042 + call 0 + i32.const 1040 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + i32.const 1040 + call 0 + call 8 + local.set 0 + i32.const 1042 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1040 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1042 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1038 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1040 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1040 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00")) diff --git a/benchmarks/pldi2026/btree/8o1u.wat b/benchmarks/pldi2026/btree/8o1u.wat new file mode 100644 index 000000000..9f76c0a17 --- /dev/null +++ b/benchmarks/pldi2026/btree/8o1u.wat @@ -0,0 +1,3027 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.const 1034 + call 0 + i32.const 1036 + call 0 + i32.gt_s + i32.const 1036 + call 0 + i32.const 1044 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1044 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1044 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1044 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1044 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1044 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00")) diff --git a/benchmarks/pldi2026/btree/9o1u.wat b/benchmarks/pldi2026/btree/9o1u.wat new file mode 100644 index 000000000..8686ccde9 --- /dev/null +++ b/benchmarks/pldi2026/btree/9o1u.wat @@ -0,0 +1,3110 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1044 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.const 1034 + call 0 + i32.const 1036 + call 0 + i32.gt_s + i32.const 1036 + call 0 + i32.const 1044 + call 0 + i32.gt_s + i32.const 1044 + call 0 + i32.const 1046 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1044 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1046 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1044 + call 0 + call 8 + local.set 0 + i32.const 1046 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1044 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1046 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1044 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1044 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1046 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1046 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00y\00")) diff --git a/benchmarks/pldi2026/btree/9o2u.wat b/benchmarks/pldi2026/btree/9o2u.wat new file mode 100644 index 000000000..fff6815d5 --- /dev/null +++ b/benchmarks/pldi2026/btree/9o2u.wat @@ -0,0 +1,3193 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32 i32))) + (type (;4;) (func)) + (import "i32" "symbolic" (func (;0;) (type 0))) + (import "i32" "sym_assume" (func (;1;) (type 1))) + (import "i32" "sym_assert" (func (;2;) (type 1))) + (import "sym" "get_sym_int32" (func (;3;) (type 0))) + (func (;4;) (type 0) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.const 1 + i32.store offset=4 + i32.const 0 + i32.const 65536 + i32.store offset=8 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 65536 + i32.const 1 + i32.store + i32.const 65536 + i32.const 0 + i32.store offset=4 + end + i32.const 65536) + (func (;5;) (type 2) (param i32 i32) (result i32) + (local i32) + i32.const 0 + local.set 2 + block ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if ;; label = @3 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @4 + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 2 (;@2;) + else + br 3 (;@1;) + end + else + br 2 (;@1;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @1 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.eq + if (result i32) ;; label = @2 + local.get 0 + i32.const 8 + i32.add + i32.const 4 + local.get 2 + i32.mul + i32.add + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @3 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end + else + local.get 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; label = @2 + i32.const -1 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 5 + end + end) + (func (;6;) (type 3) (param i32 i32) + (local i32 i32) + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if ;; label = @1 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 2 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + i32.const 1 + i32.store + else + local.get 2 + i32.const 0 + i32.store + end + local.get 2 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 2 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + local.set 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load + i32.const 1 + i32.ne + if ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.eq + if ;; label = @5 + br 2 (;@3;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 2 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.add + i32.const 4 + i32.mul + i32.add + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@4;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.load offset=4 + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + local.get 2 + i32.store offset=8 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @2 + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + local.get 0 + i32.add + local.get 3 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@3;) + end + end + end + local.get 1 + i32.const 4 + i32.mul + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 1 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + end) + (func (;7;) (type 3) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + else + i32.const 0 + end + local.get 2 + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.add + i32.mul + i32.add + local.get 1 + i32.store offset=8 + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + else + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const 0 + i32.ge_s + if ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.lt_s + if ;; label = @5 + local.get 2 + i32.const 1 + i32.sub + local.set 2 + br 2 (;@3;) + else + br 3 (;@2;) + end + else + br 2 (;@2;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if ;; label = @2 + local.get 0 + local.get 2 + call 6 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + if ;; label = @3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 7 + end) + (func (;8;) (type 0) (param i32) (result i32) + (local i32 i32) + i32.const 0 + i32.load offset=8 + local.tee 2 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.eq + if (result i32) ;; label = @1 + i32.const 1 + memory.grow + i32.const -1 + i32.ne + if (result i32) ;; label = @2 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 65536 + i32.mul + local.set 1 + i32.const 0 + i32.const 0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 0 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store + local.get 1 + i32.const 0 + i32.store offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 1 + i32.add + local.get 2 + i32.store offset=8 + local.get 1 + i32.const 0 + call 6 + local.get 1 + local.get 0 + call 7 + local.get 1 + else + i32.const -1 + end + else + local.get 2 + local.get 0 + call 7 + local.get 2 + end) + (func (;9;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 0 + i32.load + i32.const 1 + i32.eq + if ;; label = @1 + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load offset=4 + local.get 2 + i32.eq + if ;; label = @4 + br 2 (;@2;) + else + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + if ;; label = @5 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + br 3 (;@2;) + end + end + i32.const 1 + local.get 2 + i32.add + local.set 2 + br 0 (;@3;) + end + end + else + i32.const 0 + local.set 2 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + if (result i32) ;; label = @4 + local.get 1 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.gt_s + else + i32.const 0 + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.le_s + i32.and + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + br 1 (;@3;) + else + br 2 (;@2;) + end + end + end + local.get 2 + local.get 0 + i32.load offset=4 + i32.lt_s + if (result i32) ;; label = @2 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + local.get 1 + i32.eq + else + i32.const 0 + end + if ;; label = @2 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @3 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.tee 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + local.get 5 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + call 9 + drop + i32.store offset=8 + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 1 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @5 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + end + local.get 2 + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @5 + loop ;; label = @6 + local.get 0 + i32.load offset=4 + local.get 3 + i32.eq + if ;; label = @7 + br 2 (;@5;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@6;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 5 + local.get 1 + call 9 + drop + end + end + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.set 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.eq + if ;; label = @3 + i32.const -1 + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.const 4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 1 + i32.sub + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + local.get 5 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.store offset=4 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 2 + i32.div_s + i32.ge_s + if ;; label = @5 + local.get 5 + i32.load offset=4 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.sub + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + local.get 5 + i32.const 4 + i32.const 0 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + local.set 4 + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.get 0 + i32.load offset=4 + i32.le_s + if ;; label = @5 + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 5 + i32.const 4 + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 5 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + local.get 5 + local.get 5 + i32.load offset=4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + i32.const 1 + i32.add + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + i32.const 0 + local.set 4 + end + local.get 4 + i32.const -1 + i32.eq + local.get 2 + i32.const 1 + i32.sub + i32.const 0 + i32.ge_s + i32.and + if ;; label = @5 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 2 + i32.const 1 + i32.sub + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + i32.const 0 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 5 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 4 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.mul + i32.add + local.get 5 + i32.const 4 + local.get 3 + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 5 + i32.load + i32.const 1 + i32.ne + if ;; label = @6 + i32.const 0 + local.set 3 + block ;; label = @7 + loop ;; label = @8 + local.get 3 + local.get 5 + i32.load offset=4 + i32.const 1 + i32.add + i32.eq + if ;; label = @9 + br 2 (;@7;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 3 + i32.add + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 5 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@8;) + end + end + end + end + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.load offset=4 + local.get 5 + i32.load offset=4 + i32.add + i32.const 1 + i32.add + i32.store offset=4 + local.get 2 + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 3 + i32.const 1 + i32.add + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 2 + i32.const 1 + i32.sub + local.set 3 + block ;; label = @6 + loop ;; label = @7 + local.get 3 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.eq + if ;; label = @8 + br 2 (;@6;) + else + local.get 0 + i32.const 4 + local.get 3 + i32.mul + i32.add + local.get 0 + i32.const 4 + local.get 3 + i32.const 1 + i32.add + i32.mul + i32.add + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.const 1 + i32.add + local.set 3 + br 1 (;@7;) + end + end + end + local.get 0 + local.get 0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + end + end + end + local.get 4 + i32.const -1 + i32.eq + if ;; label = @3 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + local.get 2 + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.add + local.get 0 + i32.add + i32.load offset=8 + local.get 1 + call 9 + drop + else + local.get 5 + local.get 1 + call 9 + drop + end + end + end + i32.const 0 + i32.load offset=8 + i32.load offset=4 + i32.const 0 + i32.eq + if ;; label = @1 + i32.const 0 + i32.const 0 + i32.load + i32.const 1 + i32.sub + i32.const 4 + i32.mul + i32.const 0 + i32.const 4 + i32.mul + i32.add + i32.const 0 + i32.load offset=8 + i32.add + i32.load offset=8 + i32.store offset=8 + end + i32.const 0 + i32.load offset=8) + (func (;10;) (type 4) + (local i32) + i32.const 4 + call 4 + local.set 0 + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1028 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1030 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1032 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1034 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1036 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1044 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1046 + call 0 + i32.const 1044 + call 0 + i32.ne + i32.const 1024 + call 0 + i32.const 1026 + call 0 + i32.gt_s + i32.const 1026 + call 0 + i32.const 1028 + call 0 + i32.gt_s + i32.const 1028 + call 0 + i32.const 1030 + call 0 + i32.gt_s + i32.const 1030 + call 0 + i32.const 1032 + call 0 + i32.gt_s + i32.const 1032 + call 0 + i32.const 1034 + call 0 + i32.gt_s + i32.const 1034 + call 0 + i32.const 1036 + call 0 + i32.gt_s + i32.const 1036 + call 0 + i32.const 1044 + call 0 + i32.gt_s + i32.const 1044 + call 0 + i32.const 1046 + call 0 + i32.gt_s + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.const 1038 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1044 + call 0 + i32.ne + i32.const 1038 + call 0 + i32.const 1046 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1024 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1026 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1028 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1030 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1032 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1034 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1036 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1044 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1046 + call 0 + i32.ne + i32.const 1040 + call 0 + i32.const 1038 + call 0 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 1 + i32.const 1024 + call 0 + call 8 + local.set 0 + i32.const 1026 + call 0 + call 8 + local.set 0 + i32.const 1028 + call 0 + call 8 + local.set 0 + i32.const 1030 + call 0 + call 8 + local.set 0 + i32.const 1032 + call 0 + call 8 + local.set 0 + i32.const 1034 + call 0 + call 8 + local.set 0 + i32.const 1036 + call 0 + call 8 + local.set 0 + i32.const 1044 + call 0 + call 8 + local.set 0 + i32.const 1046 + call 0 + call 8 + local.set 0 + i32.const 1038 + call 0 + call 8 + local.set 0 + i32.const 1040 + call 0 + call 8 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1044 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1046 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.ne + local.get 0 + i32.const 1040 + call 0 + call 5 + i32.const -1 + i32.ne + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2 + local.get 0 + i32.const 1024 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1024 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1026 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1026 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1028 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1028 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1030 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1030 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1032 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1032 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1034 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1034 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1036 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1036 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1044 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1044 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1046 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1046 + call 0 + call 5 + i32.const -1 + i32.eq + local.get 0 + i32.const 1038 + call 0 + call 9 + local.set 0 + local.get 0 + i32.const 1038 + call 0 + call 5 + i32.const -1 + i32.eq + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + i32.and + call 2) + (memory (;0;) 1) + (export "main" (func 10)) + (data (;0;) (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00y\00")) diff --git a/benchmarks/pldi2026/btree/BTree.wast b/benchmarks/pldi2026/btree/BTree.wast new file mode 100644 index 000000000..2fd206034 --- /dev/null +++ b/benchmarks/pldi2026/btree/BTree.wast @@ -0,0 +1,4080 @@ +(module + (import "i32" "symbolic" (func $i32.symbolic (param i32) (result i32))) + + (import "i32" "sym_assume" (func $i32.sym_assume (param i32))) + + (import "i32" "sym_assert" (func $i32.sym_assert (param i32))) + + (import "sym" "get_sym_int32" (func $get_sym_int32 (param i32) (result i32))) + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (sym_int32 "a") + (sym_int32 "b") + (i32.ne) + + (;);;c + (sym_int32 "c") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne);) + + (;);;d + (sym_int32 "d") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne);) + + (;;;e + (sym_int32 "e") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne);) + + (;);; f + (sym_int32 "f") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (sym_int32 "g") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; z + (sym_int32 "z") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "g") + (i32.ne);) + + + + ;; logical order: a>b>c>d>e>f>g>z + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (;(get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s);) + + (;(get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s);) + + (;(get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s);) + + (;(get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + (get_sym_int32 "g") + (get_sym_int32 "z") + (i32.gt_s);) + + + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (sym_int32 "h") + (sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (;(get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne);) + + (;(get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne);) + + (;(get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne);) + + (;(get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "z") + (i32.ne);) + + + + ;; i + (sym_int32 "i") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (;(get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne);) + + (;(get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne);) + + (;(get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne);) + + (;(get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "z") + (i32.ne);) + + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + ;; j + (sym_int32 "j") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (;(get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne);) + + (;(get_sym_int32 "j") + (get_sym_int32 "d") + (i32.ne);) + + (;(get_sym_int32 "j") + (get_sym_int32 "e") + (i32.ne);) + + (;(get_sym_int32 "j") + (get_sym_int32 "f") + (i32.ne) + + (;(get_sym_int32 "j") + (get_sym_int32 "g") + (i32.ne););) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (call $i32.sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (;(get_sym_int32 "c") + (call $btreeInsert) + (local.set 0);) + (;(get_sym_int32 "d") + (call $btreeInsert) + (local.set 0);) + (;(get_sym_int32 "e") + (call $btreeInsert) + (local.set 0);) + (;(get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "z") + (call $btreeInsert) + (local.set 0);) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + ;; (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (;(local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + (;(local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + (;(local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + (;(local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "z") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (call $i32.sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (;);; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + (;);; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + ;; e + (;(local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + (;);; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; z + (local.get 0) + (get_sym_int32 "z") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "z") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + ;; (print_btree) + + (i32.and) + (i32.and) + (i32.and) + + (call $i32.sym_assert) + + + + ) + (export "main" (func $main)) + +) +(invoke "main") diff --git a/benchmarks/pldi2026/btree/collect_result.py b/benchmarks/pldi2026/btree/collect_result.py new file mode 100644 index 000000000..3babd7354 --- /dev/null +++ b/benchmarks/pldi2026/btree/collect_result.py @@ -0,0 +1,132 @@ +import csv +from dataclasses import dataclass +import json +from pathlib import Path + + +@dataclass +class BenchmarkResult: + instr_time: float + solver_time: float + resuming_time: float + total_time: float + total_no_solver_time: float + cost_model_time: float + path_count: int + + +def read_json_output(file_path) -> BenchmarkResult: + with open(file_path, "r") as f: + data = json.load(f) + instr_time = data.get("profile_summary").get("total_time_instruction_execution_s") + solver_time = data.get("profile_summary").get("total_time_solver_s") + resuming_time = data.get("profile_summary").get( + "total_time_resuming_from_snapshot_s" + ) + cost_model_time = data.get("profile_summary").get( + "total_time_counting_symbolic_size_s" + ) + path_count = data.get("finished_count") + return BenchmarkResult( + instr_time=instr_time, + solver_time=solver_time, + resuming_time=resuming_time, + total_time=instr_time + solver_time + resuming_time + cost_model_time, + total_no_solver_time=resuming_time + instr_time, + cost_model_time=cost_model_time, + path_count=path_count, + ) + + +def read_json_output_for_dir(directory_path) -> dict[str, BenchmarkResult]: + result = dict() + for json_file in directory_path.glob("**/*.json"): + parent_dir = json_file.parent + benchmark_name = parent_dir.name.split(".")[0] + benchmark_result = read_json_output(json_file) + result[benchmark_name] = benchmark_result + return result + + +def entry(): + current_dir = Path(__file__).parent + NoConfig_dir = current_dir / "NoConfig" + Snapshot_dir = current_dir / "Snapshot" + no_config_result = read_json_output_for_dir(NoConfig_dir) + snapshot_result = read_json_output_for_dir(Snapshot_dir) + all_configs = set(no_config_result.keys()).union(set(snapshot_result.keys())) + output_csv = current_dir / "benchmark_results.csv" + with open(output_csv, "w", newline="") as csvfile: + fieldnames = [ + "Benchmark", + "NoConfig_InstrTime(s)", + "NoConfig_SolverTime(s)", + "NoConfig_ResumingTime(s)", + "NoConfig_CostModelTime(s)", + "NoConfig_TotalTime(s)", + "NoConfig_PathCount", + "Snapshot_InstrTime(s)", + "Snapshot_NoSolverTime(s)", + "Snapshot_SolverTime(s)", + "Snapshot_ResumingTime(s)", + "Snapshot_CostModelTime(s)", + "Snapshot_TotalTime(s)", + "Snapshot_PathCount", + ] + writer = csv.DictWriter(csvfile, fieldnames=fieldnames) + writer.writeheader() + for benchmark in sorted(all_configs): + no_config = no_config_result.get(benchmark) + snapshot = snapshot_result.get(benchmark) + row = {"Benchmark": benchmark} + if no_config: + row.update( + { + "NoConfig_InstrTime(s)": no_config.instr_time, + "NoConfig_SolverTime(s)": no_config.solver_time, + "NoConfig_ResumingTime(s)": no_config.resuming_time, + "NoConfig_CostModelTime(s)": no_config.cost_model_time, + "NoConfig_TotalTime(s)": no_config.total_time, + "NoConfig_PathCount": no_config.path_count, + } + ) + else: + row.update( + { + "NoConfig_InstrTime(s)": "x", + "NoConfig_SolverTime(s)": "x", + "NoConfig_ResumingTime(s)": "x", + "NoConfig_CostModelTime(s)": "x", + "NoConfig_TotalTime(s)": "x", + "NoConfig_PathCount": "x", + } + ) + if snapshot: + row.update( + { + "Snapshot_InstrTime(s)": snapshot.instr_time, + "Snapshot_NoSolverTime(s)": snapshot.total_no_solver_time, + "Snapshot_SolverTime(s)": snapshot.solver_time, + "Snapshot_ResumingTime(s)": snapshot.resuming_time, + "Snapshot_CostModelTime(s)": snapshot.cost_model_time, + "Snapshot_TotalTime(s)": snapshot.total_time, + "Snapshot_PathCount": snapshot.path_count, + } + ) + else: + row.update( + { + "Snapshot_InstrTime(s)": "x", + "Snapshot_NoSolverTime(s)": "x", + "Snapshot_SolverTime(s)": "x", + "Snapshot_ResumingTime(s)": "x", + "Snapshot_CostModelTime(s)": "x", + "Snapshot_TotalTime(s)": "x", + "Snapshot_PathCount": "x", + } + ) + writer.writerow(row) + + +if __name__ == "__main__": + entry() diff --git a/benchmarks/pldi2026/btree/compile.py b/benchmarks/pldi2026/btree/compile.py new file mode 100644 index 000000000..f31540b2b --- /dev/null +++ b/benchmarks/pldi2026/btree/compile.py @@ -0,0 +1,121 @@ +import sys +import subprocess +from pathlib import Path + +#!/usr/bin/env python3 + +# Compile all .cpp files in this script's directory into executables with the same stem. +# Usage: python compile.py [extra g++ flags...] + +HERE = Path(__file__).resolve().parent +CPP_FILES = sorted(HERE.glob("*.cpp")) + +if not CPP_FILES: + print(f"No .cpp files found in {HERE}") + sys.exit(0) + +BASE_FLAGS = [ + "-std=c++17", + "-g", + "-O3", + "-Wall", + "-Wextra", + "-DUSE_IMM", + "-I/home/zdh/WorkSpace/GenSym/headers", + "-lz3", + "-DENABLE_PROFILE_TIME", + "-DNO_INFO" +] + +TOOL_CONFIG_DEFAULT = [ + "-DNO_REUSE", +] +TOOL_CONFIG_SNAPSHOT_UNIFORMLY = [] +TOOL_CONFIG_SNAPSHOT_COST_MODEL = ["-DUSE_COST_MODEL"] +EXTRA_FLAGS = sys.argv[1:] +FLAGS = BASE_FLAGS + TOOL_CONFIG_DEFAULT + EXTRA_FLAGS +SNAPSHOT_FLAGS = BASE_FLAGS + TOOL_CONFIG_SNAPSHOT_UNIFORMLY + EXTRA_FLAGS +SNAPSHOT_COST_MODEL_FLAGS = BASE_FLAGS + TOOL_CONFIG_SNAPSHOT_COST_MODEL + EXTRA_FLAGS + +def compile_all(cpp_files=None, flags=None): + if cpp_files is None: + cpp_files = CPP_FILES + if flags is None: + flags = FLAGS + + compiled_total = 0 + compiled_success = 0 + compiled_failed = 0 + + for cpp in cpp_files: + out = cpp.with_suffix(".exe") # foo.cpp -> ./foo + cmd = ["g++", str(cpp), "-o", str(out)] + flags + print("Compiling:", cpp.name) + try: + print(" Executing command:") + print(" ", " ".join(cmd)) + proc = subprocess.run(cmd, capture_output=True, text=True) + except FileNotFoundError: + print("Error: g++ not found. Install a C++ compiler.") + sys.exit(1) + + snapshot_out = cpp.with_suffix(".snapshot.exe") + snapshot_cmd = ["g++", str(cpp), "-o", str(snapshot_out)] + SNAPSHOT_FLAGS + print("Compiling snapshot version:", cpp.name) + try: + print(" Executing command:") + print(" ", " ".join(snapshot_cmd)) + snapshot_proc = subprocess.run(snapshot_cmd, capture_output=True, text=True) + except FileNotFoundError: + print("Error: g++ not found. Install a C++ compiler.") + sys.exit(1) + + snapshot_cost_model_out = cpp.with_suffix(".costmodel.exe") + snapshot_cost_model_cmd = ["g++", str(cpp), "-o", str(snapshot_cost_model_out)] + SNAPSHOT_COST_MODEL_FLAGS + print("Compiling snapshot cost model version:", cpp.name) + try: + print(" Executing command:") + print(" ", " ".join(snapshot_cost_model_cmd)) + snapshot_cost_model_proc = subprocess.run(snapshot_cost_model_cmd, capture_output=True, text=True) + except FileNotFoundError: + print("Error: g++ not found. Install a C++ compiler.") + sys.exit(1) + + compiled_total += 1 + + if snapshot_proc.returncode == 0: + print(f" Successfully compiled snapshot {cpp.name} to {snapshot_out.name}") + else: + print(f" Failed to compile snapshot {cpp.name}") + print(" Compiler output:") + print(snapshot_proc.stdout) + print(snapshot_proc.stderr) + + if proc.returncode == 0: + print(f" Successfully compiled {cpp.name} to {out.name}") + compiled_success += 1 + else: + print(f" Failed to compile {cpp.name}") + print(" Compiler output:") + print(proc.stdout) + print(proc.stderr) + compiled_failed += 1 + + if snapshot_cost_model_proc.returncode == 0: + print(f" Successfully compiled snapshot cost model {cpp.name} to {snapshot_cost_model_out.name}") + else: + print(f" Failed to compile snapshot cost model {cpp.name}") + print(" Compiler output:") + print(snapshot_cost_model_proc.stdout) + print(snapshot_cost_model_proc.stderr) + + print() + print("Overall summary:") + print(f" Files compiled: {compiled_total}") + print(f" Succeeded: {compiled_success}") + print(f" Failed: {compiled_failed}") + return compiled_total, compiled_success, compiled_failed + + +if __name__ == "__main__": + compile_all() diff --git a/benchmarks/pldi2026/btree/normalize.py b/benchmarks/pldi2026/btree/normalize.py new file mode 100644 index 000000000..ab02461df --- /dev/null +++ b/benchmarks/pldi2026/btree/normalize.py @@ -0,0 +1,31 @@ +from pathlib import Path +import re + +pat = re.compile( + r'\(data\b\s+\$\S+\s+\(i32\.const\s+([0-9]+)\)\s*"((?:[^"\\]|\\.)*)"\)' +) + +def get_mapping(f: Path) -> list[tuple[int, str]]: + for line in f.read_text().splitlines(): + for m in pat.finditer(line): + base_str = m.group(1) + mapping_str = m.group(2) + keys = mapping_str.split("\\00") + assert(keys[-1] == "") + keys = keys[:-1] + return [(int(base_str) + i * 2, k) for i, k in enumerate(keys)] + + +def main(): + for file in Path(__file__).parent.glob("*.wat"): + mapping = get_mapping(file) + print(f"Mapping for {file.name}: {mapping}") + for addr, key in mapping: + # replace (get_sym_int32 "{key}") to (i32.const {addr})\n\t(call $i32.symbolic) in the file + file_contents = file.read_text() + file_contents = file_contents.replace(f'(get_sym_int32 "{key}")', f'(i32.const {addr})\n\t\t(call $i32.symbolic)') + file.write_text(file_contents) + + +if __name__ == "__main__": + main() diff --git a/benchmarks/pldi2026/btree/run.py b/benchmarks/pldi2026/btree/run.py new file mode 100644 index 000000000..d816e11b1 --- /dev/null +++ b/benchmarks/pldi2026/btree/run.py @@ -0,0 +1,157 @@ +import os +import shutil +import sys +import subprocess +from pathlib import Path +import argparse + + +HERE = Path(__file__).resolve().parent +ME = Path(__file__).name + + +def is_executable(path: Path) -> bool: + if not path.is_file(): + return False + # executable bit or .exe suffix + return os.access(str(path), os.X_OK) or path.suffix.lower() == ".exe" + +def is_snapshot_executable(path: Path) -> bool: + if not path.is_file(): + return False + + return path.name.endswith(".snapshot.exe") + +def is_cost_model_executable(path: Path) -> bool: + if not path.is_file(): + return False + + return path.name.endswith(".costmodel.exe") + +def run_all(targets: list[Path], action): + for file_path in targets: + if not is_executable(file_path): + continue + file_name = file_path.name.removesuffix(".exe") + if is_snapshot_executable(file_path): + output_path = "Snapshot" + f"/{file_name}.output" + elif is_cost_model_executable(file_path): + output_path = "CostModel" + f"/{file_name}.output" + else: + output_path = "NoConfig" + f"/{file_name}.output" + + num = len(list(Path(output_path).glob("*.json"))) if Path(output_path).exists() else 0 + if num >= 5: + print(f"Skip {file_name} since it already has {num} reports.") + continue + if action == "run": + env = os.environ.copy() + env.update({"OUTPUT_FILE": output_path + f"/report_{num}.json"}) + + print("Now executing: " + str(file_path)) + proc = subprocess.Popen( + [str(file_path.resolve())], stderr=subprocess.STDOUT, env=env + ) + rc = proc.wait() + + if rc != 0: + print(f"{file_name} exited with return code {rc}", file=sys.stderr) + elif action == "clean": + p = Path(output_path) + if p.exists(): + try: + if p.is_dir(): + shutil.rmtree(p) + except Exception as e: + print(f"Failed to remove {output_path}: {e}", file=sys.stderr) + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + "-r", + "--run-all", + action="store_true", + help="Run all compiled executables in the current directory", + ) + parser.add_argument( + "--clean", + action="store_true" + ) + args = parser.parse_args() + + if not args.run_all and not args.clean: + parser.print_help() + return 0 + + # targets = list(sorted(list(Path(".").iterdir()))) + targets = list(map(Path, [ + "2o1u.wat.exe", + "2o1u.wat.snapshot.exe", + "2o1u.wat.costmodel.exe", + "3o1u.wat.exe", + "3o1u.wat.snapshot.exe", + "3o1u.wat.costmodel.exe", + "4o1u.wat.exe", + "4o1u.wat.snapshot.exe", + "4o1u.wat.costmodel.exe", + "5o1u.wat.exe", + "5o1u.wat.snapshot.exe", + "5o1u.wat.costmodel.exe", + "6o1u.wat.exe", + "6o1u.wat.snapshot.exe", + "6o1u.wat.costmodel.exe", + "7o1u.wat.exe", + "7o1u.wat.snapshot.exe", + "7o1u.wat.costmodel.exe", + "8o1u.wat.exe", + "8o1u.wat.snapshot.exe", + "8o1u.wat.costmodel.exe", + "9o1u.wat.exe", + "9o1u.wat.snapshot.exe", + "9o1u.wat.costmodel.exe", + "2o2u.wat.exe", + "2o2u.wat.snapshot.exe", + "2o2u.wat.costmodel.exe", + "3o2u.wat.exe", + "3o2u.wat.snapshot.exe", + "3o2u.wat.costmodel.exe", + "4o2u.wat.exe", + "4o2u.wat.snapshot.exe", + "4o2u.wat.costmodel.exe", + "5o2u.wat.exe", + "5o2u.wat.snapshot.exe", + "5o2u.wat.costmodel.exe", + "6o2u.wat.exe", + "6o2u.wat.snapshot.exe", + "6o2u.wat.costmodel.exe", + "7o2u.wat.exe", + "7o2u.wat.snapshot.exe", + "7o2u.wat.costmodel.exe", + # "8o2u.wat.exe" is not runnable even in wasp + # "9o2u.wat.exe", + "3o3u.wat.exe", + "3o3u.wat.snapshot.exe", + "3o3u.wat.costmodel.exe", + "4o3u.wat.exe", + "4o3u.wat.snapshot.exe", + "4o3u.wat.costmodel.exe", + "5o3u.wat.exe", + "5o3u.wat.snapshot.exe", + "5o3u.wat.costmodel.exe", + "6o3u.wat.exe", + "6o3u.wat.snapshot.exe", + "6o3u.wat.costmodel.exe", + "7o3u.wat.exe", + "7o3u.wat.snapshot.exe", + "7o3u.wat.costmodel.exe", + ])) + print(targets) + if args.run_all: + run_all(targets, action="run") + elif args.clean: + run_all(targets, action="clean") + + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/benchmarks/pldi2026/crafted/parse_expr150-16.wat b/benchmarks/pldi2026/crafted/parse_expr150-16.wat new file mode 100644 index 000000000..6c6be2b5b --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr150-16.wat @@ -0,0 +1,221 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 9 + i32.add + if + end + local.get 0 + i32.const 10 + i32.add + if + end + local.get 0 + i32.const 11 + i32.add + if + end + local.get 0 + i32.const 12 + i32.add + if + end + local.get 0 + i32.const 13 + i32.add + if + end + local.get 0 + i32.const 13 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+1\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr150-8.wat b/benchmarks/pldi2026/crafted/parse_expr150-8.wat new file mode 100644 index 000000000..3050a7652 --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr150-8.wat @@ -0,0 +1,181 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+1\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr160-16.wat b/benchmarks/pldi2026/crafted/parse_expr160-16.wat new file mode 100644 index 000000000..41e334ea2 --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr160-16.wat @@ -0,0 +1,216 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 9 + i32.add + if + end + local.get 0 + i32.const 10 + i32.add + if + end + local.get 0 + i32.const 11 + i32.add + if + end + local.get 0 + i32.const 12 + i32.add + if + end + local.get 0 + i32.const 13 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+42*x+70*x+98\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr160-8.wat b/benchmarks/pldi2026/crafted/parse_expr160-8.wat new file mode 100644 index 000000000..42496e1ad --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr160-8.wat @@ -0,0 +1,176 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+42*x+70*x+98\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr190-16.wat b/benchmarks/pldi2026/crafted/parse_expr190-16.wat new file mode 100644 index 000000000..0ca50dc9c --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr190-16.wat @@ -0,0 +1,208 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 9 + i32.add + if + end + local.get 0 + i32.const 10 + i32.add + if + end + local.get 0 + i32.const 11 + i32.add + if + end + + + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr190-8.wat b/benchmarks/pldi2026/crafted/parse_expr190-8.wat new file mode 100644 index 000000000..cd078ef4f --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr190-8.wat @@ -0,0 +1,181 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x+95*x\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr220-16.wat b/benchmarks/pldi2026/crafted/parse_expr220-16.wat new file mode 100644 index 000000000..e33b8548c --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr220-16.wat @@ -0,0 +1,226 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 9 + i32.add + if + end + local.get 0 + i32.const 10 + i32.add + if + end + local.get 0 + i32.const 11 + i32.add + if + end + local.get 0 + i32.const 11 + i32.add + if + end + local.get 0 + i32.const 12 + i32.add + if + end + local.get 0 + i32.const 13 + i32.add + if + end + local.get 0 + i32.const 14 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+10+x+x+3+8\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x+95*x+133*11*x+247*x+323+60*x+100*x+140*11*x+260*x+340+3*x+5*x+7*11*x+13*x+17+6*x\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr220-8.wat b/benchmarks/pldi2026/crafted/parse_expr220-8.wat new file mode 100644 index 000000000..61f1550c9 --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr220-8.wat @@ -0,0 +1,182 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+10+x+x+3+8\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x+95*x+133*11*x+247*x+323+60*x+100*x+140*11*x+260*x+340+3*x+5*x+7*11*x+13*x+17+6*x\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr260-16.wat b/benchmarks/pldi2026/crafted/parse_expr260-16.wat new file mode 100644 index 000000000..22c67a76d --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr260-16.wat @@ -0,0 +1,241 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + local.get 0 + i32.const 9 + i32.add + if + end + local.get 0 + i32.const 10 + i32.add + if + end + local.get 0 + i32.const 11 + i32.add + if + end + local.get 0 + i32.const 12 + i32.add + if + end + local.get 0 + i32.const 13 + i32.add + if + end + local.get 0 + i32.const 14 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x+95*x+133*11*x+247*x+323+60*x+100*x+140*11*x+260*x+340+3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x*x*x+25*x+35*11*x+65*x+85+18\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr260-8.wat b/benchmarks/pldi2026/crafted/parse_expr260-8.wat new file mode 100644 index 000000000..06bde7795 --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr260-8.wat @@ -0,0 +1,181 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x+95*x+133*11*x+247*x+323+60*x+100*x+140*11*x+260*x+340+3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x*x*x+25*x+35*11*x+65*x+85+18\00")) diff --git a/benchmarks/pldi2026/crafted/parse_expr3.wat b/benchmarks/pldi2026/crafted/parse_expr3.wat new file mode 100644 index 000000000..fba5ee858 --- /dev/null +++ b/benchmarks/pldi2026/crafted/parse_expr3.wat @@ -0,0 +1,191 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 i32) (result i32))) + (func (;0;) (type 0) (result i32) + (local i32 i32 i32) + global.get 0 + global.get 1 + i32.add + local.set 0 + local.get 0 + i32.load + i32.const 255 + i32.and) + (func (;1;) (type 1) + global.get 1 + i32.const 1 + i32.add + global.set 1) + (func (;2;) (type 0) (result i32) + (local i32 i32) + i32.const 0 + local.set 0 + loop ;; label = @1 + call 0 + local.tee 1 + i32.const 48 + i32.ge_s + local.get 1 + i32.const 57 + i32.le_s + i32.and + if ;; label = @2 + local.get 0 + i32.const 10 + i32.mul + local.get 1 + i32.const 48 + i32.sub + i32.add + local.set 0 + call 1 + br 1 (;@1;) + end + end + local.get 0) + (func (;3;) (type 0) (result i32) + (local i32) + call 0 + local.tee 0 + i32.const 48 + i32.ge_s + local.get 0 + i32.const 57 + i32.le_s + i32.and + if (result i32) ;; label = @1 + call 2 + else + local.get 0 + i32.const 120 + i32.eq + if (result i32) ;; label = @2 + call 1 + global.get 2 + else + i32.const 0 + end + end) + (func (;4;) (type 0) (result i32) + (local i32 i32 i32) + call 3 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 42 + i32.ne + br_if 1 (;@1;) + call 1 + call 3 + local.set 2 + local.get 0 + local.get 2 + i32.mul + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;5;) (type 0) (result i32) + (local i32 i32 i32) + call 4 + local.set 0 + block ;; label = @1 + loop ;; label = @2 + call 0 + local.tee 1 + i32.const 43 + i32.ne + br_if 1 (;@1;) + call 1 + call 4 + local.set 2 + local.get 0 + local.get 2 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 0) + (func (;6;) (type 2) (param i32 i32) (result i32) + local.get 0 + global.set 2 + local.get 1 + global.set 0 + i32.const 0 + global.set 1 + call 5) + (func (;7;) (result i32) + (local i32) + i32.const 0 + i32.symbolic + i32.const 1024 + call 6 + local.tee 0 + if + end + i32.const 10 ;; x + i32.const 1024 + call 6 + i32.const 0 + i32.symbolic + i32.const 0 + call 6 + local.tee 0 + if + end + local.get 0 + i32.const 1 + i32.add + if + end + local.get 0 + i32.const 2 + i32.add + if + end + local.get 0 + i32.const 3 + i32.add + if + end + local.get 0 + i32.const 4 + i32.add + if + end + local.get 0 + i32.const 5 + i32.add + if + end + local.get 0 + i32.const 6 + i32.add + if + end + local.get 0 + i32.const 7 + i32.add + if + end + local.get 0 + i32.const 8 + i32.add + if + end + ) + (import "console" "assert" (func (param i32))) + (start 7) + (memory (;0;) 1) + (global (;0;) (mut i32) (i32.const 0)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (export "memory" (memory 0)) + (export "eval_expr" (func 6)) + (data (i32.const 0) "x+1\00") + (data (;0;) (i32.const 1024) "3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x+25*x*x*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x+102+21*x+35*x+49*11*x+91*x+119+24*x+40*x+56*11*x+104*x+136+27*x+45*x+63*11*x+117*x+153+30*x+50*x+70*11*x+130*x+170+33*x+55*x+77*11*x+143*x+187+36*x+60*x+84*11*x+156*x+204+39*x+65*x+91*11*x+169*x+221+42*x+70*x+98*11*x+182*x+238+45*x+75*x+105*11*x+195*x+255+48*x*x*x+80*x+112*11*x+208*x+272+51*x*x*x+85*x+119*11*x+221*x+289+54*x+90*x+126*11*x+234*x+306+57*x*x*x+95*x+133*11*x+247*x+323+60*x+100*x+140*11*x+260*x+340+3*x+5*x+7*11*x+13*x+17+6*x+10*x+14*11*x+26*x+34+9*x+15*x+21*11*x+39*x+51+12*x+20*x+28*11*x+52*x+68+15*x*x*x+25*x+35*11*x+65*x+85+18*x+30*x+42*11*x+78*x\00")) diff --git a/benchmarks/pldi2026/wasp_btree/2o1u.wast b/benchmarks/pldi2026/wasp_btree/2o1u.wast new file mode 100644 index 000000000..b9384f568 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/2o1u.wast @@ -0,0 +1,3655 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 2 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;; logical order: a>b + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (i32.and) + + ;; 1 symbolic variable w/o order + ;; h + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (print_stack) + (i32.const -1) + (i32.eq) + (print_stack) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (print_stack) + (i32.const -1) + (i32.eq) + (print_stack) + + + (print_btree) + + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00h\00")) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/2o2u.wast b/benchmarks/pldi2026/wasp_btree/2o2u.wast new file mode 100644 index 000000000..384e4feee --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/2o2u.wast @@ -0,0 +1,3694 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 2 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;; logical order: a>b + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + ;; i + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00h\00i\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/2o3u.wast b/benchmarks/pldi2026/wasp_btree/2o3u.wast new file mode 100644 index 000000000..090f36e0f --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/2o3u.wast @@ -0,0 +1,3740 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 2 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;; logical order: a>b + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1028) + (i32.symbolic) + (sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + ;; i + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + ;; j + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/3o1u.wast b/benchmarks/pldi2026/wasp_btree/3o1u.wast new file mode 100644 index 000000000..ef2c9309a --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/3o1u.wast @@ -0,0 +1,3698 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 3 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;; logical order: a>b>c + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 1 symbolic variable w/o order + ;; h + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/3o2u.wast b/benchmarks/pldi2026/wasp_btree/3o2u.wast new file mode 100644 index 000000000..ffa990f10 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/3o2u.wast @@ -0,0 +1,3744 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 3 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;; logical order: a>b>c + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + ;; i + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/3o3u.wast b/benchmarks/pldi2026/wasp_btree/3o3u.wast new file mode 100644 index 000000000..0c191307c --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/3o3u.wast @@ -0,0 +1,3795 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 3 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + + ;; logical order: a>b>c + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 3 symbolic variables w/o order + ;; h + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + ;; i + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + ;; j + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/4o1u.wast b/benchmarks/pldi2026/wasp_btree/4o1u.wast new file mode 100644 index 000000000..da4203391 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/4o1u.wast @@ -0,0 +1,3747 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 4 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;; logical order: a>b>c>d + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 1 symbolic variables w/o order + ;; h + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/4o2u.wast b/benchmarks/pldi2026/wasp_btree/4o2u.wast new file mode 100644 index 000000000..7b3c6eecf --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/4o2u.wast @@ -0,0 +1,3798 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 4 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;; logical order: a>b>c>d + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + ;; i + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/4o3u.wast b/benchmarks/pldi2026/wasp_btree/4o3u.wast new file mode 100644 index 000000000..30faaedda --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/4o3u.wast @@ -0,0 +1,3854 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 4 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;; logical order: a>b>c>d + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + ;; i + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + ;; j + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/5o1u.wast b/benchmarks/pldi2026/wasp_btree/5o1u.wast new file mode 100644 index 000000000..9c6338700 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/5o1u.wast @@ -0,0 +1,3801 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; logical order: a>b>c>d>e + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 1 symbolic variable w/o order + ;; h + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/5o2u.wast b/benchmarks/pldi2026/wasp_btree/5o2u.wast new file mode 100644 index 000000000..cb2a650f1 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/5o2u.wast @@ -0,0 +1,3858 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; logical order: a>b>c>d>e + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variable w/o order + ;; h + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + ;; i + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/5o3u.wast b/benchmarks/pldi2026/wasp_btree/5o3u.wast new file mode 100644 index 000000000..6342b1a5d --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/5o3u.wast @@ -0,0 +1,3915 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; logical order: a>b>c>d>e + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 3 symbolic variable w/o order + ;; h + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + ;; i + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + ;; j + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/6o1u.wast b/benchmarks/pldi2026/wasp_btree/6o1u.wast new file mode 100644 index 000000000..ccc8520f0 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/6o1u.wast @@ -0,0 +1,3861 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 6 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + + ;; logical order: a>b>c>d>e>f + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + + ;; 1 symbolic variables w/o order + ;; h + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/6o2u.wast b/benchmarks/pldi2026/wasp_btree/6o2u.wast new file mode 100644 index 000000000..9038d51ee --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/6o2u.wast @@ -0,0 +1,3922 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 6 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + + ;; logical order: a>b>c>d>e>f + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + ;; i + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/6o3u.wast b/benchmarks/pldi2026/wasp_btree/6o3u.wast new file mode 100644 index 000000000..153c95b7a --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/6o3u.wast @@ -0,0 +1,3987 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 6 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + + ;; logical order: a>b>c>d>e>f + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + + ;; 3 symbolic variables w/o order + ;; h + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + ;; i + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + ;; i + (i32.const 1040) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/7o1u.wast b/benchmarks/pldi2026/wasp_btree/7o1u.wast new file mode 100644 index 000000000..69e17d056 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/7o1u.wast @@ -0,0 +1,3926 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 1 symbolic variables w/o order + ;; h + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/7o2u.wast b/benchmarks/pldi2026/wasp_btree/7o2u.wast new file mode 100644 index 000000000..7c5b411a1 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/7o2u.wast @@ -0,0 +1,3992 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + + ;; i + (i32.const 1040) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/7o3u.wast b/benchmarks/pldi2026/wasp_btree/7o3u.wast new file mode 100644 index 000000000..c51d9b646 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/7o3u.wast @@ -0,0 +1,4065 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 3 symbolic variables w/o order + ;; h + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + + ;; i + (i32.const 1040) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + ;; i + (i32.const 1042) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/8o1u.wast b/benchmarks/pldi2026/wasp_btree/8o1u.wast new file mode 100644 index 000000000..3c9425018 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/8o1u.wast @@ -0,0 +1,3996 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; x + (i32.const 1044) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "g") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g>x + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + (get_sym_int32 "g") + (get_sym_int32 "x") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 1 symbolic variables w/o order + ;; h + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "x") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "x") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; x + (local.get 0) + (get_sym_int32 "x") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/8o2u.wast b/benchmarks/pldi2026/wasp_btree/8o2u.wast new file mode 100644 index 000000000..9d19d9f7e --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/8o2u.wast @@ -0,0 +1,4059 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (sym_int32 "a") + (sym_int32 "b") + (i32.ne) + + ;;c + (sym_int32 "c") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (sym_int32 "d") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (sym_int32 "e") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (sym_int32 "f") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (sym_int32 "g") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; x + (sym_int32 "x") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "g") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g>x + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + (get_sym_int32 "g") + (get_sym_int32 "x") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (sym_int32 "h") + (sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "x") + (i32.ne) + + ;; i + (sym_int32 "i") + (sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "x") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "x") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; x + (local.get 0) + (get_sym_int32 "x") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/9o1u.wast b/benchmarks/pldi2026/wasp_btree/9o1u.wast new file mode 100644 index 000000000..ef8a94483 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/9o1u.wast @@ -0,0 +1,4072 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; x + (i32.const 1044) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "g") + (i32.ne) + + ;; y + (i32.const 1046) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "x") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g>x>y + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + (get_sym_int32 "g") + (get_sym_int32 "x") + (i32.gt_s) + + (get_sym_int32 "x") + (get_sym_int32 "y") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 1 symbolic variables w/o order + ;; h + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "x") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "y") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "x") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "y") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "y") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; x + (local.get 0) + (get_sym_int32 "x") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; y + (local.get 0) + (get_sym_int32 "y") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "y") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00y\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/9o2u.wast b/benchmarks/pldi2026/wasp_btree/9o2u.wast new file mode 100644 index 000000000..88a7615ab --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/9o2u.wast @@ -0,0 +1,4147 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 9 symbolic variables w/ order + ;; a and b + (i32.const 1024) + (i32.symbolic) + (i32.const 1026) + (i32.symbolic) + (i32.ne) + + ;;c + (i32.const 1028) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne) + + ;;d + (i32.const 1030) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne) + + ;;e + (i32.const 1032) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne) + + ;; f + (i32.const 1034) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (i32.const 1036) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; x + (i32.const 1044) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "x") + (get_sym_int32 "g") + (i32.ne) + + ;; y + (i32.const 1046) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "y") + (get_sym_int32 "x") + (i32.ne) + + ;; logical order: a>b>c>d>e>f>g>x>y + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s) + + (get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s) + + (get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s) + + (get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + (get_sym_int32 "g") + (get_sym_int32 "x") + (i32.gt_s) + + (get_sym_int32 "x") + (get_sym_int32 "y") + (i32.gt_s) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (i32.const 1038) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "x") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "y") + (i32.ne) + + ;; i + (i32.const 1040) + (i32.symbolic) + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "x") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "y") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "c") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "d") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "e") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "x") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "y") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "y") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; e + (local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; x + (local.get 0) + (get_sym_int32 "x") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "x") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; y + (local.get 0) + (get_sym_int32 "y") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "y") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + ) + (export "main" (func $main)) + (data $0 (i32.const 1024) "a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00x\00y\00") +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/BTree.wast b/benchmarks/pldi2026/wasp_btree/BTree.wast new file mode 100644 index 000000000..86cf3cbb7 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/BTree.wast @@ -0,0 +1,4073 @@ +(module + (memory $0 1) + + + (func $createBtree (param i32) (result i32) ;; createBtree(t), where t: degree of the btree + (i32.const 0) + (local.get 0) + (i32.store) ;; store t at address 0 + + (i32.const 0) + (i32.const 1) + (i32.store offset=4) ;; store the number of nodes in the btree = 1 + + (i32.const 0) + (i32.const 65536) + (i32.store offset=8) ;; store the root addr + + (i32.const 1) ;; Now create root + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then + (i32.const 65536) ;; 64KiB = 65536 bytes + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + + (i32.const 65536) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + ) + ) + (i32.const 65536) ;; returns the address of the root + ) + + ;; btreeSearch(x, k), where x: node address; k: key to search. Returns address of the key or -1 if key is not in tree. + (func $btreeSearch (param i32) (param i32) (result i32) (local i32) + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n -1 + (i32.le_s) ;; i <= x.children-1 + (if + (then + (local.get 1) ;; k + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + (if + (then + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) ;; i + + (local.get 0) ;; x + (i32.load offset=4) ;; x.children + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.le_s) ;; i <= x.children - 1 + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.eq) + ;; k == x.keys[i] + (if (result i32) + (then + + (local.get 0) ;; save the address, which is x+8+i*4 + (i32.const 8) + (i32.add) ;; x+8 + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x+8+i*4 + + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + (else + (local.get 0) ;; x + (i32.load) ;; x is leaf? + (i32.const 1) ;; if == 1, then yes + (i32.eq) + (if (result i32) + (then + (i32.const -1) + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i + + (local.get 1) ;; k + + (call $btreeSearch) ;; btreeSearch(x.children[i], k) + + ) + ) + ) + ) + ) + + ;; btreeSplitChild(x, i), where x: addr of a non full internal node; i: index such that x.children[i] is a full child of x + (func $btreeSplitChild (param i32) (param i32) (local i32) (local i32) + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if ;; if we can grow memory + (then ;; get the number of nodes in the tree + (i32.const 0) + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address is 64KiB*(number of nodes+1) + (local.set 2) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + + (i32.load offset=8) ;; load the addr of the child in index i : y + + + (i32.load) ;; check if x.children[i] is leaf ;; load the first i32 in the child + (i32.const 1) + (i32.eq) ;; is y leaf? + (if + (then ;; yes + (local.get 2) ;; addr of new node z + (i32.const 1) + (i32.store) ;; store 1(TRUE) regarding if node is leaf + ) + (else ;; no + (local.get 2) ;; addr of new node z + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + ) + ) + + (local.get 2) ;; now store number of children, which will be t/2 -1 ;; addr of z + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + + (i32.store offset=4) ;; store number of children = (t/2)-1 + + (i32.const 0) ;; now to store the keys + (local.set 3) ;; counter = 0 + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.const 1) + (i32.sub) ;; (t/2)-1 + (i32.eq) ;; counter == (t/2)-1 + (if + (then + + (br $loop_break) + ) + (else + + (local.get 2) ;; addr of z ;; we will store in the new node's address. z.keys[counter] + + (i32.const 4) + (local.get 3) ;; counter + + (i32.mul) ;; counter * 4 + + (i32.add) ;; addr + counter * 4 -> where the key is goint to be located + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 4) ;; now get x.children[i].keys[counter+(t/2)] + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.add) ;; counter + (t/2) + + (i32.mul) ;; counter + (t/2) *4 + + (i32.add) ;; y + counter + (t/2) *4 + (i32.load offset=8) ;; y.keys[counter + (t/2)] + + (i32.store offset=8) ;; z.keys[counter] = y.keys[counter + (t/2)] + + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + + ) + ) + ) + ) + + (i32.const 0) + (local.set 3) ;; set counter back to 0 + + (i32.const 0) ;; check if x.children[i] is leaf + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + i*4 + (i32.load offset=8) ;; load the address of the child in index i = y + (i32.load) ;; get first i32 in child --> isLeaf + (i32.const 1) + (i32.ne) ;; is leaf? + + (if + (then ;; not leaf so we have to update the children + (block $loop_break + (loop $loop + + (local.get 3) ;; counter + + (i32.const 0) + (i32.load) ;; t + + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.eq) ;; counter == (t/2) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; now get z.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; counter*4 + + (i32.add) ;; (t-1)*4 + counter*4 + + (local.get 2) ;; z + (i32.add) ;; z + (t-1)*4 + counter*4 --> address where addr of child is stored + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) ;; get x.children[i].children[counter+(t/2)] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.add) ;; counter + t/2 + (i32.const 4) + (i32.mul) ;; counter+t/2 * 4 + + (i32.add) ;; (t-1)*4 + (counter+(t/2))*4 + + (i32.add) ;; x.children[i] + (t-1)*4 + (counter + (t/2))*4 + (i32.load offset=8) ;; load the address of the child in index counter + t/2 + + (i32.store offset=8) ;; z.children[counter] = x.children[i].children[counter] + + (local.get 3) ;; increment counter + (i32.const 1) + (i32.add) + (local.set 3) + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.store offset=4) ;; number of keys of x.children[i] is now t/2 -1 + + (local.get 0) ;; x + + (i32.load offset=4) ;; get x.n + (local.set 3) ;; counter = x.n + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (local.get 3) ;; counter + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; get x.children[counter + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (i32.add) ;; (t-1)*4 + (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter + 1)*4 -->address where addr of child is stored + + (i32.const 0) ;; get x.children[counter] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (i32.add) ;; (t-1)*4 + (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (counter)*4 + (i32.load offset=8) ;; load the addr of the child in index (counter) + + (i32.store offset=8) ;; x.children[counter+1] = x.children[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (i32.const 0) ;; get x.children[i + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 1) + (i32.add) ;; i + 1 + (i32.const 4) + (i32.mul) ;; (i + 1)*4 + + (i32.add) ;; (t-1)*4 + (i + 1)*4 + + (local.get 0) ;; x + + (i32.add) ;; x + (t-1)*4 + (i + 1)*4 --> addr where we will store the new addr of the child + + (local.get 2) ;; addr of z + (i32.store offset=8) ;; x.children[i+1] = z + + (local.get 0) ;; x + (i32.load offset=4) ;; get x.n + (i32.const 1) + (i32.sub) + (local.set 3) ;; counter = x.n -1 + + (block $loop_break + (loop $loop + (local.get 1) ;; i + (i32.const 1) + (i32.sub) ;; i-1 + (local.get 3) ;; counter + (i32.eq) ;; counter == i-1 + + (if + (then + (br $loop_break) + ) + (else + + (local.get 3) ;; get x.keys[counter + 1] ;; counter + (i32.const 1) + (i32.add) ;; counter + 1 + (i32.const 4) + (i32.mul) ;; (counter + 1)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter + 1)*4 --> addr where we will store the new key + + (local.get 3) ;; counter + (i32.const 4) + (i32.mul) ;; (counter)*4 + + (local.get 0) ;; x + (i32.add) ;; x +(counter)*4 + (i32.load offset=8) ;; load the key in index (counter) + + (i32.store offset=8) ;; x.keys[counter+1] = x.keys[counter] + + (local.get 3) ;; decrement counter + (i32.const 1) + (i32.sub) + (local.set 3) + (br $loop) + ) + ) + + ) + ) + + (local.get 1) ;; get x.keys[i] + (i32.const 4) + (i32.mul) ;; i*4 + + (local.get 0) ;; x + (i32.add) ;; x +i*4 --> addr of the key + + (i32.const 0) ;; get x.children[i].keys[t/2] + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; t/2 -1 + + (i32.const 4) + (i32.mul) ;; (t/2)-1 *4 + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 1) ;; i + (i32.const 4) + (i32.mul) ;; (i)*4 + + (i32.add) ;; (t-1)*4 + (i)*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i)*4 + (i32.load offset=8) ;; load the address of the child in index (i) + + (i32.add) ;; y + (t/2)-1 *4 + (i32.load offset=8) ;; load the key in index (t/2)-1 from node x.children[i] + + (i32.store offset=8) ;; store the new key in the addr + + (local.get 0) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) ;; x.n + 1 + (i32.store offset=4) ;; x.n = x.n + 1 + ) + ) + ) + + ;; btreeInsertNonFull(x, k), where x: addr of a non full internal node; k: the key to insert + (func $btreeInsertNonFull (param i32) (param i32) (local i32) + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.const 1) + (i32.sub) ;; x.n -1 + (local.set 2) ;; i = x.n -1 + + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (block $loop_break + (loop $loop + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + + (if (result i32) + (then + (local.get 1) ;; k + (local.get 0) ;; x + ;; x+4*i + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + (i32.lt_s) ;; k < x.keys[i] + ) + (else + (i32.const 0) + ) + ) + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i <= 0? + (i32.and) + + (if + (then + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i *4 + + (i32.add) ;; x + i *4 --> addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.keys[i+1] = x.keys[i] + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 2) ;; i = i-1 + (br $loop) + + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.mul) ;; i+1 *4 + + (i32.add) ;; x + i+1 *4 --> addr of x.keys[i+1] + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.keys[i+1] = k + + (local.get 0) + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;; x.n = x.n +1 + + ) + (else ;; x is not leaf + (block $loop_break + (loop $loop + + (local.get 2) ;; i + (i32.const 0) + (i32.ge_s) ;; i >= 0 + + (if + (then + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.lt_s) ;; k < x.keys[i] + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i -1 + (local.set 2) ;; i = i-1 + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + + (i32.const 1) + (i32.add) + + (local.set 2) ;;i = i+1 + + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address of the child in index i = y + (i32.load offset=8) ;; load the address of the child in index i = y + + (i32.load offset=4) ;; get y.n + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; y.n == t-1 --> node is full + (if + (then + (local.get 0) ;; x + + (local.get 2) ;; i + (call $btreeSplitChild) + + (local.get 1) ;; k + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k>x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i+1 + ) + ) + ) + ) + + (i32.const 0) ;; get x.children[i] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; load the address of the child in index i = y + + (local.get 1) ;; k + + (call $btreeInsertNonFull) + + ) + ) + ) + + (func $btreeInsert (param i32) (result i32) (local i32) (local i32) + (i32.const 0) + (i32.load offset=8) ;; root addr + (local.tee 2) ;; set r + + (i32.load offset=4) ;; r.n + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.eq) ;; r.n == t-1 --> root is full + (if (result i32) + (then + + (i32.const 1) ;; create a new node + (memory.grow) ;; create new page + (i32.const -1) + (i32.ne) + (if (result i32) ;; if we can grow memory + (then + (i32.const 0) ;; get the number of nodes in the tree + (i32.load offset=4) ;; number of nodes in the tree + (i32.const 1) + (i32.add) ;; number of nodes + 1 + (i32.const 65536) + (i32.mul) ;; address of s is 64KiB*(number of nodes+1) + (local.set 1) + + (i32.const 0) ;; change number of nodes + (i32.const 0) + (i32.load offset=4) + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; set number of nodes to + 1 + + (i32.const 0) + (local.get 1) ;; s + (i32.store offset=8) ;; root addr is now s + + (local.get 1) ;; s + (i32.const 0) + (i32.store) ;; store 0(FALSE) regarding if node is leaf + + (local.get 1) ;; now store number of keys + (i32.const 0) + (i32.store offset=4) ;; store number of keys = 0 + + (i32.const 0) ;; store children addresses + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 1) ;; x + (i32.add) ;; x + (t-1)*4 --> addre where addr of child number 0 is located + (local.get 2) + + (i32.store offset=8) ;; s.children[0] = r + + (local.get 1) ;; s + (i32.const 0) + + (call $btreeSplitChild) + + (local.get 1) ;; s + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 1) ;; return the address of the new root + ) + (else + (i32.const -1) ;; return -1 because we could not create a new node + ) + ) + ) + (else + (local.get 2) ;; r + (local.get 0) ;; k + (call $btreeInsertNonFull) + (local.get 2) ;; return the address of the root, which is the same + ) + ) + ) + + ;; Returns the address of the new root (if applicable, otherwise returns the addres of the root) + (func $btreeDelete (param i32) (param i32) (result i32) (local i32) (local i32) (local i32) (local i32) + (local.get 0) ;; x + (i32.load) ;; get first i32 --> isLeaf + (i32.const 1) + (i32.eq) ;; is leaf? + (if + (then ;; x is leaf + (i32.const 0) + (local.set 2) ;; i = 0 + (block $loop_break + (loop $loop + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (local.get 2) ;; i + + (i32.eq) ;; i == x.n + (if + (then + (br $loop_break) ;; break from loop + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + + (i32.eq) ;; k == x.keys[i] + (if + (then + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $while_break + (loop $while + (local.get 3) ;; j + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n-1 + (i32.eq) ;; j == x.n-1 + (if + (then + (br $while_break) + ) + (else + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + + (i32.add) ;; x + j*4 --> addr where x.keys[j] is stored + + (local.get 0) ;; x + + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.mul) ;; j+1 *4 + + (i32.add) ;; x + j+1 *4 --> addr where x.keys[j+1] is stored + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $while) + ) + ) + + ) + ) + (local.get 0) ;; x + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.n = x.n -1 + (br $loop_break) + ) + + ) + ) + + ) + (i32.const 1) + (local.get 2) + (i32.add) + (local.set 2) ;; i = i+1 + (br $loop) ;; continue + ) + ) + ) + (else ;; x is not leaf + + (i32.const 0) ;;get the index of the appropriate child/key + (local.set 2) ;; i = 0 + + (block $loop_break + (loop $loop + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (if (result i32) + (then + (local.get 1) ;; k + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (i32.gt_s) ;; k > x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (local.get 2) ;; i + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.le_s) ;; i <= x.n - 1 + + (i32.and) ;; i <= x.n - 1 && k > x.keys[i] + + (if + (then + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (local.set 2) ;; i = i + 1 + + (br $loop) + ) + (else + (br $loop_break) + ) + ) + ) + ) + (local.get 2) + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.lt_s) ;; i < x.n + (if (result i32) + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[i] + + (local.get 1) ;; k + (i32.eq) ;; k == x.keys[i] + ) + (else + (i32.const 0) + ) + ) + (if + (then ;; key is present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.tee 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i].n >= t/2 + (if + (then + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.sub) ;; index = x.c[i].n - 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[x.c[i].n - 1] + + (call $btreeDelete) ;; (x.c[i], x.c[i].keys[x.c[i].n - 1]) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i].keys[x.c[i].n - 1] + + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i+1] + (local.tee 5) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (local.get 5) ;; x.c[i+1] + (local.get 5) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[0] + (call $btreeDelete) + (drop) + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + ) + (else + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i *4 + (i32.add) ;; x + i*4 --> addr where x.c[i].keys[x.c[i].n] will be stored + + (local.get 1) ;; k + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = k + + (i32.const 0) ;; now merge x.c[i] with x.c[i+1] + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + (i32.add) ;; (t-1)*4 + i+1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + + (if ;; j == x.c[i+1].n + (then + (br $loop_break) + ) + (else + + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n + j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[index] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x.c[i+1] + i*4 ;; addr of x.c[i+1].keys[j] + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[index] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + + ) + + ) + ) + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n +1 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.add) + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + 1 + x.c[i+1].n + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + + (i32.const 0) ;; now adjust the children + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.get 3) ;; j + (i32.add) ;; index = x.c[i].n+j + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x.c[i] + (t-1)*4 --> address where x.c[i].c[x.c[i].n+j] is stored + + (i32.const 0) ;;get x.c[i+1].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x.c[i+1] + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + (i32.const 1) + (i32.sub) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; j*4 + (i32.add) ;; x + j*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.add) + (i32.mul) ;; j+1*4 + (i32.add) ;; x + j+1*4 ;; addr of x.keys[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + + ) + ) + + (local.get 2) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = i+1 + + (block $loop_break + (loop $loop + (local.get 0) + (i32.load offset=4) + + (local.get 3) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.add) ;; j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + (local.get 0) + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + (i32.store offset=4) ;; x.n = x.n-1 + + (local.get 5) ;; x.c[i] + (local.get 1) ;; k + + (call $btreeDelete) + (drop) + + ) + ) + + ) + ) + + ) + (else ;; key not present in node x + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 4) + (i32.mul) ;; i*4 + + (i32.add) ;; (t-1)*4 + i*4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> address where addr of child in index i is located + (i32.load offset=8) ;; x.c[i] + + (local.set 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) + (i32.const 1) + (i32.sub) ;; t/2 - 1 + + (i32.eq) + + (if + (then + (i32.const -1) + (local.set 4) ;; changed = -1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.le_s) ;; i+1 <= x.n + + (if + (then + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i+1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i+1].n >= t/2 + + (if + (then + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.const 1) + (i32.sub) ;; index = t/2 -1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[t/2-1] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[t/2-1] = x.keys[i] + + (local.get 5) + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + + (i32.store offset=4) ;;x.c[i].n = x.c[i].n +1 + + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i+1].keys[0] + (i32.load offset=8) ;; x.c[i+1].keys[0] + + (i32.store offset=8) ;; x.keys[i] = x.c[i+1].keys[0] + + (local.get 5) + (i32.load) ;; x.c[i] is leaf? + (i32.const 1) + (i32.ne) + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + + (i32.const 0) ;;get x.c[i].c[t/2] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; index = t/2 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[t/2] + + (i32.const 0) ;;get x.c[i+1].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[0] + + (i32.store offset=8) ;; x.c[i].c[t/2] = x.c[i+1].c[0] + ) + ) + + (local.get 5) ;; x.c[i] + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + (i32.store offset=4) ;; x.c[i].n = t/2 + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 --> address where x.c[i+1].keys[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j+1] + + (i32.store offset=8) ;; x.c[i+1].keys[j] = x.c[i+1].keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if ;; if x.c[i] is not leaf, we have to adjust children + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 --> address where x.c[i+1].c[j] is located + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j+1 + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j+1] + + (i32.store offset=8) ;; x.c[i+1].c[j] = x.c[i+1].c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j+1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr where x.c[i+1] is located + (i32.load offset=8) + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i+1].n = x.c[i+1].n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + (i32.const 0) + (i32.ge_s) ;; i -1 >= 0 + + (i32.and) ;; changed == -1 && i -1 >= 0 + + (if + (then + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 0) + (i32.load) ;; t + (i32.const 2) + (i32.div_s) ;; t/2 + + (i32.ge_s) ;; x.c[i-1].n >= t/2 + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (local.set 3) ;; j = x.c[i].n + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[j-1] + (i32.load offset=8) ;; x.c[i].keys[j-1] + + (i32.store offset=8) ;; x.c[i].keys[j] = x.c[i].keys[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + + (if + (then + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (local.set 3) ;; j = x.c[i].n + 1 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) + (i32.eq) + + (if + (then + (br $loop_break) + ) + (else + (i32.const 0) ;;get x.c[i].c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> address where x.c[i].c[j] is located + + (i32.const 0) ;;get x.c[i].c[j-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; j + (i32.const 1) + (i32.sub) ;; j-1 + (i32.const 4) + (i32.mul) ;; j *4 + + (i32.add) ;; (t-1)*4 + j *4 + + (local.get 5) ;; x.c[i] + (i32.add) + (i32.load offset=8) ;; x.c[i].c[j-1] + + (i32.store offset=8) ;; x.c[i].c[j] = x.c[i].c[j-1] + + (local.get 3) + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = j-1 + + (br $loop) + ) + ) + ) + ) + ) + ) + + (local.get 5) + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) + (i32.store offset=4) ;; ;; x.c[i].n = x.c[i].n + 1 + + (local.get 5) ;; x.c[i] + (i32.const 4) + (i32.const 0) ;; index = 0 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[0] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i-1] + + (i32.store offset=8) ;; x.c[i].keys[0] = x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) + (i32.load offset=4) ;; x.c[i-1].n + + (i32.const 1) + (i32.sub) + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n - 1 + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; index = i-1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + (i32.load offset=8) + + (i32.store offset=8) ;; x.keys[i-1] = x.c[i-1].keys[x.c[i-1].n] + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + + (i32.const 0) ;; get x.c[i].c[0] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 ;; addr where x.c[i].c[0] is located + + (i32.const 0) ;; get x.c[i-1].c[x.c[i-1].n + 1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (i32.const 1) + (i32.add) ;; index = x.c[i-1.n + 1] + + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1].c[x.c[i-1].n + 1] + + (i32.store offset=8) ;; x.c[i].c[0] = x.c[i-1].c[x.c[i-1].n + 1] + + ) + ) + (i32.const 0) + (local.set 4) ;; changed = 0 + ) + ) + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) + (if ;; changed == -1? + (then + + (local.get 2) ;; we have to merge x.c[i] with one sibling;; i + (i32.const 1) + (i32.add) ;; i+1 + + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + + (i32.le_s) + (if ;; i+1 <= x.n + (then + + (local.get 5) ;; merge with right sibling;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) ;; index = x.c[i].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n] = x.keys[i] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + (local.get 5) ;; x.c[i] + (i32.const 4) + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i].keys[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i+1].keys[j] + + (i32.store offset=8) ;; x.c[i].keys[x.c[i].n+j] = x.c[i+1].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i+1].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 5) + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i].c[x.c[i].n+j] + + (i32.const 0) ;;get x.c[i].c[x.c[i].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1].c[j] + + (i32.store offset=8) ;; x.c[i].c[x.c[i].n+j] = x.c[i+1].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (local.get 5) ;; x.c[i] + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.const 0) ;;get x.c[i+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i+1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i+1] + (i32.load offset=4) ;; x.c[i+1].n + + (i32.add) ;; x.c[i].n + x.c[i+1].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i].n = x.c[i].n + x.c[i+1].n + 1 + + (local.get 2) ;; i + (i32.const 1) + (i32.add) ;; i+1 + (local.set 3) ;; j = i+1 + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j+1] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + ) + ) + (local.get 2) ;; i + (local.set 3) ;; j = i + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + + (i32.const 0) + (local.set 4) ;; changed = 0 + + ) + ) + + (local.get 4) ;; changed + (i32.const -1) + (i32.eq) ;; changed == -1 ? + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) ;; i - 1 + + (i32.const 0) + (i32.ge_s) ;; i - 1 >= 0? + + (i32.and) ;; changed == -1 && i - 1 >= 0 + (if + (then + + (i32.const 0) ;; merge with left sibling ;;get x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; index = x.c[i-1].n + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n] + + (local.get 0) ;; x + (i32.const 4) + (local.get 2) ;; index = i + (i32.const 1) + (i32.sub) ;; index = i-1 + + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[i-1] + (i32.load offset=8) ;; x.keys[i] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n] = x.keys[i-1] + + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;; x.c[i-1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.const 4) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.c[i-1].keys[x.c[i-1].n+j] + + (local.get 5) ;; x.c[i] + (i32.const 4) + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.c[i].keys[j] + + (i32.store offset=8) ;; x.c[i-1].keys[x.c[i-1].n+j] = x.c[i].keys[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + + (local.get 5) + (i32.load) + (i32.const 1) + (i32.ne) + (if + (then + (i32.const 0) + (local.set 3) ;; j = 0 + + (block $loop_break + (loop $loop + (local.get 3) ;; j + + (local.get 5) ;; x.c[i] + (i32.load offset=4) ;; x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + 1 + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[i-1].c[x.c[i-1].n+j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) + (local.get 3) + (i32.add) + (i32.const 1) + (i32.add) ;; index = x.c[i-1].n+j+1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.add) ;; x + (t-1)*4 --> addr of x.c[i-1].c[x.c[i-1].n+j] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 5) ;; x.c[i] + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i].c[j] + + (i32.store offset=8) ;; x.c[i-1].c[x.c[i-1].n+j] = x.c[i].c[j] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + (br $loop) + ) + ) + + ) + ) + ) + ) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (i32.load offset=4) ;; x.c[i-1].n + + (local.get 5) + (i32.load offset=4) ;; x.c[i].n + + (i32.add) ;; x.c[i-1].n + x.c[i].n + (i32.const 1) + (i32.add) ;; x.c[i].n + x.c[i+1].n + 1 + + (i32.store offset=4) ;; x.c[i-1].n = x.c[i-1].n + x.c[i].n + 1 + + (local.get 2) ;; i + (local.set 3) ;; j = i + + (block $loop_break ;; re-organize x + (loop $loop + + (local.get 3) + + (local.get 0) + (i32.load offset=4) ;; x.n + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (i32.const 0) ;;get x.c[j] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) ;; index = j + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + + (i32.const 0) ;;get x.c[j+1] + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.const 4) + (i32.mul) ;; i-1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 --> addr of x.c[j] + (i32.load offset=8) ;; x.c[j+1] + + (i32.store offset=8) ;; x.c[j] = x.c[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (local.set 3) ;; j = i - 1 + (block $loop_break + (loop $loop + + (local.get 3) ;; j + + (local.get 0) + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) + + (i32.eq) + (if + (then + (br $loop_break) + ) + (else + + (local.get 0) ;; x + (i32.const 4) + + (local.get 3) ;; index = j + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 ;; addr of x.keys[j] + + (local.get 0) ;; x + (i32.const 4) + (local.get 3) + (i32.const 1) + (i32.add) ;; index = j + 1 + (i32.mul) ;; i*4 + (i32.add) ;; x + i*4 + (i32.load offset=8) ;; x.keys[j+1] + + (i32.store offset=8) ;; x.keys[j] = x.keys[j+1] + + (local.get 3) + (i32.const 1) + (i32.add) + (local.set 3) ;; j = j + 1 + + (br $loop) + + ) + ) + + ) + ) + (local.get 0) ;; x + (local.get 0) ;; x + (i32.load offset=4) ;; x.n + (i32.const 1) + (i32.sub) ;; x.n - 1 + (i32.store offset=4) ;; x.n = x.n - 1 + ) + ) + ) + ) + ) + ) + (local.get 4) + (i32.const -1) + (i32.eq) + (if ;; changed == -1? if yes, we merged with left sibling + (then + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (local.get 2) ;; i + (i32.const 1) + (i32.sub) + (i32.const 4) + (i32.mul) ;; i+1 *4 + + (i32.add) ;; (t-1)*4 + i-1 *4 + + (local.get 0) ;; x + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; x.c[i-1] + (local.get 1) + (call $btreeDelete) + (drop) + ) + (else + (local.get 5) ;; x.c[i] + (local.get 1) + (call $btreeDelete) + (drop) + ) + ) + + ) + ) + ) ;; end of if x is not leaf + ) + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.load offset=4) + (i32.const 0) + (i32.eq) + (if ;; if root is empty + (then + (i32.const 0) + + (i32.const 0) + (i32.load) ;; t + (i32.const 1) + (i32.sub) ;; t-1 + (i32.const 4) + (i32.mul) ;; (t-1)*4 + + (i32.const 0) ;; index = 0 + (i32.const 4) + (i32.mul) ;; i *4 + + (i32.add) ;; (t-1)*4 + i *4 + + (i32.const 0) + (i32.load offset=8) ;; root addr + (i32.add) ;; x + (t-1)*4 + (i32.load offset=8) ;; root.c[0] + + (i32.store offset=8) ;; root = root.c[0] + ) + ) + + (i32.const 0) + (i32.load offset=8) ;; root addr + ) + + + (func $main + (local i32) + (i32.const 4) ;;create a tree with degree 4 + (call $createBtree) + (local.set 0) + + ;; 5 symbolic variables w/ order + ;; a and b + (sym_int32 "a") + (sym_int32 "b") + (i32.ne) + + (;);;c + (sym_int32 "c") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "c") + (get_sym_int32 "b") + (i32.ne);) + + (;);;d + (sym_int32 "d") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "d") + (get_sym_int32 "c") + (i32.ne);) + + (;;;e + (sym_int32 "e") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "e") + (get_sym_int32 "d") + (i32.ne);) + + (;);; f + (sym_int32 "f") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "f") + (get_sym_int32 "e") + (i32.ne) + + ;; g + (sym_int32 "g") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "g") + (get_sym_int32 "f") + (i32.ne) + + ;; z + (sym_int32 "z") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "b") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "c") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "d") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "e") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "z") + (get_sym_int32 "g") + (i32.ne);) + + + + ;; logical order: a>b>c>d>e>f>g>z + (get_sym_int32 "a") + (get_sym_int32 "b") + (i32.gt_s) + + (;(get_sym_int32 "b") + (get_sym_int32 "c") + (i32.gt_s);) + + (;(get_sym_int32 "c") + (get_sym_int32 "d") + (i32.gt_s);) + + (;(get_sym_int32 "d") + (get_sym_int32 "e") + (i32.gt_s);) + + (;(get_sym_int32 "e") + (get_sym_int32 "f") + (i32.gt_s) + + (get_sym_int32 "f") + (get_sym_int32 "g") + (i32.gt_s) + + (get_sym_int32 "g") + (get_sym_int32 "z") + (i32.gt_s);) + + + (i32.and) + + ;; 2 symbolic variables w/o order + ;; h + (sym_int32 "h") + (sym_int32 "a") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "b") + (i32.ne) + + (;(get_sym_int32 "h") + (get_sym_int32 "c") + (i32.ne);) + + (;(get_sym_int32 "h") + (get_sym_int32 "d") + (i32.ne);) + + (;(get_sym_int32 "h") + (get_sym_int32 "e") + (i32.ne);) + + (;(get_sym_int32 "h") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "h") + (get_sym_int32 "z") + (i32.ne);) + + + + ;; i + (sym_int32 "i") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "b") + (i32.ne) + + (;(get_sym_int32 "i") + (get_sym_int32 "c") + (i32.ne);) + + (;(get_sym_int32 "i") + (get_sym_int32 "d") + (i32.ne);) + + (;(get_sym_int32 "i") + (get_sym_int32 "e") + (i32.ne);) + + (;(get_sym_int32 "i") + (get_sym_int32 "f") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "g") + (i32.ne) + + (get_sym_int32 "i") + (get_sym_int32 "z") + (i32.ne);) + + + (get_sym_int32 "i") + (get_sym_int32 "h") + (i32.ne) + + + ;; j + (sym_int32 "j") + (get_sym_int32 "a") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "b") + (i32.ne) + + (;(get_sym_int32 "j") + (get_sym_int32 "c") + (i32.ne);) + + (;(get_sym_int32 "j") + (get_sym_int32 "d") + (i32.ne);) + + (;(get_sym_int32 "j") + (get_sym_int32 "e") + (i32.ne);) + + (;(get_sym_int32 "j") + (get_sym_int32 "f") + (i32.ne) + + (;(get_sym_int32 "j") + (get_sym_int32 "g") + (i32.ne););) + + (get_sym_int32 "j") + (get_sym_int32 "h") + (i32.ne) + + (get_sym_int32 "j") + (get_sym_int32 "i") + (i32.ne) + + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assume) + + ;; insert variables + (get_sym_int32 "a") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "b") + (call $btreeInsert) + (local.set 0) + (;(get_sym_int32 "c") + (call $btreeInsert) + (local.set 0);) + (;(get_sym_int32 "d") + (call $btreeInsert) + (local.set 0);) + (;(get_sym_int32 "e") + (call $btreeInsert) + (local.set 0);) + (;(get_sym_int32 "f") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "g") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "z") + (call $btreeInsert) + (local.set 0);) + (get_sym_int32 "h") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "i") + (call $btreeInsert) + (local.set 0) + (get_sym_int32 "j") + (call $btreeInsert) + (local.set 0) + + (print_btree) + + ;; search for variables & check that they were inserted + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (;(local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + (;(local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + (;(local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + (;(local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "z") + (call $btreeSearch) + (i32.const -1) + (i32.ne);) + + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (local.get 0) + (get_sym_int32 "j") + (call $btreeSearch) + (i32.const -1) + (i32.ne) + + (i32.and) + (i32.and) + (i32.and) + (i32.and) + (sym_assert) + + ;; delete & check that it was deleted + ;; a + (local.get 0) + (get_sym_int32 "a") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "a") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; b + (local.get 0) + (get_sym_int32 "b") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "b") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + (;);; c + (local.get 0) + (get_sym_int32 "c") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "c") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + (;);; d + (local.get 0) + (get_sym_int32 "d") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "d") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + ;; e + (;(local.get 0) + (get_sym_int32 "e") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "e") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + (;);; f + (local.get 0) + (get_sym_int32 "f") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "f") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; g + (local.get 0) + (get_sym_int32 "g") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "g") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; z + (local.get 0) + (get_sym_int32 "z") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "z") + (call $btreeSearch) + (i32.const -1) + (i32.eq);) + + ;; h + (local.get 0) + (get_sym_int32 "h") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "h") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + ;; i + (local.get 0) + (get_sym_int32 "i") + (call $btreeDelete) + (local.set 0) + + (local.get 0) + (get_sym_int32 "i") + (call $btreeSearch) + (i32.const -1) + (i32.eq) + + + (print_btree) + + (i32.and) + (i32.and) + (i32.and) + + (sym_assert) + + + + ) + (export "main" (func $main)) + +) +(invoke "main") diff --git a/benchmarks/pldi2026/wasp_btree/run.py b/benchmarks/pldi2026/wasp_btree/run.py new file mode 100644 index 000000000..fb19b77d3 --- /dev/null +++ b/benchmarks/pldi2026/wasp_btree/run.py @@ -0,0 +1,70 @@ +from pathlib import Path +import subprocess +import argparse +import sys + +#!/usr/bin/env python3 +import concurrent.futures + +def run_wast(path: Path, timeout: float | None): + log_path = path.with_suffix(path.suffix + ".log") + cmd = ["wasp", str(path), "--workspace", str(path.parent / f"{path.stem}.out")] + try: + proc = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout) + out = proc.stdout + err = proc.stderr + rc = proc.returncode + except subprocess.TimeoutExpired as e: + out = e.stdout or "" + err = (e.stderr or "") + f"\n[ERROR] timeout after {timeout}s" + rc = 124 + except Exception as e: + out = "" + err = f"[ERROR] failed to run wasp: {e}" + rc = 1 + + with open(log_path, "w", encoding="utf-8") as f: + f.write(f"$ {' '.join(cmd)}\n\n") + f.write("=== STDOUT ===\n") + f.write(out or "") + f.write("\n\n=== STDERR ===\n") + f.write(err or "") + + return path.name, rc + +def main(): + parser = argparse.ArgumentParser(description="Run wasp on all .wast files in the current directory.") + parser.add_argument("-j", "--jobs", type=int, default=1, help="number of parallel jobs (default 1)") + parser.add_argument("--timeout", type=float, default=None, help="per-file timeout in seconds") + args = parser.parse_args() + + cwd = Path.cwd() + wast_files = sorted([p for p in cwd.iterdir() if p.is_file() and p.suffix == ".wast"]) + if not wast_files: + print("No .wast files found in the current directory.") + return + + results = [] + if args.jobs == 1: + for p in wast_files: + results.append(run_wast(p, args.timeout)) + else: + with concurrent.futures.ThreadPoolExecutor(max_workers=args.jobs) as exe: + futures = {exe.submit(run_wast, p, args.timeout): p for p in wast_files} + for fut in concurrent.futures.as_completed(futures): + results.append(fut.result()) + + failed = [(name, rc) for (name, rc) in results if rc != 0] + for name, rc in results: + status = "OK" if rc == 0 else f"FAIL(rc={rc})" + print(f"{name}: {status}") + + if failed: + print(f"\n{len(failed)} failed. See corresponding .log files for details.") + sys.exit(1) + else: + print("\nAll runs succeeded.") + sys.exit(0) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/benchmarks/wasm/Makefile b/benchmarks/wasm/Makefile new file mode 100644 index 000000000..bad47a229 --- /dev/null +++ b/benchmarks/wasm/Makefile @@ -0,0 +1,7 @@ +.PHONY: clean + +clean: + find . -type f -name '*.cpp' -delete + find . -type f -name '*.cpp.exe' -delete + find . -type d -name '*.dSYM' -exec rm -rf {} + + find . -type f -name '*.dot' -delete diff --git a/benchmarks/wasm/branch-strip-buggy.wat b/benchmarks/wasm/branch-strip-buggy.wat index c957db7f6..0685f0be1 100644 --- a/benchmarks/wasm/branch-strip-buggy.wat +++ b/benchmarks/wasm/branch-strip-buggy.wat @@ -29,6 +29,7 @@ else i32.const 0 call 2 + i32.const 1 ;; to satisfy the type checker, this line will never be reached end end ) diff --git a/benchmarks/wasm/btree/2o1u-unlabeled.wat b/benchmarks/wasm/btree/2o1u-unlabeled.wat index 096f10044..443bf5d4f 100644 --- a/benchmarks/wasm/btree/2o1u-unlabeled.wat +++ b/benchmarks/wasm/btree/2o1u-unlabeled.wat @@ -2626,9 +2626,12 @@ i32.and drop) (func (;7;) (type 4) - i32.const 3 i32.const 2 + i32.symbolic i32.const 1 + i32.symbolic + i32.const 0 + i32.symbolic call 6) (memory (;0;) 2) (export "main" (func 7)) diff --git a/benchmarks/wasm/btree/2o1u-unlabeled.wat copy.cpp b/benchmarks/wasm/btree/2o1u-unlabeled.wat copy.cpp new file mode 100644 index 000000000..a449fd2a4 --- /dev/null +++ b/benchmarks/wasm/btree/2o1u-unlabeled.wat copy.cpp @@ -0,0 +1,71 @@ +std::monostate Snippet(std::monostate x0) { +Globals.pushFrame(0); +SymGlobals.pushFrame(0); +Frames.pushFrame(0); +SymFrames.pushFrame(0); +Stack.push(I32V(2)); +SymStack.push(Concrete(I32V(2))); +Stack.pop(); +SymVal x3 = SymStack.pop(); +SymVal x4 = x3.makeSymbolic(); +Stack.push(SymEnv.read(x4)); +SymStack.push(x4); +Stack.push(I32V(1)); +SymStack.push(Concrete(I32V(1))); +Stack.pop(); +SymVal x5 = SymStack.pop(); +SymVal x6 = x5.makeSymbolic(); +Stack.push(SymEnv.read(x6)); +SymStack.push(x6); +Stack.push(I32V(0)); +SymStack.push(Concrete(I32V(0))); +Stack.pop(); +SymVal x7 = SymStack.pop(); +SymVal x8 = x7.makeSymbolic(); +Stack.push(SymEnv.read(x8)); +SymStack.push(x8); +CostManager.add_instr_cost(14); +info("Exiting the function at 5, stackSize =", Stack.size()); +Frames.popFrame(6); +SymFrames.popFrame(6); +Num x5014 = Stack.peek(); +SymVal x5015 = SymStack.peek(); +Frames.set(3, x5014); +SymFrames.set(3, x5015); +Stack.push(Frames.get(1)); +SymStack.push(SymFrames.get(1)); +CostManager.add_instr_cost(8); +Stack.pop(); +Stack.pop(); +SymStack.pop(); +SymStack.pop(); +std::monostate x5032 = std::monostate(); +std::function x5033; +x5033 = [=](std::monostate x5034)->std::monostate { +std::monostate(); +return x5018(x5035); +}; +Num x5180 = Stack.pop(); +Num x5181 = Stack.pop(); +Num x5182 = Stack.pop(); +SymVal x5183 = SymStack.pop(); +SymVal x5184 = SymStack.pop(); +SymVal x5185 = SymStack.pop(); +std::monostate x5190 = std::monostate(); +std::function x5191; +x5191 = [=](std::monostate x5192)->std::monostate { +std::monostate(); +return x5188(x1); +}; +Frames.pushFrame(4); +SymFrames.pushFrame(4); +Frames.set(0, x5182); +Frames.set(1, x5181); +Frames.set(2, x5180); +SymFrames.set(0, x5185); +SymFrames.set(1, x5184); +SymFrames.set(2, x5183); +x5153(x5191); +Frames.popFrame(0); +return SymFrames.popFrame(0); +} \ No newline at end of file diff --git a/benchmarks/wasm/btree/Makefile b/benchmarks/wasm/btree/Makefile new file mode 100644 index 000000000..a876c01d9 --- /dev/null +++ b/benchmarks/wasm/btree/Makefile @@ -0,0 +1,53 @@ +# Makefile for building different versions of 2o1u-unlabeled.wat.cpp + +CXX := g++ +SRC := 2o1u-unlabeled.wat.cpp +HEADERS := ../../headers/ +LDFLAGS := -lz3 +CXXFLAGS := -g -I $(HEADERS) -std=c++17 -DENABLE_PROFILE -fno-omit-frame-pointer -O3 -DENABLE_PROFILE_TIME + +.PHONY: all clean benchmark + +all: 2o1u-unlabeled.wat.cpp.imm.no-snap.exe 2o1u-unlabeled.wat.cpp.imm.exe 2o1u-unlabeled.wat.cpp.no-snap.exe 2o1u-unlabeled.wat.cpp.exe \ + 2o1u-unlabeled.wat.cpp.concolic.imm.no-snap.exe 2o1u-unlabeled.wat.cpp.concolic.imm.exe 2o1u-unlabeled.wat.cpp.concolic.no-snap.exe 2o1u-unlabeled.wat.cpp.concolic.exe 2o1u-unlabeled.wat.cpp.concolic.imm.cost-model.exe + +2o1u-unlabeled.wat.cpp.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DRUN_ONCE + +2o1u-unlabeled.wat.cpp.no-snap.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DNO_REUSE -DRUN_ONCE + +2o1u-unlabeled.wat.cpp.imm.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DUSE_IMM -DRUN_ONCE + +2o1u-unlabeled.wat.cpp.imm.no-snap.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DUSE_IMM -DNO_REUSE -DRUN_ONCE + + +## Concolic execution tests +2o1u-unlabeled.wat.cpp.concolic.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DBY_COVERAGE + +2o1u-unlabeled.wat.cpp.concolic.no-snap.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DNO_REUSE -DBY_COVERAGE + +2o1u-unlabeled.wat.cpp.concolic.imm.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DUSE_IMM -DBY_COVERAGE + +2o1u-unlabeled.wat.cpp.concolic.imm.no-snap.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DUSE_IMM -DNO_REUSE -DBY_COVERAGE + +2o1u-unlabeled.wat.cpp.concolic.imm.cost-model.exe: $(SRC) + $(CXX) $< -o $@ $(CXXFLAGS) $(LDFLAGS) -DUSE_IMM -DNO_REUSE -DBY_COVERAGE -DUSE_COST_MODEL + +benchmark: all + hyperfine './2o1u-unlabeled.wat.cpp.imm.no-snap.exe' \ + './2o1u-unlabeled.wat.cpp.imm.exe' \ + './2o1u-unlabeled.wat.cpp.no-snap.exe' \ + './2o1u-unlabeled.wat.cpp.exe' + hyperfine './2o1u-unlabeled.wat.cpp.concolic.imm.no-snap.exe' \ + './2o1u-unlabeled.wat.cpp.concolic.imm.exe' \ + './2o1u-unlabeled.wat.cpp.concolic.no-snap.exe' \ + './2o1u-unlabeled.wat.cpp.concolic.exe' +clean: + rm -f *.exe diff --git a/benchmarks/wasm/call_indirect_test.wat b/benchmarks/wasm/call_indirect_test.wat new file mode 100644 index 000000000..7cf7c6b3a --- /dev/null +++ b/benchmarks/wasm/call_indirect_test.wat @@ -0,0 +1,25 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32 i32) (result i32))) + (type (;2;) (func (result i32))) + (func (;0;) (type 0) (param i32) (result i32) + local.get 0 + i32.const 1 + i32.add) + (func (;1;) (type 0) (param i32) (result i32) + local.get 0 + i32.const 2 + i32.mul) + (func (;2;) (type 1) (param i32 i32) (result i32) + local.get 1 + local.get 0 + call_indirect (type 0)) + (func (;3;) (type 2) (result i32) + i32.const 0 + i32.const 41 + call 2) + (table (;0;) 2 funcref) + (export "run" (func 3)) + (export "dispatch" (func 2)) + (elem (;0;) (i32.const 0) func 0 1) + (start 3)) diff --git a/benchmarks/wasm/compare_wasp/Makefile b/benchmarks/wasm/compare_wasp/Makefile new file mode 100644 index 000000000..1c3e58c69 --- /dev/null +++ b/benchmarks/wasm/compare_wasp/Makefile @@ -0,0 +1,20 @@ +.PHONY: all run clean + +all: large-branch.wat.cpp.imm.noreuse.exe large-branch.wat.cpp.imm.exe large-branch.wat.cpp.imm.cost-model.exe + +large-branch.wat.cpp.imm.noreuse.exe: large-branch.wat.cpp + g++ large-branch.wat.cpp -o large-branch.wat.cpp.imm.noreuse.exe -DUSE_IMM -I ../../../headers -lz3 -DENABLE_PROFILE_TIME -O3 -DNO_REUSE -DENABLE_PROFILE_STEP + +large-branch.wat.cpp.imm.exe: large-branch.wat.cpp + g++ large-branch.wat.cpp -o large-branch.wat.cpp.imm.exe -DUSE_IMM -I ../../../headers -lz3 -DENABLE_PROFILE_TIME -O3 -DENABLE_PROFILE_STEP + +large-branch.wat.cpp.imm.cost-model.exe: large-branch.wat.cpp + g++ large-branch.wat.cpp -o large-branch.wat.cpp.imm.cost-model.exe -DUSE_IMM -I ../../../headers -lz3 -DENABLE_PROFILE_TIME -O3 -DUSE_COST_MODEL + + +run: all + ./large-branch.wat.cpp.imm.noreuse.exe + ./large-branch.wat.cpp.imm.exe + +clean: + rm -f *.exe \ No newline at end of file diff --git a/benchmarks/wasm/compare_wasp/large-branch.wat b/benchmarks/wasm/compare_wasp/large-branch.wat new file mode 100644 index 000000000..76e40191c --- /dev/null +++ b/benchmarks/wasm/compare_wasp/large-branch.wat @@ -0,0 +1,591 @@ +(module + (type (;0;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) + (type (;1;) (func (result i32))) + (import "spectest" "print_i32" (func (;0;) (param i32))) + + (func (;1;) (type 0) (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) + local.get 0 + i32.const 0 + i32.gt_s + if ;; label = @1 + local.get 7 + local.get 13 + i32.add + i32.const 13 + i32.add + local.set 0 + end + local.get 1 + i32.const 1 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 7 + i32.add + i32.const 35 + i32.add + local.set 1 + end + local.get 2 + i32.const 2 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 4 + i32.add + i32.const 69 + i32.add + local.set 2 + end + local.get 3 + i32.const 3 + i32.gt_s + if ;; label = @1 + local.get 13 + local.get 14 + i32.add + i32.const 91 + i32.add + local.set 3 + end + local.get 4 + i32.const 4 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 10 + i32.add + i32.const 47 + i32.add + local.set 4 + end + local.get 5 + i32.const 5 + i32.gt_s + if ;; label = @1 + local.get 15 + local.get 6 + i32.add + i32.const 74 + i32.add + local.set 5 + end + local.get 6 + i32.const 6 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 8 + i32.add + i32.const 15 + i32.add + local.set 6 + end + local.get 7 + i32.const 7 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 9 + i32.add + i32.const 34 + i32.add + local.set 7 + end + local.get 8 + i32.const 8 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 12 + i32.add + i32.const 57 + i32.add + local.set 8 + end + local.get 9 + i32.const 9 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 11 + i32.add + i32.const 3 + i32.add + local.set 9 + end + local.get 10 + i32.const 10 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 6 + i32.add + i32.const 21 + i32.add + local.set 10 + end + local.get 11 + i32.const 11 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 5 + i32.add + i32.const 72 + i32.add + local.set 11 + end + local.get 12 + i32.const 12 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 6 + i32.add + i32.const 55 + i32.add + local.set 12 + end + local.get 13 + i32.const 13 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 3 + i32.add + i32.const 12 + i32.add + local.set 13 + end + local.get 14 + i32.const 14 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 12 + i32.add + i32.const 69 + i32.add + local.set 14 + end + local.get 15 + i32.const 15 + i32.gt_s + if ;; label = @1 + local.get 18 + local.get 5 + i32.add + i32.const 92 + i32.add + local.set 15 + end + local.get 16 + i32.const 16 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 12 + i32.add + i32.const 39 + i32.add + local.set 16 + end + local.get 17 + i32.const 17 + i32.gt_s + if ;; label = @1 + local.get 15 + local.get 8 + i32.add + i32.const 39 + i32.add + local.set 17 + end + local.get 18 + i32.const 18 + i32.gt_s + if ;; label = @1 + local.get 17 + local.get 3 + i32.add + i32.const 64 + i32.add + local.set 18 + end + local.get 19 + i32.const 19 + i32.gt_s + if ;; label = @1 + local.get 11 + local.get 5 + i32.add + i32.const 78 + i32.add + local.set 19 + end + local.get 6 + i32.const 6 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 8 + i32.add + i32.const 15 + i32.add + local.set 6 + end + local.get 7 + i32.const 7 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 9 + i32.add + i32.const 34 + i32.add + local.set 7 + end + local.get 8 + i32.const 8 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 12 + i32.add + i32.const 57 + i32.add + local.set 8 + end + local.get 9 + i32.const 9 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 11 + i32.add + i32.const 3 + i32.add + local.set 9 + end + local.get 10 + i32.const 10 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 6 + i32.add + i32.const 21 + i32.add + local.set 10 + end + local.get 11 + i32.const 11 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 5 + i32.add + i32.const 72 + i32.add + local.set 11 + end + local.get 12 + i32.const 12 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 6 + i32.add + i32.const 55 + i32.add + local.set 12 + end + local.get 13 + i32.const 13 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 3 + i32.add + i32.const 12 + i32.add + local.set 13 + end + local.get 14 + i32.const 14 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 12 + i32.add + i32.const 69 + i32.add + local.set 14 + end + local.get 15 + i32.const 15 + i32.gt_s + if ;; label = @1 + local.get 18 + local.get 5 + i32.add + i32.const 92 + i32.add + local.set 15 + end + local.get 16 + i32.const 16 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 12 + i32.add + i32.const 39 + i32.add + local.set 16 + end + local.get 1 + local.get 2 + i32.add + local.get 3 + i32.add + local.get 4 + i32.add + local.get 5 + i32.add + local.get 6 + i32.add + local.get 7 + i32.add + local.get 8 + i32.add + local.get 9 + i32.add + local.get 10 + i32.add + local.get 11 + i32.add + local.get 12 + i32.add + local.get 13 + i32.add + local.get 14 + i32.add + local.get 15 + i32.add + local.get 16 + i32.add + local.get 17 + i32.add + local.get 18 + i32.add + local.get 19 + i32.add) + (func (;2;) (type 1) (result i32) + i32.const 0 + i32.symbolic + i32.const 1 + i32.symbolic + i32.const 2 + i32.symbolic + i32.const 3 + i32.symbolic + i32.const 4 + i32.symbolic + i32.const 5 + i32.symbolic + i32.const 6 + i32.symbolic + i32.const 7 + i32.symbolic + i32.const 8 + i32.symbolic + i32.const 9 + i32.symbolic + i32.const 10 + i32.const 11 + i32.const 12 + i32.const 13 + i32.const 14 + i32.const 15 + i32.const 16 + i32.const 17 + i32.const 18 + i32.const 19 + call 3) + (func (;3;) (type 0) (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) + local.get 0 + i32.const 0 + i32.gt_s + if ;; label = @1 + local.get 7 + local.get 13 + i32.add + i32.const 13 + i32.add + local.set 0 + end + local.get 1 + i32.const 1 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 7 + i32.add + i32.const 35 + i32.add + local.set 1 + end + local.get 2 + i32.const 2 + i32.gt_s + if ;; label = @1 + local.get 0 + local.get 4 + i32.add + i32.const 69 + i32.add + local.set 2 + end + local.get 3 + i32.const 3 + i32.gt_s + if ;; label = @1 + local.get 13 + local.get 14 + i32.add + i32.const 91 + i32.add + local.set 3 + end + local.get 4 + i32.const 4 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 10 + i32.add + i32.const 47 + i32.add + local.set 4 + end + local.get 5 + i32.const 5 + i32.gt_s + if ;; label = @1 + local.get 15 + local.get 6 + i32.add + i32.const 74 + i32.add + local.set 5 + end + local.get 6 + i32.const 6 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 8 + i32.add + i32.const 15 + i32.add + local.set 6 + end + local.get 6 + i32.const 6 + i32.gt_s + if ;; label = @1 + local.get 19 + local.get 8 + i32.add + i32.const 15 + i32.add + local.set 6 + end + local.get 7 + i32.const 7 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 9 + i32.add + i32.const 34 + i32.add + local.set 7 + end + local.get 8 + i32.const 8 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 12 + i32.add + i32.const 57 + i32.add + local.set 8 + end + local.get 9 + i32.const 9 + i32.gt_s + if ;; label = @1 + local.get 10 + local.get 11 + i32.add + i32.const 3 + i32.add + local.set 9 + end + local.get 10 + i32.const 10 + i32.gt_s + if ;; label = @1 + local.get 6 + local.get 6 + i32.add + i32.const 21 + i32.add + local.set 10 + end + local.get 1 + local.get 2 + i32.add + local.get 3 + i32.add + local.get 4 + i32.add + local.get 5 + i32.add + local.get 6 + i32.add + local.get 7 + i32.add + local.get 8 + i32.add + local.get 9 + i32.add + local.get 10 + i32.add + local.get 11 + i32.add + local.get 12 + i32.add + local.get 13 + i32.add + local.get 14 + i32.add + local.get 15 + i32.add + local.get 16 + i32.add + local.get 17 + i32.add + local.get 18 + i32.add + local.get 19 + i32.add + ) + (export "f" (func 1)) + (export "main" (func 2)) + (start 2)) + diff --git a/benchmarks/wasm/compare_wasp/small-snapshot.wat b/benchmarks/wasm/compare_wasp/small-snapshot.wat new file mode 100644 index 000000000..991a3d250 --- /dev/null +++ b/benchmarks/wasm/compare_wasp/small-snapshot.wat @@ -0,0 +1,22301 @@ +(module + (type (;0;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) + (type (;1;) (func (result i32))) + (import "spectest" "print_i32" (func (;0;) (param i32))) + + (func (;1;) (type 0) (result i32) + i32.const 0 + i32.symbolic + call 2 + if (result i32) + i32.const 42 + else + i32.const 19 + end) + + (func (;2;) (param i32) (result i32) + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + i32.const 3 + drop + local.get 0) + (export "f" (func 2)) + (export "main" (func 1)) + (start 1)) + diff --git a/benchmarks/wasm/data_sec.wat b/benchmarks/wasm/data_sec.wat new file mode 100644 index 000000000..fe40aad1f --- /dev/null +++ b/benchmarks/wasm/data_sec.wat @@ -0,0 +1,14 @@ +(module + ;; define one page of memory (64 KiB) + (memory 1) + + ;; data bytes at address 0: 01 02 03 04 + (data (i32.const 0) "\01\02\03\04") + + ;; load all 4 bytes as one i32 (little-endian → 0x04030201 = 67305985) + (func (result i32) + i32.const 0 + i32.load + ) + (start 0) +) \ No newline at end of file diff --git a/benchmarks/wasm/diverge.wat b/benchmarks/wasm/diverge.wat new file mode 100644 index 000000000..8de7dcc1d --- /dev/null +++ b/benchmarks/wasm/diverge.wat @@ -0,0 +1,33 @@ +(module $diverge + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32))) + (import "console" "assert" (func (;0;) (type 2))) + (import "console" "log" (func (;1;) (type 2))) + ;; f x = if x == 0 then 42 else f x + (func (;2;) (type 0) (param i32) (result i32) + local.get 0 + i32.const 0 + i32.eq + if (result i32) + i32.const 42 + else + local.get 0 + call 1 + local.get 0 + call 2 + i32.const 0 + call 0 + unreachable + end + ) + (func $real_main (;2;) (type 1) + i32.const 0 + i32.symbolic + call 2 + drop + ) + (start 3) + (export "main" (func 3)) + +) \ No newline at end of file diff --git a/benchmarks/wasm/f32_test.wat b/benchmarks/wasm/f32_test.wat new file mode 100644 index 000000000..b1a03b5d4 --- /dev/null +++ b/benchmarks/wasm/f32_test.wat @@ -0,0 +1,24 @@ +(module + (type (;0;) (func (result f32 f32 f32 f32 i32))) + (func (;0;) (type 0) (result f32 f32 f32 f32 i32) + (local f32 f32) + f32.const 0x1.cp+1 (;=3.5;) + local.set 0 + f32.const 0x1p+1 (;=2;) + local.set 1 + local.get 0 + local.get 1 + f32.add + local.get 0 + local.get 1 + f32.sub + local.get 0 + local.get 1 + f32.mul + local.get 0 + local.get 1 + f32.div + local.get 0 + local.get 1 + f32.gt) + (export "test_f32" (func 0))) diff --git a/benchmarks/wasm/global-sym.wat b/benchmarks/wasm/global-sym.wat new file mode 100644 index 000000000..54f558942 --- /dev/null +++ b/benchmarks/wasm/global-sym.wat @@ -0,0 +1,21 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32) (result i32))) + + (func (;0;) (type 2) (param i32) (result i32) + local.get 0 + global.set 0 + global.get 0 + ) + (func (;1;) (type 1) + i32.const 0 + i32.symbolic + ;; TODO Somehow this value is always 0? + call 0 + ) + (start 1) + (memory (;0;) 2) + (export "main" (func 1)) + (global (;0;) (mut i32) (i32.const 42)) +) \ No newline at end of file diff --git a/benchmarks/wasm/load-offset.wat b/benchmarks/wasm/load-offset.wat new file mode 100644 index 000000000..1c42df1b5 --- /dev/null +++ b/benchmarks/wasm/load-offset.wat @@ -0,0 +1,19 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (func (;0;) (type 0) (result i32) + i32.const 0 + i32.const 256 + i32.store + i32.const 0 + i32.load offset=1 + ) + (func (;1;) (type 1) + call 0 + ;; should be 1 + ;; drop + ) + (start 1) + (memory (;0;) 2) + (export "main" (func 1)) +) \ No newline at end of file diff --git a/benchmarks/wasm/load-overflow1.wat b/benchmarks/wasm/load-overflow1.wat new file mode 100644 index 000000000..9f005ea18 --- /dev/null +++ b/benchmarks/wasm/load-overflow1.wat @@ -0,0 +1,19 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (func (;0;) (type 0) (result i32) + i32.const 0 + i32.const 256 + i32.store + i32.const 1 + i32.load + ) + (func (;1;) (type 1) + call 0 + ;; should be 1 + ;; drop + ) + (start 1) + (memory (;0;) 2) + (export "main" (func 1)) +) \ No newline at end of file diff --git a/benchmarks/wasm/load-overflow2.wat b/benchmarks/wasm/load-overflow2.wat new file mode 100644 index 000000000..86c1a5745 --- /dev/null +++ b/benchmarks/wasm/load-overflow2.wat @@ -0,0 +1,19 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (func (;0;) (type 0) (result i32) + i32.const 0 + i32.const 65536 + i32.store + i32.const 2 + i32.load + ) + (func (;1;) (type 1) + call 0 + ;; should be 1 + ;; drop + ) + (start 1) + (memory (;0;) 2) + (export "main" (func 1)) +) \ No newline at end of file diff --git a/benchmarks/wasm/load.wat b/benchmarks/wasm/load.wat index 916328aa5..6c43d79b2 100644 --- a/benchmarks/wasm/load.wat +++ b/benchmarks/wasm/load.wat @@ -10,7 +10,7 @@ ) (func (;1;) (type 1) call 0 - ;; should be 65536 + ;; should be 1 ;; drop ) (start 1) diff --git a/benchmarks/wasm/mem-sym-extract.wat b/benchmarks/wasm/mem-sym-extract.wat new file mode 100644 index 000000000..ca7e70ebf --- /dev/null +++ b/benchmarks/wasm/mem-sym-extract.wat @@ -0,0 +1,32 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (param i32))) + (import "console" "assert" (func (type 3))) + (func (;1;) (type 2) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; if x == 256 + i32.const 1 ;; return 1 + else + i32.const 0 + call 0 ;; assert false + i32.const 1 ;; to satisfy the type checker, this line will never be reached + end + ) + (func (;2;) (type 1) + i32.const 0 + i32.symbolic ;; call it x + call 1 + ) + (start 2) + (memory (;0;) 2) + (export "main" (func 1)) + (global (;0;) (mut i32) (i32.const 42)) +) \ No newline at end of file diff --git a/benchmarks/wasm/mem-sym.wat b/benchmarks/wasm/mem-sym.wat new file mode 100644 index 000000000..45b9d1c3e --- /dev/null +++ b/benchmarks/wasm/mem-sym.wat @@ -0,0 +1,43 @@ +(module + (type (;0;) (func (result i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (param i32))) + (import "console" "assert" (func (type 3))) + (func (;1;) (type 2) (param i32) (result i32) + i32.const 0 + local.get 0 + i32.store + i32.const 0 + i32.load + i32.const 25 + i32.eq + if (result i32) ;; if x == 25 + i32.const 0 + call 0 ;; assert false + i32.const 1 ;; to satisfy the type checker, this line will never be reached + else + i32.const 1 + i32.load + i32.const 1 + i32.eq + if (result i32) ;; if x >> 8 == 1 + i32.const 0 + call 0 ;; assert false + i32.const 1 ;; to satisfy the type checker, this line will never be reached + else + i32.const 1 + end + i32.const 1 + end + ) + (func (;2;) (type 1) + i32.const 0 + i32.symbolic ;; call it x + call 1 + ) + (start 2) + (memory (;0;) 2) + (export "main" (func 1)) + (global (;0;) (mut i32) (i32.const 42)) +) \ No newline at end of file diff --git a/benchmarks/wasm/staged/brtable_concolic.wat b/benchmarks/wasm/staged/brtable_concolic.wat new file mode 100644 index 000000000..04429e90b --- /dev/null +++ b/benchmarks/wasm/staged/brtable_concolic.wat @@ -0,0 +1,22 @@ +(module $brtable + (global (;0;) (mut i32) (i32.const 1048576)) + (type (;0;) (func (param i32))) + (func (;0;) (type 1) (result i32) + i32.const 2 + (block + (block + (block + i32.const 0 + i32.symbolic + br_table 0 1 2 0 ;; br_table will consume an element from the stack + ) + i32.const 1 + call 1 + br 1 + ) + i32.const 0 + call 1 + ) + ) + (import "console" "assert" (func (type 0))) + (start 0)) diff --git a/benchmarks/wasm/staged/long-trivial-execution.wat b/benchmarks/wasm/staged/long-trivial-execution.wat new file mode 100644 index 000000000..2a23f007f --- /dev/null +++ b/benchmarks/wasm/staged/long-trivial-execution.wat @@ -0,0 +1,54 @@ +(module + (type (;0;) (func)) + (type (;1;) (func (param i32))) + (import "console" "assert" (func (type 1))) + (func (;1;) (type 0) + (local i32 i32) + i32.const 1 + local.set 0 + i32.const 0 + local.set 1 + block + loop + local.get 0 + i32.const 10000 + i32.ge_s + br_if 1 + local.get 1 + i32.const 0 + i32.add + local.set 1 + local.get 0 + i32.const 1 + i32.add + local.set 0 + br 0 + end + end + i32.const 10000 + local.set 0 + i32.const 0 + local.set 1 + block + loop + local.get 0 + i32.eqz + br_if 1 ;; break if counter == 0 + local.get 1 + i32.const 0 + i32.sub ;; acc - 0 (no change) + local.set 1 + local.get 0 + i32.const 1 + i32.sub + local.set 0 ;; counter-- + br 0 ;; repeat loop + end + end + local.get 1 + if + i32.const 0 + call 0 + end + ) + (start 1)) diff --git a/benchmarks/wasm/staged/return_poly.wat b/benchmarks/wasm/staged/return_poly.wat new file mode 100644 index 000000000..1bab5ef0f --- /dev/null +++ b/benchmarks/wasm/staged/return_poly.wat @@ -0,0 +1,19 @@ +(module + (type (;0;) (func)) + (type (;1;) (func (result i32))) + ;; TODO: It seems that our parser or preprocessor has some problems; the result type of the last line doesn't take effect + (func (result i32) + block + i32.const 21 + i32.const 35 + i32.const 42 + return + end + i32.const 100 + ) + (func (type 0) + call 0 + ;; unreachable + ) + (export "$real_main" (func 1)) +) diff --git a/benchmarks/wasm/staged/simple_global.wat b/benchmarks/wasm/staged/simple_global.wat new file mode 100644 index 000000000..4877f42c4 --- /dev/null +++ b/benchmarks/wasm/staged/simple_global.wat @@ -0,0 +1,22 @@ +(module $simple_global + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (result i32))) + (type (;2;) (func (param i32))) + (func $real_main (type 1) (result i32) + (local i32) + i32.const 0 + i32.symbolic + local.tee 0 + local.get 0 + global.set 0 + if + else + i32.const 0 + call 1 + end) + (import "console" "assert" (func (type 2))) + (memory (;0;) 16) + (global $__stack_pointer (mut i32) (i32.const 1048576)) + (global (;1;) i32 (i32.const 1048576)) + (global (;2;) i32 (i32.const 1048576)) + (export "real_main" (func 0))) diff --git a/grammar/WatParser.g4 b/grammar/WatParser.g4 index 96ad2133b..99acf8b75 100644 --- a/grammar/WatParser.g4 +++ b/grammar/WatParser.g4 @@ -323,10 +323,11 @@ offset // TBH I'm not even sure what the `func 1` should count as // TODO: align with the rules here: // https://webassembly.github.io/function-references/core/_download/WebAssembly.pdf +// For now, only support initialize one table via function indices elem - : LPAR ELEM idx? LPAR instr RPAR idx* RPAR - | LPAR ELEM idx? offset idx* RPAR - | LPAR ELEM idx? DECLARE FUNC idx* RPAR + : LPAR ELEM LPAR instr RPAR FUNC idx* RPAR + // | LPAR ELEM idx? offset idx* RPAR + // | LPAR ELEM idx? DECLARE FUNC idx* RPAR ; table diff --git a/headers/wasm.hpp b/headers/wasm.hpp index 21da2ff75..aa93e379f 100644 --- a/headers/wasm.hpp +++ b/headers/wasm.hpp @@ -1,6 +1,11 @@ #ifndef WASM_HEADERS #define WASM_HEADERS +#include "wasm/concolic_driver.hpp" #include "wasm/concrete_rt.hpp" +#include "wasm/controls.hpp" +#include "wasm/profile.hpp" +#include "wasm/symbolic_rt.hpp" +#include "wasm/utils.hpp" #endif \ No newline at end of file diff --git a/headers/wasm/concolic_driver.hpp b/headers/wasm/concolic_driver.hpp new file mode 100644 index 000000000..29639e573 --- /dev/null +++ b/headers/wasm/concolic_driver.hpp @@ -0,0 +1,179 @@ +#ifndef CONCOLIC_DRIVER_HPP +#define CONCOLIC_DRIVER_HPP + +#include "concrete_rt.hpp" +#include "config.hpp" +#include "output_report.hpp" +#include "profile.hpp" +#include "smt_solver.hpp" +#include "symbolic_rt.hpp" +#include "utils.hpp" +#include +#include +#include +#include +#include +#include +#include +#include + +class ConcolicDriver { + friend class ManagedConcolicCleanup; + +public: + ConcolicDriver(std::function entrypoint, + std::optional tree_file, int branchCount) + : entrypoint(entrypoint), tree_file(tree_file) { + ExploreTree.true_branch_cov_map.assign(branchCount, false); + ExploreTree.false_branch_cov_map.assign(branchCount, false); + } + void run(); + +private: + void main_exploration_loop(); + std::function entrypoint; + std::optional tree_file; + std::vector work_list; +}; + +class ManagedConcolicCleanup { + const ConcolicDriver &driver; + +public: + ManagedConcolicCleanup(const ConcolicDriver &driver) : driver(driver) {} + ~ManagedConcolicCleanup() { + // put any cleanup code that needs to be done after each execution here + + // Dump the explore tree if needed + if (driver.tree_file.has_value()) + ExploreTree.dump_graphviz(driver.tree_file.value()); + + // Clear the symbol bookkeeper + SymBookKeeper.clear(); + } +}; + +static std::monostate reset_stacks(); + +inline void ConcolicDriver::main_exploration_loop() { + + // Register a collector to ExploreTree to add new nodes to work_list + ExploreTree.register_new_node_collector( + [&](NodeBox *new_node) { work_list.push_back(new_node); }); + + std::set visited; + + assert(ExploreTree.get_root()->isUnexplored() && + "Before main loop, root should be unexplored!"); + work_list.push_back(ExploreTree.get_root()); + + while (!work_list.empty()) { + ManagedConcolicCleanup cleanup{*this}; + // Pick an unexplored node from the work list + auto node = work_list.back(); + work_list.pop_back(); + + if (visited.find(node) != visited.end()) { + continue; + } else { + visited.insert(node); + } + + if (!node->isUnexplored()) { + // if it's not unexplored anymore, skip it + continue; + } + + if (INTERACTIVE_MODE) { + std::cout << "Press Enter to continue to the next path..." << std::endl; + std::cin.get(); + } + + auto cond = node->collect_path_conds(); + auto result = solver.solve(cond); + if (!result.has_value()) { + GENSYM_INFO("Found an unreachable path, marking it as unreachable..."); + node->fillUnreachableNode(); + continue; + } + auto &new_env = result.value().first; + auto &model = result.value().second; + + // update global symbolic environment from SMT solved model + SymEnv.update(std::move(new_env)); + try { + GENSYM_INFO("Now execute the program with symbolic environment: "); + GENSYM_INFO(SymEnv.to_string()); + if (REUSE_SNAPSHOT) { + if (auto snapshot = dynamic_cast(node->node.get())) { + assert(REUSE_SNAPSHOT); + auto snap = snapshot->get_snapshot(); + snap.resume_execution_by_model(node, model); + } else { + auto timer = ManagedTimer(TimeProfileKind::INSTR); + ExploreTree.reset_cursor(); + reset_stacks(); + entrypoint(); + } + } else { + auto timer = ManagedTimer(TimeProfileKind::INSTR); + ExploreTree.reset_cursor(); + reset_stacks(); + entrypoint(); + } + + GENSYM_INFO("Execution finished successfully with symbolic environment:"); + GENSYM_INFO(SymEnv.to_string()); + } catch (std::runtime_error &e) { + std::cout << "Caught runtime error: " << e.what() << std::endl; + ExploreTree.fillFailedNode(); + + if (std::string(e.what()) == "Symbolic assertion failed") { + GENSYM_INFO("Symbolic assertion failed, continuing to next path..."); + continue; + } + + GENSYM_INFO("Caught runtime error with symbolic environment:"); + GENSYM_INFO(SymEnv.to_string()); + switch (EXPLORE_MODE) { + case ExploreMode::EarlyExit: + return; + case ExploreMode::ExitByCoverage: + if (ExploreTree.all_branch_covered()) { + GENSYM_INFO("All branches covered, exiting..."); + return; + } else { + GENSYM_INFO( + "Found a bug, but not all branches covered, continuing..."); + } + std::cout << e.what() << std::endl; + } + } +#if defined(RUN_ONCE) + return; +#endif + } +} + +inline void ConcolicDriver::run() { + main_exploration_loop(); + auto overall = ExploreTree.read_current_overall_result(); + overall.print(); + Profile.print_summary(); + dump_all_summary_json(Profile, overall); +} + +static void start_concolic_execution_with( + std::function entrypoint, int branchCount) { + + const char *env_tree_file = std::getenv("TREE_FILE"); + + auto tree_file = + env_tree_file ? std::make_optional(env_tree_file) : std::nullopt; + + ConcolicDriver driver = ConcolicDriver( + [=]() { entrypoint(std::monostate{}); }, tree_file, branchCount); + driver.run(); +} + +#endif // CONCOLIC_DRIVER_HPP \ No newline at end of file diff --git a/headers/wasm/concrete_rt.hpp b/headers/wasm/concrete_rt.hpp index 34d739f41..9889db289 100644 --- a/headers/wasm/concrete_rt.hpp +++ b/headers/wasm/concrete_rt.hpp @@ -1,79 +1,482 @@ +#ifndef WASM_CONCRETE_RT_HPP +#define WASM_CONCRETE_RT_HPP + +#include "controls.hpp" +#include "wasm/profile.hpp" +#include "wasm/utils.hpp" #include #include #include #include #include #include +#include #include #include -void info() { -#ifdef DEBUG - std::cout << std::endl; -#endif -} - -template -void info(const T &first, const Args &...args) { -#ifdef DEBUG - std::cout << first << " "; - info(args...); -#endif -} - struct Num { Num(int64_t value) : value(value) {} Num() : value(0) {} int64_t value; - int32_t toInt() { return static_cast(value); } - - bool operator==(const Num &other) const { return value == other.value; } - bool operator!=(const Num &other) const { return !(*this == other); } - Num operator+(const Num &other) const { return Num(value + other.value); } - Num operator-(const Num &other) const { return Num(value - other.value); } - Num operator*(const Num &other) const { return Num(value * other.value); } - Num operator/(const Num &other) const { - if (other.value == 0) { - throw std::runtime_error("Division by zero"); - } - return Num(value / other.value); - } - Num operator<(const Num &other) const { return Num(value < other.value); } - Num operator<=(const Num &other) const { return Num(value <= other.value); } - Num operator>(const Num &other) const { return Num(value > other.value); } - Num operator>=(const Num &other) const { return Num(value >= other.value); } - Num operator&(const Num &other) const { return Num(value & other.value); } + + int32_t toInt() const { return static_cast(value); } + uint32_t toUInt() const { return static_cast(value); } + + // debug printer: enabled only when -DDEBUG + static inline void debug_print(const char *op, const Num &a, const Num &b, + const Num &res) { +#ifdef DEBUG_OP + std::cout << "[Debug] " << op << ": lhs=" << static_cast(a.value) + << " rhs=" << static_cast(b.value) + << " -> res=" << static_cast(res.value) << std::endl; +#endif + } + + // Helper to create a Wasm Boolean result (1 or 0 as Num) + Num WasmBool(bool condition) const { + Num res(condition ? 1 : 0); + debug_print("WasmBool", *this, *this, res); + return res; + } + // TODO: support different bit width operations, for now we just assume all + // oprands are i32 + // i32.eq (Equals): *this == other + inline Num i32_eq(const Num &other) const { + Num res = WasmBool(this->toUInt() == other.toUInt()); + debug_print("i32.eq", *this, other, res); + return res; + } + + // i32.ne (Not Equals): *this != other + inline Num i32_ne(const Num &other) const { + Num res = WasmBool(this->toUInt() != other.toUInt()); + debug_print("i32.ne", *this, other, res); + return res; + } + + // i32.lt_s (Signed Less Than): *this < other + inline Num i32_lt_s(const Num &other) const { + Num res = WasmBool(this->toInt() < other.toInt()); + debug_print("i32.lt_s", *this, other, res); + return res; + } + + // i32.lt_u (Unsigned Less Than): *this < other (unsigned) + inline Num i32_lt_u(const Num &other) const { + Num res = WasmBool(this->toUInt() < other.toUInt()); + debug_print("i32.lt_u", *this, other, res); + return res; + } + + // i32.le_s (Signed Less Than or Equal): *this <= other + inline Num i32_le_s(const Num &other) const { + Num res = WasmBool(this->toInt() <= other.toInt()); + debug_print("i32.le_s", *this, other, res); + return res; + } + // i32.le_u (Unsigned Less Than or Equal): *this <= other (unsigned) + inline Num i32_le_u(const Num &other) const { + Num res = WasmBool(this->toUInt() <= other.toUInt()); + debug_print("i32.le_u", *this, other, res); + return res; + } + + // i32.gt_s (Signed Greater Than): *this > other + inline Num i32_gt_s(const Num &other) const { + Num res = WasmBool(this->toInt() > other.toInt()); + debug_print("i32.gt_s", *this, other, res); + return res; + } + + // i32.gt_u (Unsigned Greater Than): *this > other (unsigned) + inline Num i32_gt_u(const Num &other) const { + Num res = WasmBool(this->toUInt() > other.toUInt()); + debug_print("i32.gt_u", *this, other, res); + return res; + } + + // i32.ge_s (Signed Greater Than or Equal): *this >= other + inline Num i32_ge_s(const Num &other) const { + Num res = WasmBool(this->toInt() >= other.toInt()); + debug_print("i32.ge_s", *this, other, res); + return res; + } + + // i32.ge_u (Unsigned Greater Than or Equal): *this >= other (unsigned) + inline Num i32_ge_u(const Num &other) const { + Num res = WasmBool(this->toUInt() >= other.toUInt()); + debug_print("i32.ge_u", *this, other, res); + return res; + } + + // i32.add (Wrapping addition) + inline Num i32_add(const Num &other) const { + uint32_t result_u = this->toUInt() + other.toUInt(); + Num res(static_cast(result_u)); + debug_print("i32.add", *this, other, res); + return res; + } + + // i32.sub (Wrapping subtraction) + inline Num i32_sub(const Num &other) const { + uint32_t result_u = this->toUInt() - other.toUInt(); + Num res(static_cast(result_u)); + debug_print("i32.sub", *this, other, res); + return res; + } + + // i32.mul (Wrapping multiplication) + inline Num i32_mul(const Num &other) const { + uint32_t result_u = this->toUInt() * other.toUInt(); + Num res(static_cast(result_u)); + debug_print("i32.mul", *this, other, res); + return res; + } + + // i32.div_s (Signed division with traps) + inline Num i32_div_s(const Num &other) const { + int32_t divisor = other.toInt(); + int32_t dividend = this->toInt(); + + if (divisor == 0) { + throw std::runtime_error("i32.div_s: Division by zero"); + } + + Num res(dividend / divisor); + debug_print("i32.div_s", *this, other, res); + return res; + } + + // i32.div_u (Unsigned division with traps) + inline Num i32_div_u(const Num &other) const { + uint32_t divisor = other.toUInt(); + uint32_t dividend = this->toUInt(); + if (divisor == 0) { + throw std::runtime_error("i32.div_u: Division by zero"); + } + Num res(static_cast(dividend / divisor)); + debug_print("i32.div_u", *this, other, res); + return res; + } + + // i32.shl (Shift Left): *this << other (shift count masked by 31) + inline Num i32_shl(const Num &other) const { + uint32_t shift_amount = other.toUInt() & 0x1F; + uint32_t result_u = toUInt() << shift_amount; + Num res(static_cast(result_u)); + debug_print("i32.shl", *this, other, res); + return res; + } + + // i32.shr_s (Signed Shift Right): *this >> other (Arithmetic shift) + inline Num i32_shr_s(const Num &other) const { + // Wasm masks the shift amount by 31 (0x1F) + uint32_t shift_amount = other.toUInt() & 0x1F; + int32_t result_s = toInt() >> shift_amount; + Num res(result_s); + debug_print("i32.shr_s", *this, other, res); + return res; + } + + // i32.shr_u (Unsigned Shift Right): *this >>> other (Logical shift) + inline Num i32_shr_u(const Num &other) const { + // Wasm masks the shift amount by 31 (0x1F) + uint32_t shift_amount = other.toUInt() & 0x1F; + uint32_t result_u = toUInt() >> shift_amount; + Num res(static_cast(result_u)); + debug_print("i32.shr_u", *this, other, res); + return res; + } + + // i32.and (Bitwise AND) + inline Num i32_and(const Num &other) const { + uint32_t result_u = this->toUInt() & other.toUInt(); + Num res(static_cast(result_u)); + debug_print("i32.and", *this, other, res); + return res; + } + + // i32.xor (Bitwise XOR) + inline Num i32_xor(const Num &other) const { + uint32_t result_u = this->toUInt() ^ other.toUInt(); + Num res(static_cast(result_u)); + debug_print("i32.xor", *this, other, res); + return res; + } + + // f32 helpers: interpret low 32 bits of value as IEEE-754 float + static inline float f32_from_bits(uint32_t bits) { + union { + uint32_t i; + float f; + } u; + u.i = bits; + return u.f; + } + static inline uint32_t f32_to_bits(float f) { + union { + uint32_t i; + float f; + } u; + u.f = f; + return u.i; + } + static inline bool f32_is_nan(uint32_t bits) { + // Exponent all ones and mantissa non-zero -> NaN for IEEE-754 single + return (bits & 0x7F800000u) == 0x7F800000u && (bits & 0x007FFFFFu) != 0; + } + + // f32.add + inline Num f32_add(const Num &other) const { + uint32_t a_bits = toUInt(); + uint32_t b_bits = other.toUInt(); + float a = f32_from_bits(a_bits); + float b = f32_from_bits(b_bits); + float r = a + b; + uint32_t r_bits = f32_to_bits(r); + Num res(static_cast(r_bits)); + debug_print("f32.add", *this, other, res); + return res; + } + + // f32.sub + inline Num f32_sub(const Num &other) const { + uint32_t a_bits = toUInt(); + uint32_t b_bits = other.toUInt(); + float a = f32_from_bits(a_bits); + float b = f32_from_bits(b_bits); + float r = a - b; + uint32_t r_bits = f32_to_bits(r); + Num res(static_cast(r_bits)); + debug_print("f32.sub", *this, other, res); + return res; + } + + // f32.mul + inline Num f32_mul(const Num &other) const { + uint32_t a_bits = toUInt(); + uint32_t b_bits = other.toUInt(); + float a = f32_from_bits(a_bits); + float b = f32_from_bits(b_bits); + float r = a * b; + uint32_t r_bits = f32_to_bits(r); + Num res(static_cast(r_bits)); + debug_print("f32.mul", *this, other, res); + return res; + } + + // f32.div + inline Num f32_div(const Num &other) const { + uint32_t a_bits = toUInt(); + uint32_t b_bits = other.toUInt(); + float a = f32_from_bits(a_bits); + float b = f32_from_bits(b_bits); + float r = a / b; + uint32_t r_bits = f32_to_bits(r); + Num res(static_cast(r_bits)); + debug_print("f32.div", *this, other, res); + return res; + } + + // f32.eq : false if either is NaN + inline Num f32_eq(const Num &other) const { + uint32_t a_bits = toUInt(); + uint32_t b_bits = other.toUInt(); + if (f32_is_nan(a_bits) || f32_is_nan(b_bits)) { + Num res = WasmBool(false); + debug_print("f32.eq", *this, other, res); + return res; + } + float a = f32_from_bits(a_bits); + float b = f32_from_bits(b_bits); + Num res = WasmBool(a == b); + debug_print("f32.eq", *this, other, res); + return res; + } + + // f32.ne : true if values are unordered or not equal (i.e., NaN makes it + // true) + inline Num f32_ne(const Num &other) const { + uint32_t a_bits = toUInt(); + uint32_t b_bits = other.toUInt(); + // per wasm: if either is NaN, f32.ne is true + if (f32_is_nan(a_bits) || f32_is_nan(b_bits)) { + Num res = WasmBool(true); + debug_print("f32.ne", *this, other, res); + return res; + } + float a = f32_from_bits(a_bits); + float b = f32_from_bits(b_bits); + Num res = WasmBool(a != b); + debug_print("f32.ne", *this, other, res); + return res; + } + + // ordered comparisons: return false if any operand is NaN + inline Num f32_lt(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + if (f32_is_nan(a_bits) || f32_is_nan(b_bits)) + return WasmBool(false); + float a = f32_from_bits(a_bits), b = f32_from_bits(b_bits); + Num res = WasmBool(a < b); + debug_print("f32.lt", *this, other, res); + return res; + } + inline Num f32_le(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + if (f32_is_nan(a_bits) || f32_is_nan(b_bits)) + return WasmBool(false); + float a = f32_from_bits(a_bits), b = f32_from_bits(b_bits); + Num res = WasmBool(a <= b); + debug_print("f32.le", *this, other, res); + return res; + } + inline Num f32_gt(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + if (f32_is_nan(a_bits) || f32_is_nan(b_bits)) + return WasmBool(false); + float a = f32_from_bits(a_bits), b = f32_from_bits(b_bits); + Num res = WasmBool(a > b); + debug_print("f32.gt", *this, other, res); + return res; + } + inline Num f32_ge(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + if (f32_is_nan(a_bits) || f32_is_nan(b_bits)) + return WasmBool(false); + float a = f32_from_bits(a_bits), b = f32_from_bits(b_bits); + Num res = WasmBool(a >= b); + debug_print("f32.ge", *this, other, res); + return res; + } + + // f32.abs: clear sign bit + inline Num f32_abs() const { + uint32_t a_bits = toUInt(); + uint32_t r_bits = a_bits & 0x7FFFFFFFu; + Num res(static_cast(r_bits)); + debug_print("f32.abs", *this, *this, res); + return res; + } + + // f32.neg: flip sign bit + inline Num f32_neg() const { + uint32_t a_bits = toUInt(); + uint32_t r_bits = a_bits ^ 0x80000000u; + Num res(static_cast(r_bits)); + debug_print("f32.neg", *this, *this, res); + return res; + } + + // f32.min / f32.max: follow wasm-ish semantics: if either is NaN, return NaN + // (propagate) + inline Num f32_min(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + if (f32_is_nan(a_bits)) + return Num(static_cast(a_bits)); + if (f32_is_nan(b_bits)) + return Num(static_cast(b_bits)); + float a = f32_from_bits(a_bits), b = f32_from_bits(b_bits); + // If values compare equal choose one to preserve signed zero: pick the one + // whose sign bit is set for min when both zeros (so -0 wins for min). + if (a == b) { + if ((a_bits & 0x80000000u) || (b_bits & 0x80000000u)) + return Num( + static_cast((a_bits & 0x80000000u) ? a_bits : b_bits)); + return Num(static_cast(a_bits)); + } + float r = (a < b) ? a : b; + uint32_t r_bits = f32_to_bits(r); + Num res(static_cast(r_bits)); + debug_print("f32.min", *this, other, res); + return res; + } + + inline Num f32_max(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + if (f32_is_nan(a_bits)) + return Num(static_cast(a_bits)); + if (f32_is_nan(b_bits)) + return Num(static_cast(b_bits)); + float a = f32_from_bits(a_bits), b = f32_from_bits(b_bits); + if (a == b) { + if ((a_bits & 0x80000000u) || (b_bits & 0x80000000u)) + return Num( + static_cast((a_bits & 0x80000000u) ? b_bits : a_bits)); + return Num(static_cast(a_bits)); + } + float r = (a > b) ? a : b; + uint32_t r_bits = f32_to_bits(r); + Num res(static_cast(r_bits)); + debug_print("f32.max", *this, other, res); + return res; + } + + // f32.copysign: result has magnitude of lhs, sign of rhs + inline Num f32_copysign(const Num &other) const { + uint32_t a_bits = toUInt(), b_bits = other.toUInt(); + uint32_t r_bits = (a_bits & 0x7FFFFFFFu) | (b_bits & 0x80000000u); + Num res(static_cast(r_bits)); + debug_print("f32.copysign", *this, other, res); + return res; + } }; static Num I32V(int v) { return v; } static Num I64V(int64_t v) { return v; } -using Slice = std::vector; +static Num F32V(float f) { + union { + uint32_t i; + float f; + } u; + u.f = f; + return static_cast(u.i); +} + +static Num F64V(double d) { + union { + uint64_t i; + double d; + } u; + u.d = d; + return static_cast(u.i); +} const int STACK_SIZE = 1024 * 64; class Stack_t { public: - Stack_t() : count(0), stack_ptr(new Num[STACK_SIZE]) {} + Stack_t() : count(0), stack_ptr(new Num[STACK_SIZE]) { + size_t page_size = (size_t)sysconf(_SC_PAGESIZE); + // pre touch the memory to avoid page faults during execution + for (int i = 0; i < STACK_SIZE; i += page_size) { + stack_ptr[i] = Num(0); + } + } std::monostate push(Num &&num) { + Profile.step(StepProfileKind::PUSH); stack_ptr[count] = num; count++; return std::monostate{}; } std::monostate push(Num &num) { + Profile.step(StepProfileKind::PUSH); stack_ptr[count] = num; count++; return std::monostate{}; } Num pop() { + Profile.step(StepProfileKind::POP); #ifdef DEBUG - if (count == 0) { - throw std::runtime_error("Stack underflow"); - } + assert(count > 0 && "Stack underflow"); + printf("[Debug] popping a value %ld from stack, size of concrete stack is: " + "%d\n", + stack_ptr[count - 1].value, count); #endif Num num = stack_ptr[count - 1]; count--; @@ -81,6 +484,7 @@ class Stack_t { } Num peek() { + Profile.step(StepProfileKind::PEEK); #ifdef DEBUG if (count == 0) { throw std::runtime_error("Stack underflow"); @@ -92,6 +496,7 @@ class Stack_t { int32_t size() { return count; } void shift(int32_t offset, int32_t size) { + Profile.step(StepProfileKind::SHIFT); #ifdef DEBUG if (offset < 0) { throw std::out_of_range("Invalid offset: " + std::to_string(offset)); @@ -99,9 +504,13 @@ class Stack_t { if (size < 0) { throw std::out_of_range("Invalid size: " + std::to_string(size)); } + std::cout << "Shifting stack by offset " << offset << " and size " << size + << std::endl; + std::cout << "Current stack size: " << count << std::endl; #endif // shift last `size` of numbers forward of `offset` for (int32_t i = count - size; i < count; ++i) { + assert(i - offset >= 0); stack_ptr[i - offset] = stack_ptr[i]; } count -= offset; @@ -112,10 +521,24 @@ class Stack_t { for (int32_t i = 0; i < count; ++i) { std::cout << stack_ptr[count - i - 1].value << std::endl; } + std::cout << "End of Stack contents" << std::endl; } void initialize() { - // do nothing for now + // todo: remove this method + reset(); + } + + void reset() { count = 0; } + + void resize(int32_t new_size) { + assert(new_size >= 0); + count = new_size; + } + + void set_from_front(int32_t index, const Num &num) { + assert(index >= 0 && index < count); + stack_ptr[index] = num; } private: @@ -124,11 +547,16 @@ class Stack_t { }; static Stack_t Stack; -const int FRAME_SIZE = 1024; - +const int FRAME_SIZE = 1024 * 8; class Frames_t { public: - Frames_t() : count(0), stack_ptr(new Num[FRAME_SIZE]) {} + Frames_t() : count(0), stack_ptr(new Num[FRAME_SIZE]) { + size_t page_size = (size_t)sysconf(_SC_PAGESIZE); + // pre touch the memory to avoid page faults during execution + for (int i = 0; i < FRAME_SIZE; i += page_size) { + stack_ptr[i] = Num(0); + } + } std::monostate popFrame(std::int32_t size) { assert(size >= 0); @@ -137,15 +565,37 @@ class Frames_t { } Num get(std::int32_t index) { + Profile.step(StepProfileKind::GET); auto ret = stack_ptr[count - 1 - index]; return ret; } - void set(std::int32_t index, Num num) { stack_ptr[count - 1 - index] = num; } + void set(std::int32_t index, Num num) { + Profile.step(StepProfileKind::SET); + stack_ptr[count - 1 - index] = num; + } void pushFrame(std::int32_t size) { assert(size >= 0); count += size; + // Zero-initialize the new stack frames. + for (std::int32_t i = 0; i < size; ++i) { + stack_ptr[count - 1 - i] = Num(0); + } + } + + void reset() { count = 0; } + + size_t size() const { return count; } + + void set_from_front(int32_t index, const Num &num) { + assert(index >= 0 && index < count && "Index out of bounds"); + stack_ptr[index] = num; + } + + void resize(int32_t new_size) { + assert(new_size >= 0); + count = new_size; } private: @@ -154,6 +604,7 @@ class Frames_t { }; static Frames_t Frames; +static Frames_t Globals; static void initRand() { // for now, just do nothing @@ -164,32 +615,77 @@ static std::monostate unreachable() { throw std::runtime_error("Unreachable code reached"); } +static const int PRE_ALLOC_PAGES = 20; static int32_t pagesize = 65536; static int32_t page_count = 0; struct Memory_t { + // TODO: We assign a SymVal to each byte in memory std::vector memory; - Memory_t(int32_t init_page_count) : memory(init_page_count * pagesize) {} + int init_page_count; + int page_count; + int allocated_pages; + + Memory_t(int32_t init_page_count) + : memory(PRE_ALLOC_PAGES * pagesize), init_page_count(init_page_count), + page_count(init_page_count), allocated_pages(PRE_ALLOC_PAGES) {} int32_t loadInt(int32_t base, int32_t offset) { - return *reinterpret_cast(static_cast(memory.data()) + - base + offset); +#ifdef DEBUG + std::cout << "[Debug] loading int from memory at address: " + << (base + offset) << std::endl; +#endif + // just load a 4-byte integer from memory of the vector + int32_t addr = base + offset; + if (!(addr + 3 < memory.size())) { + throw std::runtime_error("Invalid memory access " + std::to_string(addr)); + } + int32_t result = 0; + // Little-endian: lowest byte at lowest address + for (int i = 0; i < 4; ++i) { + result |= static_cast(memory[addr + i]) << (8 * i); + } + return result; } std::monostate storeInt(int32_t base, int32_t offset, int32_t value) { - *reinterpret_cast(static_cast(memory.data()) + base + - offset) = value; + int32_t addr = base + offset; +#ifdef DEBUG + std::cout << "[Debug] storing int " << value << " to memory at address " + << addr << std::endl; +#endif + // Ensure we don't write out of bounds + if (!(addr + 3 < memory.size())) { + throw std::runtime_error("Invalid memory access " + std::to_string(addr)); + } + for (int i = 0; i < 4; ++i) { + memory[addr + i] = static_cast((value >> (8 * i)) & 0xFF); + // Optionally, update memory[addr + i].second (SymVal) if needed + } + return std::monostate{}; + } + + std::monostate store_byte(int32_t addr, uint8_t value) { + assert(addr < memory.size()); + memory[addr] = value; return std::monostate{}; } // grow memory by delta bytes when bytes > 0. return -1 if failed, return old // size when success int32_t grow(int32_t delta) { + Profile.step(StepProfileKind::MEM_GROW); if (delta <= 0) { - return memory.size(); + return page_count * pagesize; + } + + if (page_count + delta < allocated_pages) { + page_count += delta; + return page_count * pagesize; } try { + assert(false && "Use pre-allocated memory, should not reach here"); memory.resize(memory.size() + delta * pagesize); auto old_page_count = page_count; page_count += delta; @@ -198,6 +694,45 @@ struct Memory_t { return -1; } } + + void reset() { + page_count = init_page_count; + allocated_pages = PRE_ALLOC_PAGES; + for (int i = 0; i < memory.size() && i < page_count * pagesize; ++i) { + memory[i] = 0; + } + } +}; + +static Memory_t Memory(4); // 4 page memory + +struct FuncTable_t { + FuncTable_t() : table(20) {} + std::vector table; + + Func_t read(int32_t index) { + if (index < 0 || index >= table.size()) { + throw std::runtime_error("Function table read out of bounds: " + + std::to_string(index)); + } + if (!table[index]) { + assert(false); + throw std::runtime_error("Function table entry at index " + + std::to_string(index) + " is empty or invalid"); + } + return table[index]; + } + + std::monostate set(Num offset, int32_t index, Func_t func) { + if (index < 0 || index >= table.size()) { + throw std::runtime_error("Function table set out of bounds: " + + std::to_string(index)); + } + table[offset.toInt() + index] = func; + return std::monostate{}; + } }; -static Memory_t Memory(1); // 1 page memory \ No newline at end of file +static FuncTable_t FuncTable; + +#endif // WASM_CONCRETE_RT_HPP \ No newline at end of file diff --git a/headers/wasm/config.hpp b/headers/wasm/config.hpp new file mode 100644 index 000000000..037c62634 --- /dev/null +++ b/headers/wasm/config.hpp @@ -0,0 +1,64 @@ +#ifndef CONFIG_HPP +#define CONFIG_HPP + +// This file contains configuration settings for the concolic execution + +// If ENABLE_PROFILE_STEP defined, the compiled program will collect and print +// profiling how much steps of each data structure's operations are executed +#ifdef ENABLE_PROFILE_STEP +const bool PROFILE_STEP = true; +#else +const bool PROFILE_STEP = false; +#endif + +// If ENABLE_PROFILE_TIME defined, the compiled program will collect and print +// the profile of time spent in main loop and constraint solving +#ifdef ENABLE_PROFILE_TIME +const bool PROFILE_TIME = true; +#else +const bool PROFILE_TIME = false; +#endif + +// This variable define when concolic execution will stop +enum class ExploreMode { + EarlyExit, // Stop at the first error encountered + + ExitByCoverage // Exit when all syntactic branches are covered +}; + +#ifdef EARLY_EXIT +static const ExploreMode EXPLORE_MODE = ExploreMode::EarlyExit; +#elif defined(BY_COVERAGE) +static const ExploreMode EXPLORE_MODE = ExploreMode::ExitByCoverage; +#else +static const ExploreMode EXPLORE_MODE = ExploreMode::EarlyExit; +#endif + +// This variable decides whether we enable the snapshot reuse optimization +#ifdef NO_REUSE +static const bool REUSE_SNAPSHOT = false; +#else +static const bool REUSE_SNAPSHOT = true; +#endif + +// If we use immutable data structures for symbolic states to reduce the cost of +// copying. +#ifdef USE_IMM +static const bool IMMUTABLE_SYMS = true; +#else +static const bool IMMUTABLE_SYMS = false; +#endif + +#ifdef INTERACTIVE +static const bool INTERACTIVE_MODE = true; +#else +static const bool INTERACTIVE_MODE = false; +#endif + +#ifdef USE_COST_MODEL +static const bool ENABLE_COST_MODEL = true; +#else +static const bool ENABLE_COST_MODEL = false; +#endif + +#endif // CONFIG_HPP \ No newline at end of file diff --git a/headers/wasm/controls.hpp b/headers/wasm/controls.hpp new file mode 100644 index 000000000..dd25f78cb --- /dev/null +++ b/headers/wasm/controls.hpp @@ -0,0 +1,69 @@ + +#ifndef WASM_CONTROLS_HPP +#define WASM_CONTROLS_HPP + +#include + +#include +#include +#include + +class MContRepr; +struct MCont_t { + std::shared_ptr ptr; + MCont_t() : ptr(nullptr) {} + MCont_t(const MCont_t &p) : ptr(p.ptr) {} + MCont_t(std::shared_ptr p) : ptr(p) {} + MCont_t(std::function haltK) + : ptr(std::make_shared(haltK)) {} + bool is_null() const { return ptr == nullptr; } + + std::monostate enter(); +}; +using Cont_t = std::function; +class MContRepr { +public: + MContRepr(Cont_t cont, MCont_t mcont) : cont(cont), mcont(mcont) {} + + MContRepr(std::function haltK) + : cont([=](MCont_t) { + // std::cout << "Halting the program..." << std::endl; + + return haltK(std::monostate{}); + }), + mcont() {} + + MContRepr() : cont(nullptr), mcont() {} + + std::monostate enter() { + // std::cout << "Entering MCont\n"; + // std::cout << "Cont cont: " << (cont ? "valid" : "null") << "\n"; + // std::cout << "MCont mcont: " << (mcont ? "valid" : "null") << "\n"; + if (mcont.is_null()) { + return cont(std::make_shared( + MContRepr())); // when mcont is null, we pass a dummy MContRepr + } + return cont(mcont); + } + +private: + Cont_t cont; + MCont_t mcont; +}; + +inline MCont_t prependCont(Cont_t k, MCont_t mcont) { + return std::make_shared(k, mcont); +} + +inline std::monostate MCont_t::enter() { return ptr->enter(); } + +struct Control { + Cont_t cont; + MCont_t mcont; + + Control(Cont_t cont, MCont_t mcont) : cont(cont), mcont(mcont) {} +}; + +using Func_t = std::function; + +#endif // WASM_CONTROLS_HPP \ No newline at end of file diff --git a/headers/wasm/heap_mem_bookkeeper.hpp b/headers/wasm/heap_mem_bookkeeper.hpp new file mode 100644 index 000000000..c4cc7313f --- /dev/null +++ b/headers/wasm/heap_mem_bookkeeper.hpp @@ -0,0 +1,24 @@ +#ifndef HEAP_MEM_BOOKKEEPER_HPP +#define HEAP_MEM_BOOKKEEPER_HPP + +#include +#include + +// Todo: remove this later, this is just a workaround to make sure that the +// SymVals' memory will not be freed during the main execution. +// We can leave the SymVal's memory unmanaged if reference counting is not +// performant +template struct MemBookKeeper { + std::set> allocated; + + template + std::shared_ptr allocate(Args &&...args) { + auto ptr = std::make_shared(std::forward(args)...); + // allocated.insert(ptr); + return ptr; + } + + void clear() { allocated.clear(); } +}; + +#endif // HEAP_MEM_BOOKKEEPER_HPP \ No newline at end of file diff --git a/headers/wasm/output_report.hpp b/headers/wasm/output_report.hpp new file mode 100644 index 000000000..ef8de2a0e --- /dev/null +++ b/headers/wasm/output_report.hpp @@ -0,0 +1,50 @@ +#ifndef WASM_OUTPUT_REPORT_HPP +#define WASM_OUTPUT_REPORT_HPP + +#include "profile.hpp" +#include "symbolic_rt.hpp" +#include "config.hpp" +#include + +inline void dump_all_summary_json(const Profile_t &profile, + const OverallResult &overall) { + // use environment variable OUTPUT_FILE to config particular output profiling file + const char *output_file = std::getenv("OUTPUT_FILE"); + if (output_file == nullptr) { + return; + } + + std::filesystem::path report_path(output_file); + + auto parent = report_path.parent_path(); + if (!parent.empty()) { + std::error_code ec; + std::filesystem::create_directories(parent, ec); + if (ec) { + throw std::runtime_error("Failed to create output directory: " + + ec.message()); + } + } + + std::ofstream ofs(report_path); + if (!ofs.is_open()) { + throw std::runtime_error("Failed to open " + report_path.string() + + " for writing"); + } + + // Simple JSON dump (pretty-printed) + ofs << "{\n"; + ofs << " \"unexplored_count\": " << overall.unexplored_count << ",\n"; + ofs << " \"finished_count\": " << overall.finished_count << ",\n"; + ofs << " \"failed_count\": " << overall.failed_count << ",\n"; + ofs << " \"not_to_explore_count\": " << overall.not_to_explore_count + << ",\n"; + ofs << " \"unreachable_count\": " << overall.unreachable_count; + if (PROFILE_STEP || PROFILE_TIME) { + ofs << ",\n"; + profile.write_as_json(ofs); + } + ofs << "}\n"; + ofs.close(); +} +#endif // WASM_OUTPUT_REPORT_HPP \ No newline at end of file diff --git a/headers/wasm/profile.hpp b/headers/wasm/profile.hpp new file mode 100644 index 000000000..7afd4416f --- /dev/null +++ b/headers/wasm/profile.hpp @@ -0,0 +1,236 @@ +#ifndef PROFILE_HPP +#define PROFILE_HPP + +#include "config.hpp" +#include "utils.hpp" +#include +#include +#include +#include +#include + +enum class StepProfileKind { + PUSH, + POP, + PEEK, + SHIFT, + SET, + GET, + BINARY, + TREE_FILL, + CURSOR_MOVE, + MEM_GROW, + SNAPSHOT_CREATE, + SYM_EVAL, + OperationCount // keep this as the last element, this is used to get the + // number of kinds of operations +}; + +enum class TimeProfileKind { + INSTR, + SOLVER, + RESUME_SNAPSHOT, + COUNT_SYM_SIZE, + TimeOperationCount // keep this as the last element, this is used to get the + // number of kinds of operations +}; + +class Profile_t { +public: + Profile_t() : step_count(0) {} + std::monostate step() { + if (PROFILE_STEP) + step_count++; + return std::monostate(); + } + std::monostate step(StepProfileKind op) { + if (PROFILE_STEP) + op_count[static_cast(op)]++; + return std::monostate(); + } + void print_summary() { + if (PROFILE_STEP) { + std::cout << "Profile Summary:" << std::endl; + std::cout << "Total PUSH operations: " + << op_count[static_cast(StepProfileKind::PUSH)] + << std::endl; + std::cout << "Total POP operations: " + << op_count[static_cast(StepProfileKind::POP)] + << std::endl; + std::cout << "Total PEEK operations: " + << op_count[static_cast(StepProfileKind::PEEK)] + << std::endl; + std::cout << "Total SHIFT operations: " + << op_count[static_cast(StepProfileKind::SHIFT)] + << std::endl; + std::cout << "Total SET operations: " + << op_count[static_cast(StepProfileKind::SET)] + << std::endl; + std::cout << "Total GET operations: " + << op_count[static_cast(StepProfileKind::GET)] + << std::endl; + std::cout << "Total BINARY operations: " + << op_count[static_cast(StepProfileKind::BINARY)] + << std::endl; + std::cout + << "Total TREE_FILL operations: " + << op_count[static_cast(StepProfileKind::TREE_FILL)] + << std::endl; + std::cout + << "Total CURSOR_MOVE operations: " + << op_count[static_cast(StepProfileKind::CURSOR_MOVE)] + << std::endl; + std::cout << "Total other instructions executed: " << step_count + << std::endl; + std::cout << "Total MEM_GROW operations: " + << op_count[static_cast(StepProfileKind::MEM_GROW)] + << std::endl; + std::cout << "Total SNAPSHOT_CREATE operations: " + << op_count[static_cast( + StepProfileKind::SNAPSHOT_CREATE)] + << std::endl; + std::cout << "Total SYM_EVAL operations: " + << op_count[static_cast(StepProfileKind::SYM_EVAL)] + << std::endl; + std::cout << "Total time for instruction execution (s): " + << std::setprecision(15) << execution_time << std::endl; + } + if (PROFILE_TIME) { + std::cout << "Time Profile Summary:" << std::endl; + std::cout << "Total time in instruction execution (s): " + << std::setprecision(15) + << time_count[static_cast(TimeProfileKind::INSTR)] + << std::endl; + std::cout << "Total time in solver (s): " << std::setprecision(15) + << time_count[static_cast(TimeProfileKind::SOLVER)] + << std::endl; + std::cout << "Total time in resuming from snapshot (s): " + << std::setprecision(15) + << time_count[static_cast( + TimeProfileKind::RESUME_SNAPSHOT)] + << std::endl; + std::cout << "Total time in counting symbolic size (s): " + << std::setprecision(15) + << time_count[static_cast( + TimeProfileKind::COUNT_SYM_SIZE)] + << std::endl; + } + } + + void write_as_json(std::ostream &os) const { + os << " \"profile_summary\": {\n"; + if (PROFILE_STEP) { + os << " \"total_push_operations\": " + << op_count[static_cast(StepProfileKind::PUSH)] << ",\n"; + os << " \"total_pop_operations\": " + << op_count[static_cast(StepProfileKind::POP)] << ",\n"; + os << " \"total_peek_operations\": " + << op_count[static_cast(StepProfileKind::PEEK)] << ",\n"; + os << " \"total_shift_operations\": " + << op_count[static_cast(StepProfileKind::SHIFT)] << ",\n"; + os << " \"total_set_operations\": " + << op_count[static_cast(StepProfileKind::SET)] << ",\n"; + os << " \"total_get_operations\": " + << op_count[static_cast(StepProfileKind::GET)] << ",\n"; + os << " \"total_binary_operations\": " + << op_count[static_cast(StepProfileKind::BINARY)] + << ",\n"; + os << " \"total_tree_fill_operations\": " + << op_count[static_cast(StepProfileKind::TREE_FILL)] + << ",\n"; + os << " \"total_cursor_move_operations\": " + << op_count[static_cast(StepProfileKind::CURSOR_MOVE)] + << ",\n"; + os << " \"total_other_instructions_executed\": " << step_count + << ",\n"; + os << " \"total_mem_grow_operations\": " + << op_count[static_cast(StepProfileKind::MEM_GROW)] + << ",\n"; + os << " \"total_snapshot_create_operations\": " + << op_count[static_cast(StepProfileKind::SNAPSHOT_CREATE)] + << ",\n"; + os << " \"total_sym_eval_operations\": " + << op_count[static_cast(StepProfileKind::SYM_EVAL)] + << "\n"; + } + if (PROFILE_TIME) { + os << " \"total_time_instruction_execution_s\": " + << std::setprecision(15) + << time_count[static_cast(TimeProfileKind::INSTR)] + << ",\n"; + os << " \"total_time_solver_s\": " << std::setprecision(15) + << time_count[static_cast(TimeProfileKind::SOLVER)] + << ",\n"; + os << " \"total_time_resuming_from_snapshot_s\": " + << std::setprecision(15) + << time_count[static_cast( + TimeProfileKind::RESUME_SNAPSHOT)] + << ",\n"; + os << " \"total_time_counting_symbolic_size_s\": " + << std::setprecision(15) + << time_count[static_cast( + TimeProfileKind::COUNT_SYM_SIZE)] + << "\n"; + } + os << " }\n"; + } + + // record the time spent in main instruction execution, in seconds + void add_instruction_time(TimeProfileKind kind, double time) { + time_count[static_cast(kind)] += time; + } + + void remove_instruction_time(TimeProfileKind kind, double time) { + time_count[static_cast(kind)] -= time; + } + + int step_count; + std::array(StepProfileKind::OperationCount)> + op_count; + std::array(TimeProfileKind::TimeOperationCount)> + time_count; + double execution_time = 0.0; +}; + +static Profile_t Profile; + +class ManagedTimer { +public: + ManagedTimer() = delete; + ManagedTimer(TimeProfileKind kind) : kind(kind) { + start = std::chrono::high_resolution_clock::now(); + } + ~ManagedTimer() { + auto end = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = end - start; + Profile.add_instruction_time(kind, elapsed.count()); + } + +private: + TimeProfileKind kind; + std::chrono::high_resolution_clock::time_point start; +}; + +struct CostManager_t { + int instr_cost; + + CostManager_t() : instr_cost(0) {} + + std::monostate add_instr_cost(int n) { + instr_cost += n; + return {}; + } + + int dump_instr_cost() { + auto cost = instr_cost; + instr_cost = 0; + return normalize_cost(cost); + } + + int normalize_cost(int cost) { return 1 * cost; } +}; + +static CostManager_t CostManager; + +#endif // PROFILE_HPP \ No newline at end of file diff --git a/headers/wasm/smt_solver.hpp b/headers/wasm/smt_solver.hpp new file mode 100644 index 000000000..0dc09f127 --- /dev/null +++ b/headers/wasm/smt_solver.hpp @@ -0,0 +1,213 @@ +#ifndef SMT_SOLVER_HPP +#define SMT_SOLVER_HPP + +#include "concrete_rt.hpp" +#include "symbolic_rt.hpp" +#include "utils.hpp" +#include "wasm/profile.hpp" +#include "z3++.h" +#include +#include +#include +#include +#include +#include +#include + +class Solver { +public: + Solver() {} + std::optional> + solve(std::vector &conditions) { + z3::solver z3_solver(z3_ctx); + z3::check_result solver_result; + { + auto timer = ManagedTimer(TimeProfileKind::SOLVER); + // make an conjunction of all conditions + auto conjunction = to_z3_conjunction(conditions); + // call z3 to solve the condition + // NOTE: half of the solver time is spent in solver.add + z3_solver.add(conjunction); + solver_result = z3_solver.check(); + } + switch (solver_result) { + case z3::unsat: + return std::nullopt; // No solution found + case z3::sat: { + z3::model model = z3_solver.get_model(); + NumMap result; + // Reference: + // https://github.com/Z3Prover/z3/blob/master/examples/c%2B%2B/example.cpp#L59 + GENSYM_INFO("Solved Z3 model"); + GENSYM_INFO(model); + for (unsigned i = 0; i < model.size(); ++i) { + z3::func_decl var = model[i]; + z3::expr value = model.get_const_interp(var); + std::string name = var.name().str(); + if (starts_with(name, "s_")) { + int id = std::stoi(name.substr(2)); + result[id] = Num(value.get_numeral_int64()); + } else { + GENSYM_INFO("Find a variable that is not created by GenSym: " + name); + } + } + return std::optional>( + std::in_place, std::move(result), std::move(model)); + } + case z3::unknown: + throw std::runtime_error("Z3 solver returned unknown status"); + } + return std::nullopt; // Should not reach here + } + z3::expr build_z3_expr(SymVal &sym_val); + +private: + z3::expr to_z3_conjunction(std::vector &conditions) { + z3::expr conjunction = z3_ctx.bool_val(true); + for (auto &cond : conditions) { + auto z3_cond = build_z3_expr(cond); + conjunction = conjunction && z3_cond != z3_ctx.bv_val(0, 32); + } +#ifdef DEBUG + std::cout << "Symbolic conditions size: " << conditions.size() << std::endl; + std::cout << "Solving conditions: " << conjunction << std::endl; +#endif + return conjunction; + } + + z3::context z3_ctx; + z3::expr build_z3_expr_aux(SymVal &sym_val); +}; + +static Solver solver; + +inline z3::expr Solver::build_z3_expr_aux(SymVal &sym_val) { + if (auto sym = std::dynamic_pointer_cast(sym_val.symptr)) { + return z3_ctx.bv_const(("s_" + std::to_string(sym->get_id())).c_str(), 32); + } else if (auto concrete = + std::dynamic_pointer_cast(sym_val.symptr)) { + return z3_ctx.bv_val(concrete->value.value, 32); + } else if (auto smallbv = + std::dynamic_pointer_cast(sym_val.symptr)) { + return z3_ctx.bv_val(smallbv->get_value(), smallbv->get_size()); + } else if (auto binary = + std::dynamic_pointer_cast(sym_val.symptr)) { + auto bit_width = 32; + z3::expr zero_bv = + z3_ctx.bv_val(0, bit_width); // Represents 0 as a 32-bit bitvector + z3::expr one_bv = + z3_ctx.bv_val(1, bit_width); // Represents 1 as a 32-bit bitvector + + z3::expr left = build_z3_expr(binary->lhs); + z3::expr right = build_z3_expr(binary->rhs); + // TODO: make sure the semantics of these operations are aligned with wasm + switch (binary->op) { + case EQ: { + auto temp_bool = left == right; + return z3::ite(temp_bool, one_bv, zero_bv); + } + case NEQ: { + auto temp_bool = left != right; + return z3::ite(temp_bool, one_bv, zero_bv); + } + case LT: { + auto temp_bool = left < right; + return z3::ite(temp_bool, one_bv, zero_bv); + } + case LTU: { + auto temp_bool = z3::ult(left, right); + return z3::ite(temp_bool, one_bv, zero_bv); + } + case LEQ: { + auto temp_bool = left <= right; + return z3::ite(temp_bool, one_bv, zero_bv); + } + case GT: { + auto temp_bool = left > right; + return z3::ite(temp_bool, one_bv, zero_bv); + } + case GTU: { + auto temp_bool = z3::ugt(left, right); + return z3::ite(temp_bool, one_bv, zero_bv); + } + case GEU: { + auto temp_bool = z3::uge(left, right); + return z3::ite(temp_bool, one_bv, zero_bv); + } + case SHR: { + return z3::lshr(left, right); + } + case GEQ: { + auto temp_bool = left >= right; + return z3::ite(temp_bool, one_bv, zero_bv); + } + case ADD: { + return left + right; + } + case SUB: { + return left - right; + } + case MUL: { + return left * right; + } + case DIV: { + return left / right; + } + case B_AND: { + return left & right; + } + case B_XOR: { + return left ^ right; + } + case CONCAT: { + return z3::concat(left, right); + } + default: + throw std::runtime_error("Operation not supported: " + + std::to_string(binary->op)); + } + } else if (auto extract = dynamic_cast(sym_val.symptr.get())) { + assert(extract); + int high = extract->high * 8 - 1; + int low = extract->low * 8 - 8; + auto s = build_z3_expr(extract->value); + auto res = s.extract(high, low); + return res; + } + throw std::runtime_error("Unsupported symbolic value type"); +} + +inline z3::expr Solver::build_z3_expr(SymVal &sym_val) { + if (sym_val.symptr->z3_expr()) { + return *sym_val.symptr->z3_expr(); + } + auto e = build_z3_expr_aux(sym_val); + sym_val.symptr->update_z3_expr(e); + return e; +} + +inline EvalRes eval_sym_expr_by_model(const SymVal &sym, z3::model &model) { + auto expr = solver.build_z3_expr(const_cast(sym)); + // let z3 decide the value of symbols that are not in the model + z3::expr value = model.eval(expr, true); + // every value is bitvector + int width = expr.get_sort().bv_size(); + return EvalRes(Num(value.get_numeral_int64()), width); +} + +inline std::monostate GENSYM_SYM_ASSERT(SymVal &sym_cond) { + std::vector conds = ExploreTree.collect_current_path_conds(); + conds.push_back(sym_cond.negate()); + auto start = std::chrono::steady_clock::now(); + auto result = solver.solve(conds); + auto end = std::chrono::steady_clock::now(); + auto time_need_to_be_removed = std::chrono::duration(end - start); + Profile.remove_instruction_time(TimeProfileKind::INSTR, time_need_to_be_removed.count()); + if (result.has_value()) { + std::cout << "Symbolic assertion failed" << std::endl; + throw std::runtime_error("Symbolic assertion failed"); + } + return std::monostate{}; +} + +#endif // SMT_SOLVER_HPP \ No newline at end of file diff --git a/headers/wasm/symbolic_rt.hpp b/headers/wasm/symbolic_rt.hpp new file mode 100644 index 000000000..b47c0e657 --- /dev/null +++ b/headers/wasm/symbolic_rt.hpp @@ -0,0 +1,1682 @@ +#ifndef WASM_SYMBOLIC_RT_HPP +#define WASM_SYMBOLIC_RT_HPP + +#include "concrete_rt.hpp" +#include "config.hpp" +#include "controls.hpp" +#include "heap_mem_bookkeeper.hpp" +#include "immer/map.hpp" +#include "immer/map_transient.hpp" +#include "immer/vector_transient.hpp" +#include "profile.hpp" +#include "utils.hpp" +#include "z3++.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Symbolic { +public: + Symbolic() {} + virtual ~Symbolic() = default; // Make Symbolic polymorphic + virtual int size() = 0; + virtual std::optional z3_expr() { return _z3_expr; } + virtual void update_z3_expr(z3::expr expr) { _z3_expr = expr; } + +private: + std::optional _z3_expr; +}; + +static int max_id = 0; + +class Symbol : public Symbolic { +public: + // TODO: add type information to determine the size of bitvector + // for now we just assume that only i32 will be used + Symbol(int id) : id(id) { max_id = std::max(max_id, id); } + int get_id() const { return id; } + int size() override { return 1; } + +private: + int id; +}; + +class SymConcrete : public Symbolic { +public: + Num value; + SymConcrete(Num num) : value(num) {} + int size() override { return 1; } +}; + +class SmallBV : public Symbolic { +public: + SmallBV(int width, int64_t value) : width(width), value(value) {} + int get_size() const { return width; } + int64_t get_value() const { return value; } + int size() override { return 1; } + +private: + int width; // in bits + int64_t value; +}; +struct SymBinary; + +enum Operation { + ADD, // Addition + SUB, // Subtraction + MUL, // Multiplication + DIV, // Division + EQ, // Equal + NEQ, // Not equal + LT, // Less than + LTU, // Unsigned less than + LEQ, // Less than or equal + GT, // Greater than + GTU, // Unsigned greater than + GEQ, // Greater than or equal + GEU, // Unsigned greater than or equal + SHR, // Shift right + B_AND, // Bitwise AND + B_XOR, // Bitwise XOR + CONCAT, // Byte-level concatenation +}; +static MemBookKeeper SymBookKeeper; + +static std::shared_ptr ZERO = + SymBookKeeper.allocate(I32V(0)); +static std::shared_ptr ZeroByte = + SymBookKeeper.allocate(8, 0); + +struct SymVal { + std::shared_ptr symptr; + + SymVal() : symptr(ZERO) {} + SymVal(std::shared_ptr symptr) : symptr(symptr) {} + + // data structure operations + SymVal makeSymbolic() const; + + // bitvector arithmetic operations + SymVal is_zero() const; + SymVal add(const SymVal &other) const; + SymVal minus(const SymVal &other) const; + SymVal mul(const SymVal &other) const; + SymVal div(const SymVal &other) const; + SymVal eq(const SymVal &other) const; + SymVal neq(const SymVal &other) const; + SymVal lt(const SymVal &other) const; + SymVal ltu(const SymVal &other) const; + SymVal le(const SymVal &other) const; + SymVal gt(const SymVal &other) const; + SymVal gtu(const SymVal &other) const; + SymVal ge(const SymVal &other) const; + SymVal geu(const SymVal &other) const; + SymVal shr(const SymVal &other) const; + SymVal negate() const; + SymVal bitwise_and(const SymVal &other) const; + SymVal bitwise_xor(const SymVal &other) const; + SymVal concat(const SymVal &other) const; + SymVal extract(int high, int low) const; + // TODO: add bitwise operations, and use the underlying bitvector theory + + bool is_concrete() const; + int size() const { return symptr->size(); } + +private: + static SymVal make_binary(Operation op, const SymVal &lhs, const SymVal &rhs); +}; + +static SymVal make_symbolic(int index) { + return SymVal(SymBookKeeper.allocate(index)); +} + +static std::unordered_map concrete_pool; + +inline SymVal Concrete(Num num) { + if (concrete_pool.find(num.toInt()) != concrete_pool.end()) { + return concrete_pool[num.toInt()]; + } + + auto new_val = SymVal(SymBookKeeper.allocate(num)); + concrete_pool[num.toInt()] = new_val; + return new_val; +} + +// Extract is different from other operations, it only has one symbolic operand, +// the other two operands are constants +// Extract from value, both high and low are inclusive byte indexes +struct SymExtract : Symbolic { + SymVal value; + int high; + int low; + int size_cache = -1; + + SymExtract(SymVal value, int high, int low) + : value(value), high(high), low(low) {} + int size() override { + if (size_cache != -1) { + return size_cache; + } + size_cache = 1 + value.size(); + return size_cache; + } +}; + +struct SymBinary : Symbolic { + Operation op; + SymVal lhs; + SymVal rhs; + int size_cache = -1; + + SymBinary(Operation op, SymVal lhs, SymVal rhs) + : op(op), lhs(lhs), rhs(rhs) {} + int size() override { + if (size_cache != -1) { + return size_cache; + } + size_cache = 1 + lhs.size() + rhs.size(); + return size_cache; + } +}; + +inline SymVal SymVal::add(const SymVal &other) const { + return make_binary(ADD, *this, other); +} + +inline SymVal SymVal::minus(const SymVal &other) const { + return make_binary(SUB, *this, other); +} + +inline SymVal SymVal::mul(const SymVal &other) const { + return make_binary(MUL, *this, other); +} + +inline SymVal SymVal::div(const SymVal &other) const { + return make_binary(DIV, *this, other); +} + +inline SymVal SymVal::eq(const SymVal &other) const { + return make_binary(EQ, *this, other); +} + +inline SymVal SymVal::neq(const SymVal &other) const { + return make_binary(NEQ, *this, other); +} + +inline SymVal SymVal::lt(const SymVal &other) const { + return make_binary(LT, *this, other); +} + +inline SymVal SymVal::ltu(const SymVal &other) const { + // for now, we treat unsigned less than as signed less than + return make_binary(LTU, *this, other); +} + +inline SymVal SymVal::le(const SymVal &other) const { + return make_binary(LEQ, *this, other); +} + +inline SymVal SymVal::gt(const SymVal &other) const { + return make_binary(GT, *this, other); +} + +inline SymVal SymVal::gtu(const SymVal &other) const { + return make_binary(GTU, *this, other); +} + +inline SymVal SymVal::ge(const SymVal &other) const { + return make_binary(GEQ, *this, other); +} + +inline SymVal SymVal::geu(const SymVal &other) const { + return make_binary(GEU, *this, other); +} + +inline SymVal SymVal::shr(const SymVal &other) const { + return make_binary(SHR, *this, other); +} + +inline SymVal SymVal::is_zero() const { + return make_binary(EQ, *this, Concrete(I32V(0))); +} + +inline SymVal SymVal::negate() const { + return make_binary(EQ, *this, Concrete(I32V(0))); +} + +inline SymVal SymVal::concat(const SymVal &other) const { + return make_binary(CONCAT, *this, other); +} + +inline SymVal SymVal::extract(int high, int low) const { + assert(high >= low && "Invalid extract range"); + return SymVal(SymBookKeeper.allocate(*this, high, low)); +} + +inline SymVal SymVal::bitwise_and(const SymVal &other) const { + return make_binary(B_AND, *this, other); +} + +inline SymVal SymVal::bitwise_xor(const SymVal &other) const { + return make_binary(B_XOR, *this, other); +} + +inline SymVal SymVal::make_binary(Operation op, const SymVal &lhs, + const SymVal &rhs) { + assert(lhs.symptr != nullptr && rhs.symptr != nullptr); + return SymVal(SymBookKeeper.allocate(op, lhs, rhs)); +} +static std::unordered_map SymbolCache; + +inline SymVal SymVal::makeSymbolic() const { + auto concrete = dynamic_cast(symptr.get()); + if (concrete) { + // If the symbolic value is a concrete value, use it to create a symbol + auto id = concrete->value.toInt(); + auto it = SymbolCache.find(id); + if (it != SymbolCache.end()) { + return it->second; + } + auto sym = Symbol(id); + auto ptr = SymBookKeeper.allocate(sym); + return SymVal(ptr); + + } else { + throw std::runtime_error( + "Cannot make symbolic a non-concrete symbolic value"); + } +} + +inline bool SymVal::is_concrete() const { + return dynamic_cast(symptr.get()) != nullptr; +} + +template inline bool allConcrete(const Args &...args) { + static_assert((std::is_same_v && ...), + "all_concrete only accepts SymVal arguments"); + return (... && args.is_concrete()); +} + +class Snapshot_t; + +class SymStack_t { +public: + void push(SymVal val) { + // Push a symbolic value to the stack + stack.push_back(val); + } + + SymVal pop() { + // Pop a symbolic value from the stack + +#ifdef DEBUG + printf("[Debug] poping from stack, size of symbolic stack is: %zu\n", + stack.size()); +#endif +#ifdef USE_IMM + auto ret = *(stack.end() - 1); + stack.take(stack.size() - 1); + return ret; +#else + auto ret = stack.back(); + stack.pop_back(); + return ret; +#endif + } + + SymVal peek() { return *(stack.end() - 1); } + + std::monostate shift(int32_t offset, int32_t size) { + auto n = stack.size(); + for (size_t i = n - size; i < n; ++i) { + assert(i - offset >= 0); +#ifdef USE_IMM + stack.set(i - offset, stack[i]); +#else + stack[i - offset] = stack[i]; +#endif + } +#ifdef USE_IMM + stack.take(n - offset); +#else + stack.resize(n - offset); +#endif + return std::monostate(); + } + + void reset() { +// Reset the symbolic stack +#ifdef USE_IMM + stack = immer::vector_transient(); +#else + stack.clear(); +#endif + } + + size_t size() const { return stack.size(); } + + SymVal operator[](size_t index) const { return stack[index]; } + + int cost_of_copy() const { + int cost = 0; + for (size_t i = 0; i < stack.size(); ++i) { + cost += stack[i].size(); + } + return cost; + } + +private: +#ifdef USE_IMM + immer::vector_transient stack; +#else + std::vector stack; +#endif +}; + +static SymStack_t SymStack; + +class SymFrames_t { + +public: + void pushFrame(int size) { + // Push a new frame with the given size +#ifdef USE_IMM + for (int i = 0; i < size; ++i) { + stack.push_back(SymVal()); + } +#else + stack.resize(size + stack.size()); +#endif + } + std::monostate popFrame(int size) { + // Pop the frame of the given size + +#ifdef USE_IMM + stack.take(stack.size() - size); +#else + stack.resize(stack.size() - size); +#endif + return std::monostate(); + } + + SymVal get(int index) { + // Get the symbolic value at the given frame index + auto res = stack[stack.size() - 1 - index]; + return res; + } + + void set(int index, SymVal val) { + // Set the symbolic value at the given index + assert(val.symptr != nullptr); +#ifdef USE_IMM + stack.set(stack.size() - 1 - index, val); +#else + stack[stack.size() - 1 - index] = val; +#endif + } + + void reset() { + // Reset the symbolic frames + +#ifdef USE_IMM + stack = immer::vector_transient(); +#else + stack.clear(); +#endif + } + + size_t size() const { return stack.size(); } + + SymVal operator[](size_t index) const { return stack[index]; } + + int cost_of_copy() const { + int cost = 0; + for (size_t i = 0; i < stack.size(); ++i) { + cost += stack[i].size(); + } + return cost; + } + +private: +#ifdef USE_IMM + immer::vector_transient stack; +#else + std::vector stack; +#endif +}; + +struct NodeBox; +struct SymEnv_t; + +class SymMemory_t { +public: +#ifdef USE_IMM + immer::map_transient memory; +#else + std::unordered_map memory; +#endif + + SymVal loadSymByte(int32_t addr) { +// if the address is not in the memory, it must be a zero-initialized memory +#ifdef USE_IMM + auto it = memory.find(addr); + if (it != nullptr) { + return *it; + } else { + auto s = SymVal(ZeroByte); + return s; + } +#else + auto it = memory.find(addr); + SymVal s = (it != memory.end()) ? it->second : SymVal(ZeroByte); + return s; +#endif + } + + SymVal loadSym(int32_t base, int32_t offset) { + // calculate the real address + +#ifdef USE_IMM + int32_t addr = base + offset; + auto it = memory.find(addr); + SymVal s0 = it ? *it : SymVal(ZeroByte); + it = memory.find(addr + 1); + SymVal s1 = it ? *it : SymVal(ZeroByte); + it = memory.find(addr + 2); + SymVal s2 = it ? *it : SymVal(ZeroByte); + it = memory.find(addr + 3); + SymVal s3 = it ? *it : SymVal(ZeroByte); + + return s3.concat(s2).concat(s1).concat(s0); +#else + int32_t addr = base + offset; + auto it = memory.find(addr); + SymVal s0 = (it != memory.end()) ? it->second : SymVal(ZeroByte); + it = memory.find(addr + 1); + SymVal s1 = (it != memory.end()) ? it->second : SymVal(ZeroByte); + it = memory.find(addr + 2); + SymVal s2 = (it != memory.end()) ? it->second : SymVal(ZeroByte); + it = memory.find(addr + 3); + SymVal s3 = (it != memory.end()) ? it->second : SymVal(ZeroByte); + + return s3.concat(s2).concat(s1).concat(s0); +#endif + } + + // when loading a symval, we need to concat 4 symbolic values + // This sounds terribly bad for SMT... + // Load a 4-byte symbolic value from memory + // Store a 4-byte symbolic value to memory + std::monostate storeSym(int32_t base, int32_t offset, SymVal value) { + int32_t addr = base + offset; + // Extract 4 bytes from that symbol + SymVal s0 = value.extract(1, 1); + SymVal s1 = value.extract(2, 2); + SymVal s2 = value.extract(3, 3); + SymVal s3 = value.extract(4, 4); +#ifdef USE_IMM + memory.set(addr, s0); + memory.set(addr + 1, s1); + memory.set(addr + 2, s2); + memory.set(addr + 3, s3); +#else + memory[addr] = s0; + memory[addr + 1] = s1; + memory[addr + 2] = s2; + memory[addr + 3] = s3; +#endif + return std::monostate{}; + } + + std::monostate reset() { +#ifdef USE_IMM + memory = immer::map_transient(); +#else + memory.clear(); +#endif + return std::monostate{}; + } + + int cost_of_copy() const { +#ifdef USE_IMM + // If we use immer, the copy cost should be negligible + return 0; +#else + return memory.size(); +#endif + } +}; + +static SymMemory_t SymMemory; + +static std::monostate memoryInitialize(int32_t offset, + const std::string &data) { + // initialize concrete memory + for (size_t i = 0; i < data.size(); ++i) { + Memory.storeInt(offset, i, static_cast(data[i])); + } + // initialize symbolic memory + for (size_t i = 0; i < data.size(); ++i) { + SymMemory.storeSym(offset + i, 0, + Concrete(I32V(static_cast(data[i])))); + } + return {}; +} + +// A snapshot of the symbolic state and execution context (control) +class Snapshot_t { +public: + explicit Snapshot_t(Cont_t cont, MCont_t mcont, SymStack_t stack, + SymFrames_t frames, SymMemory_t memory); + explicit Snapshot_t() {} + + SymStack_t get_stack() const { return stack; } + SymFrames_t get_frames() const { return frames; } + SymMemory_t get_memory() const { return memory; } + + std::monostate resume_execution(NodeBox *node) const; + std::monostate resume_execution_by_model(NodeBox *node, + z3::model &model) const; + + static int cost_of_snapshot(); + +private: + SymStack_t stack; + SymFrames_t frames; + SymMemory_t memory; + // The continuation at the snapshot point + Cont_t cont; + MCont_t mcont; + void restore_states_to_global() const; +}; + +static SymFrames_t SymFrames; +static SymFrames_t SymGlobals; + +static Control makeControl(Cont_t cont, MCont_t mcont) { + return Control(cont, mcont); +} + +static Snapshot_t makeSnapshot(Control control) { + // create a snapshot from the current symbolic states and the control + return Snapshot_t(control.cont, control.mcont, SymStack, SymFrames, + SymMemory); +} + +struct Node; + +struct NodeBox { + explicit NodeBox(NodeBox *parent); + std::unique_ptr node; + NodeBox *parent; + int cost; + int instr_cost; + + bool fillIfElseNode(SymVal cond, int id); + bool fillCallIndirectNode(SymVal cond, int id); + std::monostate fillFinishedNode(); + std::monostate fillFailedNode(); + std::monostate fillUnreachableNode(); + std::monostate fillSnapshotNode(Snapshot_t snapshot); + std::monostate fillNotToExploreNode(); + bool isUnexplored() const; + std::vector collect_path_conds(); + int min_cost_of_reaching_here(); + void reach_here(std::function); +}; + +struct Node { + virtual ~Node(){}; + virtual std::string to_string() = 0; + void to_graphviz(std::ostream &os) { + os << "digraph G {\n"; + os << " rankdir=TB;\n"; + os << " node [shape=box, style=filled, fillcolor=lightblue];\n"; + current_id = 0; + generate_dot(os, -1, ""); + + os << "}\n"; + } + virtual void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) = 0; + +protected: + // Counter for unique node IDs across the entire graph, only for generating + // graphviz purpose + static int current_id; + void graphviz_node(std::ostream &os, const int node_id, + const std::string &label, const std::string &shape, + const std::string &fillcolor) { + os << " node" << node_id << " [label=\"" << label << "\", shape=" << shape + << ", style=filled, fillcolor=" << fillcolor << "];\n"; + } + + void graphviz_edge(std::ostream &os, int from_id, int target_id, + const std::string &edge_label) { + os << " node" << from_id << " -> node" << target_id; + if (!edge_label.empty()) { + os << " [label=\"" << edge_label << "\"]"; + } + os << ";\n"; + } +}; + +// TODO: use this header file in multiple compilation units will cause problems +// during linking +int Node::current_id = 0; + +struct IfElseNode : Node { + SymVal cond; + std::unique_ptr true_branch; + std::unique_ptr false_branch; + int id; + + IfElseNode(SymVal cond, NodeBox *parent, int id) + : cond(cond), true_branch(std::make_unique(parent)), + false_branch(std::make_unique(parent)), id(id) {} + + std::string to_string() override { + std::string result = "IfElseNode {\n"; + result += " true_branch: "; + if (true_branch) { + result += true_branch->node->to_string(); + } else { + result += "nullptr"; + } + result += "\n"; + + result += " false_branch: "; + if (false_branch) { + result += false_branch->node->to_string(); + } else { + result += "nullptr"; + } + result += "\n"; + result += "}"; + return result; + } + + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id; + current_id += 1; + + graphviz_node(os, current_node_dot_id, "If", "diamond", "lightyellow"); + + // Draw edge from parent if this is not the root node + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + assert(true_branch != nullptr); + assert(true_branch->node != nullptr); + true_branch->node->generate_dot(os, current_node_dot_id, "true"); + assert(false_branch != nullptr); + assert(false_branch->node != nullptr); + false_branch->node->generate_dot(os, current_node_dot_id, "false"); + } +}; + +struct CallIndirectNode : Node { + SymVal cond; + std::unordered_map> branches; + std::unique_ptr otherwise_branch; + int id; + CallIndirectNode(SymVal cond, NodeBox *parent, int id) + : cond(cond), id(id), + otherwise_branch(std::make_unique(parent)) {} + std::string to_string() override { + std::string result = "CallIndirectNode {\n"; + for (const auto &pair : branches) { + result += " branch " + std::to_string(pair.first) + ": "; + if (pair.second && pair.second->node) { + result += pair.second->node->to_string(); + } else { + result += "nullptr"; + } + result += "\n"; + } + result += "}"; + return result; + } + + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id; + current_id += 1; + + graphviz_node(os, current_node_dot_id, "Branch", "diamond", "lightyellow"); + + // Draw edge from parent if this is not the root node + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + for (const auto &pair : branches) { + assert(pair.second != nullptr); + assert(pair.second->node != nullptr); + pair.second->node->generate_dot(os, current_node_dot_id, + "branch " + std::to_string(pair.first)); + } + } +}; + +struct UnExploredNode : Node { + UnExploredNode() {} + std::string to_string() override { return "UnexploredNode"; } + +protected: + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id++; + graphviz_node(os, current_node_dot_id, "Unexplored", "octagon", + "lightgrey"); + + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + } +}; + +struct NotToExploreNode : Node { + NotToExploreNode() {} + std::string to_string() override { return "NotToExploreNode"; } + +protected: + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id++; + graphviz_node(os, current_node_dot_id, "NotToExplore", "box", "grey"); + + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + } +}; + +struct SnapshotNode : Node { + SnapshotNode(Snapshot_t snapshot) : snapshot(snapshot) {} + std::string to_string() override { return "SnapshotNode"; } + const Snapshot_t &get_snapshot() const { return snapshot; } + Snapshot_t move_out_snapshot() { return std::move(snapshot); } + +protected: + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id++; + graphviz_node(os, current_node_dot_id, "Snapshot", "box", "lightblue"); + + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + } + +private: + Snapshot_t snapshot; +}; + +struct Finished : Node { + Finished() {} + std::string to_string() override { return "FinishedNode"; } + +protected: + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id++; + graphviz_node(os, current_node_dot_id, "Finished", "box", "lightgreen"); + + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + } +}; + +struct Failed : Node { + Failed() {} + std::string to_string() override { return "FailedNode"; } + +protected: + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id++; + graphviz_node(os, current_node_dot_id, "Failed", "box", "red"); + + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + } +}; + +struct Unreachable : Node { + Unreachable() {} + std::string to_string() override { return "UnreachableNode"; } + +protected: + void generate_dot(std::ostream &os, int parent_dot_id, + const std::string &edge_label) override { + int current_node_dot_id = current_id++; + graphviz_node(os, current_node_dot_id, "Unreachable", "box", "orange"); + + if (parent_dot_id != -1) { + graphviz_edge(os, parent_dot_id, current_node_dot_id, edge_label); + } + } +}; + +inline NodeBox::NodeBox(NodeBox *parent) + : node(std::make_unique()), + /* TODO: avoid allocation of unexplored node */ + parent(parent), cost(-1), instr_cost(0) {} + +inline bool NodeBox::fillIfElseNode(SymVal cond, int id) { + // fill the current NodeBox with an ifelse branch node when it's unexplored + if (auto ptr = dynamic_cast(node.get())) { + node = std::make_unique(cond, this, id); + return true; + } else if (dynamic_cast(node.get())) { + node = std::make_unique(cond, this, id); + return true; + } else if (dynamic_cast(node.get()) != nullptr) { + assert(false && + "Unexpected traversal: arrived at a node marked 'NotToExplore'."); + return false; + } + + assert( + dynamic_cast(node.get()) != nullptr && + "Current node is not an Unexplored nor an IfElseNode, cannot fill it!"); + return false; +} + +inline bool NodeBox::fillCallIndirectNode(SymVal cond, int id) { + // fill the current NodeBox with a call_indirect branch node when it's + // unexplored + if (auto ptr = dynamic_cast(node.get())) { + node = std::make_unique(cond, this, id); + return true; + } else if (dynamic_cast(node.get())) { + node = std::make_unique(cond, this, id); + return true; + } else if (dynamic_cast(node.get()) != nullptr) { + assert(false && + "Unexpected traversal: arrived at a node marked 'NotToExplore'."); + return false; + } + + assert( + dynamic_cast(node.get()) != nullptr && + "Current node is not an Unexplored nor a CallIndirectNode, cannot fill " + "it!"); + return false; +} + +inline std::monostate NodeBox::fillSnapshotNode(Snapshot_t snapshot) { + if (this->isUnexplored()) { + node = std::make_unique(snapshot); + } + return std::monostate(); +} + +inline std::monostate NodeBox::fillNotToExploreNode() { + if (this->isUnexplored()) { + node = std::make_unique(); + } else { + assert(dynamic_cast(node.get()) != nullptr); + } + return std::monostate(); +} + +inline std::monostate NodeBox::fillFinishedNode() { + if (this->isUnexplored()) { + node = std::make_unique(); + } else { + assert(dynamic_cast(node.get()) != nullptr); + } + return std::monostate(); +} + +inline std::monostate NodeBox::fillFailedNode() { + if (this->isUnexplored()) { + node = std::make_unique(); + } else { + assert(dynamic_cast(node.get()) != nullptr); + } + return std::monostate(); +} + +inline std::monostate NodeBox::fillUnreachableNode() { + if (this->isUnexplored()) { + node = std::make_unique(); + } else { + assert(dynamic_cast(node.get()) != nullptr); + } + return std::monostate(); +} + +inline bool NodeBox::isUnexplored() const { + assert(node != nullptr); + if (dynamic_cast(node.get()) != nullptr) { + return true; + } + if (dynamic_cast(node.get()) != nullptr) { + return true; + } + return false; +} + +inline std::vector NodeBox::collect_path_conds() { + auto box = this; + auto result = std::vector(); + while (box->parent) { + auto parent = box->parent; + if (auto if_else_node = dynamic_cast(parent->node.get())) { + if (if_else_node->true_branch.get() == box) { + // If the current box is the true branch, add the condition + result.push_back(if_else_node->cond); + } else if (if_else_node->false_branch.get() == box) { + // If the current box is the false branch, add the negated condition + result.push_back(if_else_node->cond.negate()); + } else { + throw std::runtime_error("Unexpected node structure in explore tree"); + } + } else if (auto call_indirect_node = + dynamic_cast(parent->node.get())) { + // Find which branch we are in + bool found = false; + for (const auto &pair : call_indirect_node->branches) { + if (pair.second.get() == box) { + // We are in this branch + // Add the condition that leads to this branch + result.push_back( + call_indirect_node->cond.eq(Concrete(I32V(pair.first)))); + found = true; + break; + } + } + if (!found) { + // We must be in the otherwise branch + if (call_indirect_node->otherwise_branch.get() != box) { + throw std::runtime_error("Unexpected node structure in explore tree"); + } + // Add the negated conditions for all other branches + SymVal negated_conditions = Concrete(I32V(1)); // true + for (const auto &pair : call_indirect_node->branches) { + negated_conditions = negated_conditions.bitwise_and( + call_indirect_node->cond.neq(Concrete(I32V(pair.first)))); + } + result.push_back(negated_conditions); + } + } + // Move to parent + box = box->parent; + } + return result; +} + +inline int NodeBox::min_cost_of_reaching_here() { + if (cost != -1) { + return cost; + } + + if (auto snapshot = dynamic_cast(node.get())) { + cost = snapshot->get_snapshot().cost_of_snapshot(); + return cost; + } + + if (parent != nullptr) { + auto parent_cost = parent->min_cost_of_reaching_here(); + cost = parent_cost + instr_cost; + return cost; + } + cost = instr_cost; + return cost; +} + +inline Snapshot_t::Snapshot_t(Cont_t cont, MCont_t mcont, SymStack_t stack, + SymFrames_t frames, SymMemory_t memory) + : stack(std::move(stack)), frames(std::move(frames)), + memory(std::move(memory)), cont(cont), mcont(mcont) { + Profile.step(StepProfileKind::SNAPSHOT_CREATE); +#ifdef DEBUG + std::cout << "Creating snapshot of size " << stack.size() << std::endl; +#endif +} + +inline int Snapshot_t::cost_of_snapshot() { + auto cost_of_stack_copy = SymStack.cost_of_copy(); + auto cost_of_frame_copy = SymFrames.cost_of_copy(); + auto cost_of_memory_copy = SymMemory.cost_of_copy(); + // The speed ratio between symbolic expression instantiation and WebAssembly + // instruction execution, given by benchmark results + auto ratio = 2.5; + return ratio * + (cost_of_stack_copy + cost_of_frame_copy + cost_of_memory_copy); +} + +struct OverallResult { + int unexplored_count = 0; + int finished_count = 0; + int failed_count = 0; + int not_to_explore_count = 0; + int unreachable_count = 0; + + void print() { + std::cout << "Explore Tree Overall Result:" << std::endl; + std::cout << " Unexplored paths: " << unexplored_count << std::endl; + std::cout << " Finished paths: " << finished_count << std::endl; + std::cout << " Failed paths: " << failed_count << std::endl; + std::cout << " Unreachable paths: " << unreachable_count << std::endl; + std::cout << " NotToExplore paths: " << not_to_explore_count << std::endl; + } +}; + +class ExploreTree_t { +public: + explicit ExploreTree_t() + : root(std::make_unique(nullptr)), cursor(root.get()) {} + + void reset_cursor() { + GENSYM_INFO("Resetting cursor to root"); + // Reset the cursor to the root of the tree + cursor = root.get(); + } + + void clear() { + GENSYM_INFO("Clearing the explore tree"); + root = std::make_unique(nullptr); + cursor = root.get(); + true_branch_cov_map.clear(); + false_branch_cov_map.clear(); + } + + void set_cursor(NodeBox *new_cursor) { + GENSYM_INFO("Setting cursor to a new node"); + cursor = new_cursor; + assert(dynamic_cast(cursor->node.get()) != nullptr); + } + + std::monostate fillFinishedNode() { return cursor->fillFinishedNode(); } + + std::monostate fillFailedNode() { return cursor->fillFailedNode(); } + + std::monostate fillIfElseNode(SymVal cond, int id) { + if (cursor->fillIfElseNode(cond, id)) { + auto if_else_node = dynamic_cast(cursor->node.get()); + register_new_node(if_else_node->true_branch.get()); + register_new_node(if_else_node->false_branch.get()); + } + return std::monostate(); + } + + std::monostate fillCallIndirectNode(SymVal cond, int id) { + if (cursor->fillCallIndirectNode(cond, id)) { + auto indirect_node = dynamic_cast(cursor->node.get()); + register_new_node(indirect_node->otherwise_branch.get()); + } + return std::monostate(); + } + + std::monostate fillNotToExploredNode() { + return cursor->fillNotToExploreNode(); + } + + std::vector collect_current_path_conds() { + return cursor->collect_path_conds(); + } + + bool worth_to_create_snapshot() { + if (!ENABLE_COST_MODEL) { + // If we are not using cost model, always create snapshot + return REUSE_SNAPSHOT; + } + // find out the best way to reach the current position via our cost model + auto snapshot_cost = Snapshot_t::cost_of_snapshot(); + int re_execution_cost = cursor->instr_cost; + if (snapshot_cost <= re_execution_cost) { + GENSYM_INFO("Snapshot is worth to create"); + } + return snapshot_cost <= re_execution_cost; + } + + std::monostate moveCursor(bool branch, Control control) { + Profile.step(StepProfileKind::CURSOR_MOVE); + assert(cursor != nullptr); + auto if_else_node = dynamic_cast(cursor->node.get()); + assert( + if_else_node != nullptr && + "Can't move cursor when the branch node is not initialized correctly!"); + int cost_from_parent = CostManager.dump_instr_cost(); + int cost_from_root = + cost_from_parent + (cursor->parent ? cursor->parent->instr_cost : 0); + cursor->instr_cost = cost_from_root; + if (branch) { + true_branch_cov_map[if_else_node->id] = true; + if (worth_to_create_snapshot()) { + auto snapshot = makeSnapshot(control); + if_else_node->false_branch->fillSnapshotNode(snapshot); + } else { + // Do nothing, the initial value of the branch is an unexplored node + } + cursor = if_else_node->true_branch.get(); + } else { + false_branch_cov_map[if_else_node->id] = true; + if (worth_to_create_snapshot()) { + auto snapshot = makeSnapshot(control); + if_else_node->true_branch->fillSnapshotNode(snapshot); + } else { + // Do nothing, the initial value of the branch is an unexplored node + } + cursor = if_else_node->false_branch.get(); + } + + return std::monostate(); + } + + std::monostate moveCursorNoControl(bool branch) { + Profile.step(StepProfileKind::CURSOR_MOVE); + assert(cursor != nullptr); + auto if_else_node = dynamic_cast(cursor->node.get()); + assert( + if_else_node != nullptr && + "Can't move cursor when the branch node is not initialized correctly!"); + int cost_from_parent = CostManager.dump_instr_cost(); + int cost_from_root = + cost_from_parent + (cursor->parent ? cursor->parent->instr_cost : 0); + cursor->instr_cost = cost_from_root; + if (branch) { + true_branch_cov_map[if_else_node->id] = true; + if_else_node->false_branch->fillNotToExploreNode(); + cursor = if_else_node->true_branch.get(); + } else { + assert(false && + "moveCursorNoControl should not be used for false branch"); + } + return std::monostate(); + } + + std::monostate moveCursorIndirect(int branch_index) { + // Dont use snapshot reuse for untaken branches of indirect call + Profile.step(StepProfileKind::CURSOR_MOVE); + assert(cursor != nullptr); + auto branch_node = dynamic_cast(cursor->node.get()); + assert(branch_node != nullptr && + "Can't move cursor when the branch node is not initialized "); + if (branch_node->branches.find(branch_index) == + branch_node->branches.end()) { + // Create a new branch + branch_node->branches[branch_index] = std::make_unique(cursor); + register_new_node(branch_node->branches[branch_index].get()); + } + cursor = branch_node->branches[branch_index].get(); + int cost_from_parent = CostManager.dump_instr_cost(); + int cost_from_root = + cost_from_parent + (cursor->parent ? cursor->parent->instr_cost : 0); + cursor->instr_cost = cost_from_root; + return std::monostate(); + } + + std::monostate print() { + std::cout << root->node->to_string() << std::endl; + return std::monostate(); + } + + std::monostate to_graphviz(std::ostream &os) { + root->node->to_graphviz(os); + return std::monostate(); + } + + std::monostate dump_graphviz(std::string filepath) { + std::filesystem::path out_path(filepath); + auto parent = out_path.parent_path(); + if (!parent.empty()) { + std::error_code ec; + std::filesystem::create_directories(parent, ec); + if (ec) { + throw std::runtime_error("Failed to create output directory: " + + ec.message()); + } + } + std::ofstream ofs(filepath); + if (!ofs.is_open()) { + throw std::runtime_error("Failed to open " + filepath + " for writing"); + } + to_graphviz(ofs); + return std::monostate(); + } + + OverallResult read_current_overall_result() { + OverallResult result; + std::function dfs = [&](NodeBox *node) { + if (auto if_else_node = dynamic_cast(node->node.get())) { + dfs(if_else_node->true_branch.get()); + dfs(if_else_node->false_branch.get()); + } else if (dynamic_cast(node->node.get())) { + result.unexplored_count += 1; + } else if (dynamic_cast(node->node.get())) { + result.finished_count += 1; + } else if (dynamic_cast(node->node.get())) { + result.failed_count += 1; + } else if (dynamic_cast(node->node.get())) { + result.unreachable_count += 1; + } else if (dynamic_cast(node->node.get())) { + // Snapshot node is considered unexplored + result.unexplored_count += 1; + } else if (dynamic_cast(node->node.get())) { + result.not_to_explore_count += 1; + } else if (auto call_indirect_node = + dynamic_cast(node->node.get())) { + for (const auto &pair : call_indirect_node->branches) { + dfs(pair.second.get()); + } + dfs(call_indirect_node->otherwise_branch.get()); + } else { + throw std::runtime_error("Unknown node type in explore tree"); + } + }; + dfs(root.get()); + return result; + } + + std::monostate print_overall_result() {} + + NodeBox *pick_unexplored() { + // Pick an unexplored node from the tree + // For now, we just iterate through the tree and return the first unexplored + return pick_unexplored_of(root.get()); + } + std::vector true_branch_cov_map; + std::vector false_branch_cov_map; + bool all_branch_covered() const { + for (bool covered : true_branch_cov_map) { + if (!covered) + return false; + } + for (bool covered : false_branch_cov_map) { + if (!covered) + return false; + } + return true; + } + + NodeBox *get_root() const { return root.get(); } + + void register_new_node_collector(std::function func) { + new_node_collectors.push_back(func); + } + +private: + NodeBox *pick_unexplored_of(NodeBox *node) { + if (node->isUnexplored()) { + return node; + } + auto if_else_node = dynamic_cast(node->node.get()); + if (if_else_node) { + NodeBox *result = pick_unexplored_of(if_else_node->true_branch.get()); + if (result) { + return result; + } + return pick_unexplored_of(if_else_node->false_branch.get()); + } + return nullptr; // No unexplored node found + } + void register_new_node(NodeBox *node) { + for (auto &func : new_node_collectors) { + func(node); + } + } + std::unique_ptr root; + NodeBox *cursor; + std::vector> new_node_collectors; +}; + +static ExploreTree_t ExploreTree; + +using NumMap = std::unordered_map; + +class SymEnv_t { +public: + Num read(const Symbol &symbol) { +#if DEBUG + std::cout << "Read symbol: " << symbol.get_id() + << " from symbolic environment" << std::endl; + std::cout << "Current symbolic environment: " << to_string() << std::endl; +#endif + map.try_emplace(symbol.get_id(), Num(I32V(0))); + return map.at(symbol.get_id()); + } + + Num read(SymVal sym) { + // Read the value of a symbolic value from the environment, it will update + // the environment if the key does not exist. + auto symbol = dynamic_cast(sym.symptr.get()); + assert(symbol); + return read(*symbol); + } + + void update(NumMap new_env) { map = std::move(new_env); } + + std::string to_string() const { + std::string result; + result += "(\n"; + for (const auto &[id, num] : map) { + result += + " (" + std::to_string(id) + "->" + std::to_string(num.value) + ")\n"; + } + result += ")"; + return result; + } + + size_t size() const { return map.size(); } + +private: + NumMap map; // The symbolic environment, a vector of Num +}; + +static SymEnv_t SymEnv; + +static std::monostate reset_stacks() { + Stack.reset(); + SymStack.reset(); + Frames.reset(); + SymFrames.reset(); + Memory.reset(); + SymMemory.reset(); + initRand(); + return std::monostate{}; +} + +[[deprecated]] inline void +NodeBox::reach_here(std::function entrypoint) { + // reach the node of exploration tree with given input (symbolic environment) + if (auto snapshot = dynamic_cast(node.get())) { + assert(REUSE_SNAPSHOT); + auto snap = snapshot->get_snapshot(); + snap.resume_execution(this); + return; + } else if (parent == nullptr) { + // if it's the root node, the only way to reach here is to reset everything + // and start a new execution + assert(this == ExploreTree.get_root() && + "Only the root node can have no parent"); + auto timer = ManagedTimer(TimeProfileKind::INSTR); + ExploreTree.reset_cursor(); + reset_stacks(); + entrypoint(); + return; + } + // Reach the parent node, then from the parent node, we can reach here + // TODO: short circuit the lookup + parent->reach_here(entrypoint); + return; +} + +struct EvalRes { + Num value; + int width; // in bits + EvalRes(Num value, int width) : value(value), width(width) {} +}; + +// TODO: reduce the re-computation of the same symbolic expression, it's better +// if it can be done by the smt solver +static EvalRes eval_sym_expr(const SymVal &sym, SymEnv_t &sym_env) { + Profile.step(StepProfileKind::SYM_EVAL); + assert(sym.symptr != nullptr && "Symbolic expression is null"); + if (auto concrete = dynamic_cast(sym.symptr.get())) { + return EvalRes(concrete->value, 32); + } else if (auto extract = dynamic_cast(sym.symptr.get())) { + auto res = eval_sym_expr(extract->value, sym_env); + int high = extract->high; + int low = extract->low; + assert(high >= low && "Invalid extract range"); + int size = high - low + 1; // size in bytes + int64_t mask = (1LL << (size * 8)) - 1; + int64_t extracted_value = (res.value.toInt() >> ((low - 1) * 8)) & mask; + return EvalRes(Num(I64V(extracted_value)), size * 8); + } else if (auto smallbv = dynamic_cast(sym.symptr.get())) { + return EvalRes(Num(I64V(smallbv->get_value())), smallbv->get_size()); + } else if (auto operation = dynamic_cast(sym.symptr.get())) { + // If it's a operation, we need to evaluate it + auto lhs_res = eval_sym_expr(operation->lhs, sym_env); + auto rhs_res = eval_sym_expr(operation->rhs, sym_env); + auto lhs = lhs_res.value; + auto rhs = rhs_res.value; + auto lhs_width = lhs_res.width; + auto rhs_width = rhs_res.width; + switch (operation->op) { + case ADD: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_add(rhs), 32); + } else { + assert(false && "TODO"); + } + case SUB: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_sub(rhs), 32); + } else { + assert(false && "TODO"); + } + case MUL: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_mul(rhs), 32); + } else { + assert(false && "TODO"); + } + case DIV: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_div_s(rhs), 32); + } else { + assert(false && "TODO"); + } + case LT: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_lt_s(rhs), 32); + } else { + assert(false && "TODO"); + } + case LEQ: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_le_s(rhs), 32); + } else { + assert(false && "TODO"); + } + case GT: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_gt_s(rhs), 32); + } else { + assert(false && "TODO"); + } + case GEQ: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_ge_s(rhs), 32); + } else { + assert(false && "TODO"); + } + case NEQ: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_ne(rhs), 32); + } else { + assert(false && "TODO"); + } + case EQ: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_eq(rhs), 32); + } else { + assert(false && "TODO"); + } + case B_AND: + if (lhs_width == 32 && rhs_width == 32) { + return EvalRes(lhs.i32_and(rhs), 32); + } else { + assert(false && "TODO"); + } + case CONCAT: { + auto lhs_width = lhs_res.width; + auto rhs_width = rhs_res.width; + auto conc_value = (lhs.value << rhs_width) | (rhs.value); + auto new_width = lhs_width + rhs_width; + return EvalRes(Num(I64V(conc_value)), new_width); + } + default: + assert(false && "Operation not supported in evaluation"); + } + } else if (auto symbol = dynamic_cast(sym.symptr.get())) { + auto sym_id = symbol->get_id(); + GENSYM_INFO("Reading symbol: " + std::to_string(sym_id)); + return EvalRes(sym_env.read(sym), 32); + } + throw std::runtime_error("Not supported symbolic expression"); +} + +inline EvalRes eval_sym_expr_by_model(const SymVal &sym, z3::model &model); + +static void resume_conc_stack(const SymStack_t &sym_stack, Stack_t &stack, + SymEnv_t &sym_env) { + stack.resize(sym_stack.size()); + for (size_t i = 0; i < sym_stack.size(); ++i) { + auto sym = sym_stack[i]; + auto res = eval_sym_expr(sym, sym_env); + auto conc = res.value; + stack.set_from_front(i, conc); + } +} + +static void resume_conc_stack_by_model(const SymStack_t &sym_stack, + Stack_t &stack, z3::model &model) { + GENSYM_INFO("Restoring concrete stack from symbolic stack"); + stack.resize(sym_stack.size()); + for (size_t i = 0; i < sym_stack.size(); ++i) { + auto sym = sym_stack[i]; + auto res = eval_sym_expr_by_model(sym, model); + auto conc = res.value; + stack.set_from_front(i, conc); + } +} + +static void resume_conc_frames(const SymFrames_t &sym_frame, Frames_t &frames, + SymEnv_t &sym_env) { + GENSYM_INFO("Restoring concrete frames from symbolic frames"); + frames.resize(sym_frame.size()); + for (size_t i = 0; i < sym_frame.size(); ++i) { + auto sym = sym_frame[i]; + assert(sym.symptr != nullptr); + auto res = eval_sym_expr(sym, sym_env); + auto conc = res.value; + frames.set_from_front(i, conc); + } +} + +static void resume_conc_frames_by_model(const SymFrames_t &sym_frame, + Frames_t &frames, z3::model &model) { + GENSYM_INFO("Restoring concrete frames from symbolic frames"); + frames.resize(sym_frame.size()); + for (size_t i = 0; i < sym_frame.size(); ++i) { + auto sym = sym_frame[i]; + assert(sym.symptr != nullptr); + auto res = eval_sym_expr_by_model(sym, model); + auto conc = res.value; + frames.set_from_front(i, conc); + } +} + +static void resume_conc_memory(const SymMemory_t &sym_memory, Memory_t &memory, + SymEnv_t &sym_env) { + GENSYM_INFO("Restoring concrete memory from symbolic memory"); + memory.reset(); + for (const auto &pair : sym_memory.memory) { + int32_t addr = pair.first; + SymVal sym = pair.second; + assert(sym.symptr != nullptr); + auto res = eval_sym_expr(sym, sym_env); + auto conc = res.value; + assert(res.width == 8 && "Memory should only store bytes"); + memory.store_byte(addr, conc.value & 0xFF); + } +} + +static void resume_conc_memory_by_model(const SymMemory_t &sym_memory, + Memory_t &memory, z3::model &model) { + GENSYM_INFO("Restoring concrete memory from symbolic memory"); + memory.reset(); + for (const auto &pair : sym_memory.memory) { + int32_t addr = pair.first; + SymVal sym = pair.second; + assert(sym.symptr != nullptr); + auto res = eval_sym_expr_by_model(sym, model); + auto conc = res.value; + assert(res.width == 8 && "Memory should only store bytes"); + memory.store_byte(addr, conc.value & 0xFF); + } +} + +static void resume_conc_states(const SymStack_t &sym_stack, + const SymFrames_t &sym_frame, + const SymMemory_t &sym_memory, Stack_t &stack, + Frames_t &frames, Memory_t &memory, + SymEnv_t &sym_env) { + resume_conc_stack(sym_stack, stack, sym_env); + resume_conc_frames(sym_frame, frames, sym_env); + resume_conc_memory(sym_memory, memory, sym_env); +} + +static void resume_conc_states_by_model(const SymStack_t &sym_stack, + const SymFrames_t &sym_frame, + const SymMemory_t &sym_memory, + Stack_t &stack, Frames_t &frames, + Memory_t &memory, z3::model &model) { + resume_conc_stack_by_model(sym_stack, stack, model); + resume_conc_frames_by_model(sym_frame, frames, model); + resume_conc_memory_by_model(sym_memory, memory, model); +} + +inline void Snapshot_t::restore_states_to_global() const { + // Restore the symbolic state from the snapshot + GENSYM_INFO("Reusing symbolic state from snapshot"); + SymStack = stack; + SymFrames = frames; + SymMemory = memory; +} + +inline std::monostate +Snapshot_t::resume_execution_by_model(NodeBox *node, z3::model &model) const { + // Reset explore tree's cursor and restore symbolic states + ExploreTree.set_cursor(node); + restore_states_to_global(); + + { + auto timer = ManagedTimer(TimeProfileKind::RESUME_SNAPSHOT); + // Restore the concrete states from the symbolic states + resume_conc_states_by_model(stack, frames, memory, Stack, Frames, Memory, + model); + } + // Resume execution from the continuation + auto timer = ManagedTimer(TimeProfileKind::INSTR); + return cont(mcont); +} + +[[deprecated]] inline std::monostate +Snapshot_t::resume_execution(NodeBox *node) const { + // Reset explore tree's cursor and restore symbolic states + ExploreTree.set_cursor(node); + restore_states_to_global(); + { + auto timer = ManagedTimer(TimeProfileKind::RESUME_SNAPSHOT); + // Restore the concrete states from the symbolic states + resume_conc_states(stack, frames, memory, Stack, Frames, Memory, SymEnv); + } + + // Resume execution from the continuation + auto timer = ManagedTimer(TimeProfileKind::INSTR); + return cont(mcont); +} + +#endif // WASM_SYMBOLIC_RT_HPP diff --git a/headers/wasm/utils.hpp b/headers/wasm/utils.hpp new file mode 100644 index 000000000..8b7b04711 --- /dev/null +++ b/headers/wasm/utils.hpp @@ -0,0 +1,74 @@ +#ifndef UTILS_HPP +#define UTILS_HPP +#include +#include + +#ifndef GENSYM_ASSERT +#define GENSYM_ASSERT(condition) \ + do { \ + if (!(condition)) { \ + throw std::runtime_error(std::string("Assertion failed: ") + " (" + \ + __FILE__ + ":" + std::to_string(__LINE__) + \ + ")"); \ + } \ + } while (0) +#endif + +#ifndef NO_DBG +#define GENSYM_DBG(obj) \ + do { \ + std::cout << "LOG: " << obj << " (" << __FILE__ << ":" \ + << std::to_string(__LINE__) << ")" << std::endl; \ + } while (0) +#else +#define GENSYM_LOG(message) \ + do { \ + } while (0) +#endif + +#ifndef NO_INFO +#define GENSYM_INFO(obj) \ + do { \ + std::cout << obj << std::endl; \ + } while (0) +#else +#define GENSYM_INFO(message) \ + do { \ + } while (0) + +#endif + +#if __cplusplus < 202002L +#include + +inline bool starts_with(const std::string &str, const std::string &prefix) { + return str.size() >= prefix.size() && + std::equal(prefix.begin(), prefix.end(), str.begin()); +} +#else +#include +inline bool starts_with(const std::string &str, const std::string &prefix) { + return str.starts_with(prefix); +} +#endif + +inline std::monostate info() { +#ifdef DEBUG + std::cout << std::endl; +#endif + return std::monostate{}; +} + +template +std::monostate info(const T &first, const Args &...args) { +#ifdef DEBUG + std::cout << first << " "; + info(args...); +#endif + return std::monostate{}; +} + +inline std::monostate get_unit() { return std::monostate{}; } +inline std::monostate get_unit(std::monostate x) { return std::monostate{}; } + +#endif // UTILS_HPP \ No newline at end of file diff --git a/src/main/java/wasm/WatParser.java b/src/main/java/wasm/WatParser.java index 3895179d5..b364ddea6 100644 --- a/src/main/java/wasm/WatParser.java +++ b/src/main/java/wasm/WatParser.java @@ -1648,7 +1648,6 @@ public final PlainInstrContext plainInstr() throws RecognitionException { enterRule(_localctx, 40, RULE_plainInstr); int _la; try { - int _alt; setState(357); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,18,_ctx) ) { @@ -1705,24 +1704,18 @@ public final PlainInstrContext plainInstr() throws RecognitionException { match(BR_TABLE); setState(289); _errHandler.sync(this); - _alt = 1; + _la = _input.LA(1); do { - switch (_alt) { - case 1: - { - { - setState(288); - idx(); - } - } - break; - default: - throw new NoViableAltException(this); + { + { + setState(288); + idx(); + } } setState(291); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,13,_ctx); - } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); + _la = _input.LA(1); + } while ( _la==NAT || _la==VAR ); } break; case 8: @@ -2941,14 +2934,14 @@ public final BlockInstrContext blockInstr() throws RecognitionException { match(END); setState(473); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,34,_ctx) ) { - case 1: + _la = _input.LA(1); + if (_la==VAR) { { setState(472); bindVar(); } - break; } + } break; case LOOP: @@ -2972,14 +2965,14 @@ public final BlockInstrContext blockInstr() throws RecognitionException { match(END); setState(482); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { - case 1: + _la = _input.LA(1); + if (_la==VAR) { { setState(481); bindVar(); } - break; } + } break; case IF: @@ -3025,14 +3018,14 @@ public final BlockInstrContext blockInstr() throws RecognitionException { match(END); setState(498); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,40,_ctx) ) { - case 1: + _la = _input.LA(1); + if (_la==VAR) { { setState(497); bindVar(); } - break; } + } break; case TRY: @@ -3379,14 +3372,14 @@ public final ExprContext expr() throws RecognitionException { match(BLOCK); setState(541); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,45,_ctx) ) { - case 1: + _la = _input.LA(1); + if (_la==VAR) { { setState(540); bindVar(); } - break; } + setState(543); block(); } @@ -3398,14 +3391,14 @@ public final ExprContext expr() throws RecognitionException { match(LOOP); setState(546); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,46,_ctx) ) { - case 1: + _la = _input.LA(1); + if (_la==VAR) { { setState(545); bindVar(); } - break; } + setState(548); block(); } @@ -4351,17 +4344,13 @@ public InstrContext instr() { public TerminalNode RPAR(int i) { return getToken(WatParser.RPAR, i); } + public TerminalNode FUNC() { return getToken(WatParser.FUNC, 0); } public List idx() { return getRuleContexts(IdxContext.class); } public IdxContext idx(int i) { return getRuleContext(IdxContext.class,i); } - public OffsetContext offset() { - return getRuleContext(OffsetContext.class,0); - } - public TerminalNode DECLARE() { return getToken(WatParser.DECLARE, 0); } - public TerminalNode FUNC() { return getToken(WatParser.FUNC, 0); } public ElemContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -4386,126 +4375,36 @@ public final ElemContext elem() throws RecognitionException { enterRule(_localctx, 94, RULE_elem); int _la; try { - setState(723); + enterOuterAlt(_localctx, 1); + { + setState(679); + match(LPAR); + setState(680); + match(ELEM); + setState(681); + match(LPAR); + setState(682); + instr(); + setState(683); + match(RPAR); + setState(684); + match(FUNC); + setState(688); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,73,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); + _la = _input.LA(1); + while (_la==NAT || _la==VAR) { { - setState(679); - match(LPAR); - setState(680); - match(ELEM); - setState(682); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==NAT || _la==VAR) { - { - setState(681); - idx(); - } - } - - setState(684); - match(LPAR); - setState(685); - instr(); - setState(686); - match(RPAR); - setState(690); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==NAT || _la==VAR) { - { - { - setState(687); - idx(); - } - } - setState(692); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(693); - match(RPAR); - } - break; - case 2: - enterOuterAlt(_localctx, 2); { - setState(695); - match(LPAR); - setState(696); - match(ELEM); - setState(698); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==NAT || _la==VAR) { - { - setState(697); - idx(); - } - } - - setState(700); - offset(); - setState(704); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==NAT || _la==VAR) { - { - { - setState(701); - idx(); - } - } - setState(706); - _errHandler.sync(this); - _la = _input.LA(1); + setState(685); + idx(); } - setState(707); - match(RPAR); } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(709); - match(LPAR); - setState(710); - match(ELEM); - setState(712); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==NAT || _la==VAR) { - { - setState(711); - idx(); - } - } - - setState(714); - match(DECLARE); - setState(715); - match(FUNC); - setState(719); + setState(690); _errHandler.sync(this); _la = _input.LA(1); - while (_la==NAT || _la==VAR) { - { - { - setState(716); - idx(); - } - } - setState(721); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(722); - match(RPAR); - } - break; + } + setState(691); + match(RPAR); } } catch (RecognitionException re) { @@ -4556,23 +4455,23 @@ public final TableContext table() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(725); + setState(693); match(LPAR); - setState(726); + setState(694); match(TABLE); - setState(728); + setState(696); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(727); + setState(695); bindVar(); } } - setState(730); + setState(698); tableField(); - setState(731); + setState(699); match(RPAR); } } @@ -4637,58 +4536,58 @@ public final TableFieldContext tableField() throws RecognitionException { enterRule(_localctx, 98, RULE_tableField); int _la; try { - setState(751); + setState(719); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,76,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,70,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(733); + setState(701); tableType(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(734); + setState(702); inlineImport(); - setState(735); + setState(703); tableType(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(737); + setState(705); inlineExport(); - setState(738); + setState(706); tableField(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(740); + setState(708); refType(); - setState(741); + setState(709); match(LPAR); - setState(742); + setState(710); match(ELEM); - setState(746); + setState(714); _errHandler.sync(this); _la = _input.LA(1); while (_la==NAT || _la==VAR) { { { - setState(743); + setState(711); idx(); } } - setState(748); + setState(716); _errHandler.sync(this); _la = _input.LA(1); } - setState(749); + setState(717); match(RPAR); } break; @@ -4753,84 +4652,84 @@ public final DataContext data() throws RecognitionException { enterRule(_localctx, 100, RULE_data); int _la; try { - setState(783); + setState(751); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,81,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,75,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(753); + setState(721); match(LPAR); - setState(754); + setState(722); match(DATA); - setState(756); + setState(724); _errHandler.sync(this); _la = _input.LA(1); if (_la==NAT || _la==VAR) { { - setState(755); + setState(723); idx(); } } - setState(758); + setState(726); match(LPAR); - setState(759); + setState(727); instr(); - setState(760); + setState(728); match(RPAR); - setState(764); + setState(732); _errHandler.sync(this); _la = _input.LA(1); while (_la==STRING_) { { { - setState(761); + setState(729); match(STRING_); } } - setState(766); + setState(734); _errHandler.sync(this); _la = _input.LA(1); } - setState(767); + setState(735); match(RPAR); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(769); + setState(737); match(LPAR); - setState(770); + setState(738); match(DATA); - setState(772); + setState(740); _errHandler.sync(this); _la = _input.LA(1); if (_la==NAT || _la==VAR) { { - setState(771); + setState(739); idx(); } } - setState(774); + setState(742); offset(); - setState(778); + setState(746); _errHandler.sync(this); _la = _input.LA(1); while (_la==STRING_) { { { - setState(775); + setState(743); match(STRING_); } } - setState(780); + setState(748); _errHandler.sync(this); _la = _input.LA(1); } - setState(781); + setState(749); match(RPAR); } break; @@ -4884,23 +4783,23 @@ public final MemoryContext memory() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(785); + setState(753); match(LPAR); - setState(786); + setState(754); match(MEMORY); - setState(788); + setState(756); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(787); + setState(755); bindVar(); } } - setState(790); + setState(758); memoryField(); - setState(791); + setState(759); match(RPAR); } } @@ -4960,56 +4859,56 @@ public final MemoryFieldContext memoryField() throws RecognitionException { enterRule(_localctx, 104, RULE_memoryField); int _la; try { - setState(809); + setState(777); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,84,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,78,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(793); + setState(761); memoryType(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(794); + setState(762); inlineImport(); - setState(795); + setState(763); memoryType(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(797); + setState(765); inlineExport(); - setState(798); + setState(766); memoryField(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(800); + setState(768); match(LPAR); - setState(801); + setState(769); match(DATA); - setState(805); + setState(773); _errHandler.sync(this); _la = _input.LA(1); while (_la==STRING_) { { { - setState(802); + setState(770); match(STRING_); } } - setState(807); + setState(775); _errHandler.sync(this); _la = _input.LA(1); } - setState(808); + setState(776); match(RPAR); } break; @@ -5063,23 +4962,23 @@ public final GlobalContext global() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(811); + setState(779); match(LPAR); - setState(812); + setState(780); match(GLOBAL); - setState(814); + setState(782); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(813); + setState(781); bindVar(); } } - setState(816); + setState(784); globalField(); - setState(817); + setState(785); match(RPAR); } } @@ -5134,33 +5033,33 @@ public final GlobalFieldContext globalField() throws RecognitionException { GlobalFieldContext _localctx = new GlobalFieldContext(_ctx, getState()); enterRule(_localctx, 108, RULE_globalField); try { - setState(828); + setState(796); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,86,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,80,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(819); + setState(787); globalType(); - setState(820); + setState(788); constExpr(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(822); + setState(790); inlineImport(); - setState(823); + setState(791); globalType(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(825); + setState(793); inlineExport(); - setState(826); + setState(794); globalField(); } break; @@ -5227,121 +5126,121 @@ public final ImportDescContext importDesc() throws RecognitionException { enterRule(_localctx, 110, RULE_importDesc); int _la; try { - setState(870); + setState(838); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,92,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,86,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(830); + setState(798); match(LPAR); - setState(831); + setState(799); match(FUNC); - setState(833); + setState(801); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(832); + setState(800); bindVar(); } } - setState(835); + setState(803); typeUse(); - setState(836); + setState(804); match(RPAR); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(838); + setState(806); match(LPAR); - setState(839); + setState(807); match(FUNC); - setState(841); + setState(809); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(840); + setState(808); bindVar(); } } - setState(843); + setState(811); funcType(); - setState(844); + setState(812); match(RPAR); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(846); + setState(814); match(LPAR); - setState(847); + setState(815); match(TABLE); - setState(849); + setState(817); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(848); + setState(816); bindVar(); } } - setState(851); + setState(819); tableType(); - setState(852); + setState(820); match(RPAR); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(854); + setState(822); match(LPAR); - setState(855); + setState(823); match(MEMORY); - setState(857); + setState(825); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(856); + setState(824); bindVar(); } } - setState(859); + setState(827); memoryType(); - setState(860); + setState(828); match(RPAR); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(862); + setState(830); match(LPAR); - setState(863); + setState(831); match(GLOBAL); - setState(865); + setState(833); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(864); + setState(832); bindVar(); } } - setState(867); + setState(835); globalType(); - setState(868); + setState(836); match(RPAR); } break; @@ -5397,17 +5296,17 @@ public final SimportContext simport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(872); + setState(840); match(LPAR); - setState(873); + setState(841); match(IMPORT); - setState(874); + setState(842); name(); - setState(875); + setState(843); name(); - setState(876); + setState(844); importDesc(); - setState(877); + setState(845); match(RPAR); } } @@ -5458,15 +5357,15 @@ public final InlineImportContext inlineImport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(879); + setState(847); match(LPAR); - setState(880); + setState(848); match(IMPORT); - setState(881); + setState(849); name(); - setState(882); + setState(850); name(); - setState(883); + setState(851); match(RPAR); } } @@ -5515,58 +5414,58 @@ public final ExportDescContext exportDesc() throws RecognitionException { ExportDescContext _localctx = new ExportDescContext(_ctx, getState()); enterRule(_localctx, 116, RULE_exportDesc); try { - setState(905); + setState(873); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,93,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,87,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(885); + setState(853); match(LPAR); - setState(886); + setState(854); match(FUNC); - setState(887); + setState(855); idx(); - setState(888); + setState(856); match(RPAR); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(890); + setState(858); match(LPAR); - setState(891); + setState(859); match(TABLE); - setState(892); + setState(860); idx(); - setState(893); + setState(861); match(RPAR); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(895); + setState(863); match(LPAR); - setState(896); + setState(864); match(MEMORY); - setState(897); + setState(865); idx(); - setState(898); + setState(866); match(RPAR); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(900); + setState(868); match(LPAR); - setState(901); + setState(869); match(GLOBAL); - setState(902); + setState(870); idx(); - setState(903); + setState(871); match(RPAR); } break; @@ -5619,15 +5518,15 @@ public final Export_Context export_() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(907); + setState(875); match(LPAR); - setState(908); + setState(876); match(EXPORT); - setState(909); + setState(877); name(); - setState(910); + setState(878); exportDesc(); - setState(911); + setState(879); match(RPAR); } } @@ -5675,13 +5574,13 @@ public final InlineExportContext inlineExport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(913); + setState(881); match(LPAR); - setState(914); + setState(882); match(EXPORT); - setState(915); + setState(883); name(); - setState(916); + setState(884); match(RPAR); } } @@ -5736,25 +5635,25 @@ public final TagContext tag() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(918); + setState(886); match(LPAR); - setState(919); + setState(887); match(TAG); - setState(921); + setState(889); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(920); + setState(888); bindVar(); } } - setState(923); + setState(891); typeUse(); - setState(924); + setState(892); funcType(); - setState(925); + setState(893); match(RPAR); } } @@ -5806,23 +5705,23 @@ public final TypeDefContext typeDef() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(927); + setState(895); match(LPAR); - setState(928); + setState(896); match(TYPE); - setState(930); + setState(898); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(929); + setState(897); bindVar(); } } - setState(932); + setState(900); defType(); - setState(933); + setState(901); match(RPAR); } } @@ -5870,13 +5769,13 @@ public final Start_Context start_() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(935); + setState(903); match(LPAR); - setState(936); + setState(904); match(START_); - setState(937); + setState(905); idx(); - setState(938); + setState(906); match(RPAR); } } @@ -5949,83 +5848,83 @@ public final ModuleFieldContext moduleField() throws RecognitionException { ModuleFieldContext _localctx = new ModuleFieldContext(_ctx, getState()); enterRule(_localctx, 128, RULE_moduleField); try { - setState(951); + setState(919); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,96,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,90,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(940); + setState(908); typeDef(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(941); + setState(909); global(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(942); + setState(910); table(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(943); + setState(911); memory(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(944); + setState(912); function(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(945); + setState(913); elem(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(946); + setState(914); data(); } break; case 8: enterOuterAlt(_localctx, 8); { - setState(947); + setState(915); start_(); } break; case 9: enterOuterAlt(_localctx, 9); { - setState(948); + setState(916); simport(); } break; case 10: enterOuterAlt(_localctx, 10); { - setState(949); + setState(917); export_(); } break; case 11: enterOuterAlt(_localctx, 11); { - setState(950); + setState(918); tag(); } break; @@ -6080,35 +5979,35 @@ public final Module_Context module_() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(953); + setState(921); match(LPAR); - setState(954); + setState(922); match(MODULE); - setState(956); + setState(924); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(955); + setState(923); match(VAR); } } - setState(961); + setState(929); _errHandler.sync(this); _la = _input.LA(1); while (_la==LPAR) { { { - setState(958); + setState(926); moduleField(); } } - setState(963); + setState(931); _errHandler.sync(this); _la = _input.LA(1); } - setState(964); + setState(932); match(RPAR); } } @@ -6163,34 +6062,34 @@ public final ScriptModuleContext scriptModule() throws RecognitionException { enterRule(_localctx, 132, RULE_scriptModule); int _la; try { - setState(994); + setState(962); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,103,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,97,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(966); + setState(934); module_(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(967); + setState(935); match(LPAR); - setState(968); + setState(936); match(MODULE); - setState(970); + setState(938); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(969); + setState(937); match(VAR); } } - setState(972); + setState(940); _la = _input.LA(1); if ( !(_la==BIN || _la==QUOTE) ) { _errHandler.recoverInline(this); @@ -6200,60 +6099,60 @@ public final ScriptModuleContext scriptModule() throws RecognitionException { _errHandler.reportMatch(this); consume(); } - setState(976); + setState(944); _errHandler.sync(this); _la = _input.LA(1); while (_la==STRING_) { { { - setState(973); + setState(941); match(STRING_); } } - setState(978); + setState(946); _errHandler.sync(this); _la = _input.LA(1); } - setState(979); + setState(947); match(RPAR); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(980); + setState(948); match(LPAR); - setState(981); + setState(949); match(MODULE); - setState(982); + setState(950); match(DEFINITION); - setState(984); + setState(952); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(983); + setState(951); match(VAR); } } - setState(986); + setState(954); match(BIN); - setState(990); + setState(958); _errHandler.sync(this); _la = _input.LA(1); while (_la==STRING_) { { { - setState(987); + setState(955); match(STRING_); } } - setState(992); + setState(960); _errHandler.sync(this); _la = _input.LA(1); } - setState(993); + setState(961); match(RPAR); } break; @@ -6307,54 +6206,54 @@ public final Action_Context action_() throws RecognitionException { enterRule(_localctx, 134, RULE_action_); int _la; try { - setState(1013); + setState(981); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,106,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,100,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(996); + setState(964); match(LPAR); - setState(997); + setState(965); match(INVOKE); - setState(999); + setState(967); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(998); + setState(966); match(VAR); } } - setState(1001); + setState(969); name(); - setState(1002); + setState(970); constList(); - setState(1003); + setState(971); match(RPAR); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(1005); + setState(973); match(LPAR); - setState(1006); + setState(974); match(GET); - setState(1008); + setState(976); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1007); + setState(975); match(VAR); } } - setState(1010); + setState(978); name(); - setState(1011); + setState(979); match(RPAR); } break; @@ -6416,137 +6315,137 @@ public final AssertionContext assertion() throws RecognitionException { AssertionContext _localctx = new AssertionContext(_ctx, getState()); enterRule(_localctx, 136, RULE_assertion); try { - setState(1067); + setState(1035); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,107,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,101,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(1015); + setState(983); match(LPAR); - setState(1016); + setState(984); match(ASSERT_MALFORMED); - setState(1017); + setState(985); scriptModule(); - setState(1018); + setState(986); match(STRING_); - setState(1019); + setState(987); match(RPAR); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(1021); + setState(989); match(LPAR); - setState(1022); + setState(990); match(ASSERT_INVALID); - setState(1023); + setState(991); scriptModule(); - setState(1024); + setState(992); match(STRING_); - setState(1025); + setState(993); match(RPAR); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(1027); + setState(995); match(LPAR); - setState(1028); + setState(996); match(ASSERT_UNLINKABLE); - setState(1029); + setState(997); scriptModule(); - setState(1030); + setState(998); match(STRING_); - setState(1031); + setState(999); match(RPAR); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(1033); + setState(1001); match(LPAR); - setState(1034); + setState(1002); match(ASSERT_TRAP); - setState(1035); + setState(1003); scriptModule(); - setState(1036); + setState(1004); match(STRING_); - setState(1037); + setState(1005); match(RPAR); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(1039); + setState(1007); match(LPAR); - setState(1040); + setState(1008); match(ASSERT_RETURN); - setState(1041); + setState(1009); action_(); - setState(1042); + setState(1010); constList(); - setState(1043); + setState(1011); match(RPAR); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(1045); + setState(1013); match(LPAR); - setState(1046); + setState(1014); match(ASSERT_RETURN_CANONICAL_NAN); - setState(1047); + setState(1015); action_(); - setState(1048); + setState(1016); match(RPAR); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(1050); + setState(1018); match(LPAR); - setState(1051); + setState(1019); match(ASSERT_RETURN_ARITHMETIC_NAN); - setState(1052); + setState(1020); action_(); - setState(1053); + setState(1021); match(RPAR); } break; case 8: enterOuterAlt(_localctx, 8); { - setState(1055); + setState(1023); match(LPAR); - setState(1056); + setState(1024); match(ASSERT_TRAP); - setState(1057); + setState(1025); action_(); - setState(1058); + setState(1026); match(STRING_); - setState(1059); + setState(1027); match(RPAR); } break; case 9: enterOuterAlt(_localctx, 9); { - setState(1061); + setState(1029); match(LPAR); - setState(1062); + setState(1030); match(ASSERT_EXHAUSTION); - setState(1063); + setState(1031); action_(); - setState(1064); + setState(1032); match(STRING_); - setState(1065); + setState(1033); match(RPAR); } break; @@ -6611,64 +6510,64 @@ public final CmdContext cmd() throws RecognitionException { enterRule(_localctx, 138, RULE_cmd); int _la; try { - setState(1082); + setState(1050); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,109,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,103,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(1069); + setState(1037); action_(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(1070); + setState(1038); assertion(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(1071); + setState(1039); scriptModule(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(1072); + setState(1040); match(LPAR); - setState(1073); + setState(1041); match(REGISTER); - setState(1074); + setState(1042); name(); - setState(1076); + setState(1044); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1075); + setState(1043); match(VAR); } } - setState(1078); + setState(1046); match(RPAR); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(1080); + setState(1048); meta(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(1081); + setState(1049); instance(); } break; @@ -6721,33 +6620,33 @@ public final InstanceContext instance() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(1084); + setState(1052); match(LPAR); - setState(1085); + setState(1053); match(MODULE); - setState(1086); + setState(1054); match(INSTANCE); - setState(1088); + setState(1056); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,110,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,104,_ctx) ) { case 1: { - setState(1087); + setState(1055); match(VAR); } break; } - setState(1091); + setState(1059); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1090); + setState(1058); match(VAR); } } - setState(1093); + setState(1061); match(RPAR); } } @@ -6801,108 +6700,108 @@ public final MetaContext meta() throws RecognitionException { enterRule(_localctx, 142, RULE_meta); int _la; try { - setState(1127); + setState(1095); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,117,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,111,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(1095); + setState(1063); match(LPAR); - setState(1096); + setState(1064); match(SCRIPT); - setState(1098); + setState(1066); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1097); + setState(1065); match(VAR); } } - setState(1103); + setState(1071); _errHandler.sync(this); _la = _input.LA(1); while (_la==LPAR) { { { - setState(1100); + setState(1068); cmd(); } } - setState(1105); + setState(1073); _errHandler.sync(this); _la = _input.LA(1); } - setState(1106); + setState(1074); match(RPAR); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(1107); + setState(1075); match(LPAR); - setState(1108); + setState(1076); match(INPUT); - setState(1110); + setState(1078); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1109); + setState(1077); match(VAR); } } - setState(1112); + setState(1080); match(STRING_); - setState(1113); + setState(1081); match(RPAR); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(1114); + setState(1082); match(LPAR); - setState(1115); + setState(1083); match(OUTPUT); - setState(1117); + setState(1085); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1116); + setState(1084); match(VAR); } } - setState(1119); + setState(1087); match(STRING_); - setState(1120); + setState(1088); match(RPAR); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(1121); + setState(1089); match(LPAR); - setState(1122); + setState(1090); match(OUTPUT); - setState(1124); + setState(1092); _errHandler.sync(this); _la = _input.LA(1); if (_la==VAR) { { - setState(1123); + setState(1091); match(VAR); } } - setState(1126); + setState(1094); match(RPAR); } break; @@ -6952,13 +6851,13 @@ public final WconstContext wconst() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(1129); + setState(1097); match(LPAR); - setState(1130); + setState(1098); match(CONST); - setState(1131); + setState(1099); literal(); - setState(1132); + setState(1100); match(RPAR); } } @@ -7007,17 +6906,17 @@ public final ConstListContext constList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(1137); + setState(1105); _errHandler.sync(this); _la = _input.LA(1); while (_la==LPAR) { { { - setState(1134); + setState(1102); wconst(); } } - setState(1139); + setState(1107); _errHandler.sync(this); _la = _input.LA(1); } @@ -7073,48 +6972,48 @@ public final ScriptContext script() throws RecognitionException { enterRule(_localctx, 148, RULE_script); int _la; try { - setState(1154); + setState(1122); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,121,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,115,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(1143); + setState(1111); _errHandler.sync(this); _la = _input.LA(1); while (_la==LPAR) { { { - setState(1140); + setState(1108); cmd(); } } - setState(1145); + setState(1113); _errHandler.sync(this); _la = _input.LA(1); } - setState(1146); + setState(1114); match(EOF); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(1148); + setState(1116); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(1147); + setState(1115); moduleField(); } } - setState(1150); + setState(1118); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==LPAR ); - setState(1152); + setState(1120); match(EOF); } break; @@ -7167,36 +7066,36 @@ public final ModuleContext module() throws RecognitionException { enterRule(_localctx, 150, RULE_module); int _la; try { - setState(1166); + setState(1134); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,123,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,117,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(1156); + setState(1124); module_(); - setState(1157); + setState(1125); match(EOF); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(1162); + setState(1130); _errHandler.sync(this); _la = _input.LA(1); while (_la==LPAR) { { { - setState(1159); + setState(1127); moduleField(); } } - setState(1164); + setState(1132); _errHandler.sync(this); _la = _input.LA(1); } - setState(1165); + setState(1133); match(EOF); } break; @@ -7214,7 +7113,7 @@ public final ModuleContext module() throws RecognitionException { } public static final String _serializedATN = - "\u0004\u0001\u00ab\u0491\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001"+ + "\u0004\u0001\u00ab\u0471\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001"+ "\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004"+ "\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007"+ "\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b"+ @@ -7303,165 +7202,162 @@ public final ModuleContext module() throws RecognitionException { "+\u0001+\u0001+\u0003+\u0286\b+\u0001,\u0001,\u0001,\u0001-\u0001-\u0001"+ "-\u0005-\u028e\b-\n-\f-\u0291\t-\u0001-\u0001-\u0001-\u0003-\u0296\b-"+ "\u0001-\u0005-\u0299\b-\n-\f-\u029c\t-\u0001-\u0001-\u0001.\u0001.\u0001"+ - ".\u0001.\u0001.\u0001.\u0003.\u02a6\b.\u0001/\u0001/\u0001/\u0003/\u02ab"+ - "\b/\u0001/\u0001/\u0001/\u0001/\u0005/\u02b1\b/\n/\f/\u02b4\t/\u0001/"+ - "\u0001/\u0001/\u0001/\u0001/\u0003/\u02bb\b/\u0001/\u0001/\u0005/\u02bf"+ - "\b/\n/\f/\u02c2\t/\u0001/\u0001/\u0001/\u0001/\u0001/\u0003/\u02c9\b/"+ - "\u0001/\u0001/\u0001/\u0005/\u02ce\b/\n/\f/\u02d1\t/\u0001/\u0003/\u02d4"+ - "\b/\u00010\u00010\u00010\u00030\u02d9\b0\u00010\u00010\u00010\u00011\u0001"+ - "1\u00011\u00011\u00011\u00011\u00011\u00011\u00011\u00011\u00011\u0005"+ - "1\u02e9\b1\n1\f1\u02ec\t1\u00011\u00011\u00031\u02f0\b1\u00012\u00012"+ - "\u00012\u00032\u02f5\b2\u00012\u00012\u00012\u00012\u00052\u02fb\b2\n"+ - "2\f2\u02fe\t2\u00012\u00012\u00012\u00012\u00012\u00032\u0305\b2\u0001"+ - "2\u00012\u00052\u0309\b2\n2\f2\u030c\t2\u00012\u00012\u00032\u0310\b2"+ - "\u00013\u00013\u00013\u00033\u0315\b3\u00013\u00013\u00013\u00014\u0001"+ - "4\u00014\u00014\u00014\u00014\u00014\u00014\u00014\u00014\u00054\u0324"+ - "\b4\n4\f4\u0327\t4\u00014\u00034\u032a\b4\u00015\u00015\u00015\u00035"+ - "\u032f\b5\u00015\u00015\u00015\u00016\u00016\u00016\u00016\u00016\u0001"+ - "6\u00016\u00016\u00016\u00036\u033d\b6\u00017\u00017\u00017\u00037\u0342"+ - "\b7\u00017\u00017\u00017\u00017\u00017\u00017\u00037\u034a\b7\u00017\u0001"+ - "7\u00017\u00017\u00017\u00017\u00037\u0352\b7\u00017\u00017\u00017\u0001"+ - "7\u00017\u00017\u00037\u035a\b7\u00017\u00017\u00017\u00017\u00017\u0001"+ - "7\u00037\u0362\b7\u00017\u00017\u00017\u00037\u0367\b7\u00018\u00018\u0001"+ - "8\u00018\u00018\u00018\u00018\u00019\u00019\u00019\u00019\u00019\u0001"+ - "9\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001"+ + ".\u0001.\u0001.\u0001.\u0003.\u02a6\b.\u0001/\u0001/\u0001/\u0001/\u0001"+ + "/\u0001/\u0001/\u0005/\u02af\b/\n/\f/\u02b2\t/\u0001/\u0001/\u00010\u0001"+ + "0\u00010\u00030\u02b9\b0\u00010\u00010\u00010\u00011\u00011\u00011\u0001"+ + "1\u00011\u00011\u00011\u00011\u00011\u00011\u00011\u00051\u02c9\b1\n1"+ + "\f1\u02cc\t1\u00011\u00011\u00031\u02d0\b1\u00012\u00012\u00012\u0003"+ + "2\u02d5\b2\u00012\u00012\u00012\u00012\u00052\u02db\b2\n2\f2\u02de\t2"+ + "\u00012\u00012\u00012\u00012\u00012\u00032\u02e5\b2\u00012\u00012\u0005"+ + "2\u02e9\b2\n2\f2\u02ec\t2\u00012\u00012\u00032\u02f0\b2\u00013\u00013"+ + "\u00013\u00033\u02f5\b3\u00013\u00013\u00013\u00014\u00014\u00014\u0001"+ + "4\u00014\u00014\u00014\u00014\u00014\u00014\u00054\u0304\b4\n4\f4\u0307"+ + "\t4\u00014\u00034\u030a\b4\u00015\u00015\u00015\u00035\u030f\b5\u0001"+ + "5\u00015\u00015\u00016\u00016\u00016\u00016\u00016\u00016\u00016\u0001"+ + "6\u00016\u00036\u031d\b6\u00017\u00017\u00017\u00037\u0322\b7\u00017\u0001"+ + "7\u00017\u00017\u00017\u00017\u00037\u032a\b7\u00017\u00017\u00017\u0001"+ + "7\u00017\u00017\u00037\u0332\b7\u00017\u00017\u00017\u00017\u00017\u0001"+ + "7\u00037\u033a\b7\u00017\u00017\u00017\u00017\u00017\u00017\u00037\u0342"+ + "\b7\u00017\u00017\u00017\u00037\u0347\b7\u00018\u00018\u00018\u00018\u0001"+ + "8\u00018\u00018\u00019\u00019\u00019\u00019\u00019\u00019\u0001:\u0001"+ ":\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001"+ - ":\u0003:\u038a\b:\u0001;\u0001;\u0001;\u0001;\u0001;\u0001;\u0001<\u0001"+ - "<\u0001<\u0001<\u0001<\u0001=\u0001=\u0001=\u0003=\u039a\b=\u0001=\u0001"+ - "=\u0001=\u0001=\u0001>\u0001>\u0001>\u0003>\u03a3\b>\u0001>\u0001>\u0001"+ - ">\u0001?\u0001?\u0001?\u0001?\u0001?\u0001@\u0001@\u0001@\u0001@\u0001"+ - "@\u0001@\u0001@\u0001@\u0001@\u0001@\u0001@\u0003@\u03b8\b@\u0001A\u0001"+ - "A\u0001A\u0003A\u03bd\bA\u0001A\u0005A\u03c0\bA\nA\fA\u03c3\tA\u0001A"+ - "\u0001A\u0001B\u0001B\u0001B\u0001B\u0003B\u03cb\bB\u0001B\u0001B\u0005"+ - "B\u03cf\bB\nB\fB\u03d2\tB\u0001B\u0001B\u0001B\u0001B\u0001B\u0003B\u03d9"+ - "\bB\u0001B\u0001B\u0005B\u03dd\bB\nB\fB\u03e0\tB\u0001B\u0003B\u03e3\b"+ - "B\u0001C\u0001C\u0001C\u0003C\u03e8\bC\u0001C\u0001C\u0001C\u0001C\u0001"+ - "C\u0001C\u0001C\u0003C\u03f1\bC\u0001C\u0001C\u0001C\u0003C\u03f6\bC\u0001"+ + ":\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0003:\u036a"+ + "\b:\u0001;\u0001;\u0001;\u0001;\u0001;\u0001;\u0001<\u0001<\u0001<\u0001"+ + "<\u0001<\u0001=\u0001=\u0001=\u0003=\u037a\b=\u0001=\u0001=\u0001=\u0001"+ + "=\u0001>\u0001>\u0001>\u0003>\u0383\b>\u0001>\u0001>\u0001>\u0001?\u0001"+ + "?\u0001?\u0001?\u0001?\u0001@\u0001@\u0001@\u0001@\u0001@\u0001@\u0001"+ + "@\u0001@\u0001@\u0001@\u0001@\u0003@\u0398\b@\u0001A\u0001A\u0001A\u0003"+ + "A\u039d\bA\u0001A\u0005A\u03a0\bA\nA\fA\u03a3\tA\u0001A\u0001A\u0001B"+ + "\u0001B\u0001B\u0001B\u0003B\u03ab\bB\u0001B\u0001B\u0005B\u03af\bB\n"+ + "B\fB\u03b2\tB\u0001B\u0001B\u0001B\u0001B\u0001B\u0003B\u03b9\bB\u0001"+ + "B\u0001B\u0005B\u03bd\bB\nB\fB\u03c0\tB\u0001B\u0003B\u03c3\bB\u0001C"+ + "\u0001C\u0001C\u0003C\u03c8\bC\u0001C\u0001C\u0001C\u0001C\u0001C\u0001"+ + "C\u0001C\u0003C\u03d1\bC\u0001C\u0001C\u0001C\u0003C\u03d6\bC\u0001D\u0001"+ "D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001"+ "D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001"+ "D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001"+ "D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001"+ "D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001D\u0001"+ - "D\u0001D\u0003D\u042c\bD\u0001E\u0001E\u0001E\u0001E\u0001E\u0001E\u0001"+ - "E\u0003E\u0435\bE\u0001E\u0001E\u0001E\u0001E\u0003E\u043b\bE\u0001F\u0001"+ - "F\u0001F\u0001F\u0003F\u0441\bF\u0001F\u0003F\u0444\bF\u0001F\u0001F\u0001"+ - "G\u0001G\u0001G\u0003G\u044b\bG\u0001G\u0005G\u044e\bG\nG\fG\u0451\tG"+ - "\u0001G\u0001G\u0001G\u0001G\u0003G\u0457\bG\u0001G\u0001G\u0001G\u0001"+ - "G\u0001G\u0003G\u045e\bG\u0001G\u0001G\u0001G\u0001G\u0001G\u0003G\u0465"+ - "\bG\u0001G\u0003G\u0468\bG\u0001H\u0001H\u0001H\u0001H\u0001H\u0001I\u0005"+ - "I\u0470\bI\nI\fI\u0473\tI\u0001J\u0005J\u0476\bJ\nJ\fJ\u0479\tJ\u0001"+ - "J\u0001J\u0004J\u047d\bJ\u000bJ\fJ\u047e\u0001J\u0001J\u0003J\u0483\b"+ - "J\u0001K\u0001K\u0001K\u0001K\u0005K\u0489\bK\nK\fK\u048c\tK\u0001K\u0003"+ - "K\u048f\bK\u0001K\u0000\u0000L\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010"+ - "\u0012\u0014\u0016\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BDFHJLNPR"+ - "TVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082\u0084\u0086\u0088\u008a\u008c\u008e"+ - "\u0090\u0092\u0094\u0096\u0000\u0004\u0001\u0000\u0004\u0005\u0001\u0000"+ - "\u0003\u0005\u0002\u0000\u0003\u0003\u00a8\u00a8\u0001\u0000\u0096\u0097"+ - "\u0519\u0000\u0098\u0001\u0000\u0000\u0000\u0002\u009a\u0001\u0000\u0000"+ - "\u0000\u0004\u009c\u0001\u0000\u0000\u0000\u0006\u00ab\u0001\u0000\u0000"+ - "\u0000\b\u00ad\u0001\u0000\u0000\u0000\n\u00b2\u0001\u0000\u0000\u0000"+ - "\f\u00b7\u0001\u0000\u0000\u0000\u000e\u00bf\u0001\u0000\u0000\u0000\u0010"+ - "\u00cb\u0001\u0000\u0000\u0000\u0012\u00dd\u0001\u0000\u0000\u0000\u0014"+ - "\u00eb\u0001\u0000\u0000\u0000\u0016\u00ee\u0001\u0000\u0000\u0000\u0018"+ - "\u00f1\u0001\u0000\u0000\u0000\u001a\u00f7\u0001\u0000\u0000\u0000\u001c"+ - "\u00fb\u0001\u0000\u0000\u0000\u001e\u0100\u0001\u0000\u0000\u0000 \u0102"+ - "\u0001\u0000\u0000\u0000\"\u0104\u0001\u0000\u0000\u0000$\u010b\u0001"+ - "\u0000\u0000\u0000&\u010d\u0001\u0000\u0000\u0000(\u0165\u0001\u0000\u0000"+ - "\u0000*\u0167\u0001\u0000\u0000\u0000,\u016f\u0001\u0000\u0000\u0000."+ - "\u0175\u0001\u0000\u0000\u00000\u0178\u0001\u0000\u0000\u00002\u017b\u0001"+ - "\u0000\u0000\u00004\u0182\u0001\u0000\u0000\u00006\u0187\u0001\u0000\u0000"+ - "\u00008\u0194\u0001\u0000\u0000\u0000:\u01a1\u0001\u0000\u0000\u0000<"+ - "\u01bd\u0001\u0000\u0000\u0000>\u01cd\u0001\u0000\u0000\u0000@\u01fa\u0001"+ - "\u0000\u0000\u0000B\u0207\u0001\u0000\u0000\u0000D\u0209\u0001\u0000\u0000"+ - "\u0000F\u020c\u0001\u0000\u0000\u0000H\u023a\u0001\u0000\u0000\u0000J"+ - "\u023d\u0001\u0000\u0000\u0000L\u024c\u0001\u0000\u0000\u0000N\u025c\u0001"+ - "\u0000\u0000\u0000P\u0268\u0001\u0000\u0000\u0000R\u026e\u0001\u0000\u0000"+ - "\u0000T\u0270\u0001\u0000\u0000\u0000V\u0285\u0001\u0000\u0000\u0000X"+ - "\u0287\u0001\u0000\u0000\u0000Z\u029a\u0001\u0000\u0000\u0000\\\u02a5"+ - "\u0001\u0000\u0000\u0000^\u02d3\u0001\u0000\u0000\u0000`\u02d5\u0001\u0000"+ - "\u0000\u0000b\u02ef\u0001\u0000\u0000\u0000d\u030f\u0001\u0000\u0000\u0000"+ - "f\u0311\u0001\u0000\u0000\u0000h\u0329\u0001\u0000\u0000\u0000j\u032b"+ - "\u0001\u0000\u0000\u0000l\u033c\u0001\u0000\u0000\u0000n\u0366\u0001\u0000"+ - "\u0000\u0000p\u0368\u0001\u0000\u0000\u0000r\u036f\u0001\u0000\u0000\u0000"+ - "t\u0389\u0001\u0000\u0000\u0000v\u038b\u0001\u0000\u0000\u0000x\u0391"+ - "\u0001\u0000\u0000\u0000z\u0396\u0001\u0000\u0000\u0000|\u039f\u0001\u0000"+ - "\u0000\u0000~\u03a7\u0001\u0000\u0000\u0000\u0080\u03b7\u0001\u0000\u0000"+ - "\u0000\u0082\u03b9\u0001\u0000\u0000\u0000\u0084\u03e2\u0001\u0000\u0000"+ - "\u0000\u0086\u03f5\u0001\u0000\u0000\u0000\u0088\u042b\u0001\u0000\u0000"+ - "\u0000\u008a\u043a\u0001\u0000\u0000\u0000\u008c\u043c\u0001\u0000\u0000"+ - "\u0000\u008e\u0467\u0001\u0000\u0000\u0000\u0090\u0469\u0001\u0000\u0000"+ - "\u0000\u0092\u0471\u0001\u0000\u0000\u0000\u0094\u0482\u0001\u0000\u0000"+ - "\u0000\u0096\u048e\u0001\u0000\u0000\u0000\u0098\u0099\u0007\u0000\u0000"+ - "\u0000\u0099\u0001\u0001\u0000\u0000\u0000\u009a\u009b\u0005\u0006\u0000"+ - "\u0000\u009b\u0003\u0001\u0000\u0000\u0000\u009c\u009d\u0005\u0007\u0000"+ - "\u0000\u009d\u0005\u0001\u0000\u0000\u0000\u009e\u00ac\u0005\n\u0000\u0000"+ - "\u009f\u00ac\u0005\u000b\u0000\u0000\u00a0\u00a1\u0005\u0001\u0000\u0000"+ - "\u00a1\u00a2\u0005\r\u0000\u0000\u00a2\u00a3\u0003 \u0010\u0000\u00a3"+ - "\u00a4\u0005\u0002\u0000\u0000\u00a4\u00ac\u0001\u0000\u0000\u0000\u00a5"+ - "\u00a6\u0005\u0001\u0000\u0000\u00a6\u00a7\u0005\r\u0000\u0000\u00a7\u00a8"+ - "\u0005\u000f\u0000\u0000\u00a8\u00a9\u0003 \u0010\u0000\u00a9\u00aa\u0005"+ - "\u0002\u0000\u0000\u00aa\u00ac\u0001\u0000\u0000\u0000\u00ab\u009e\u0001"+ - "\u0000\u0000\u0000\u00ab\u009f\u0001\u0000\u0000\u0000\u00ab\u00a0\u0001"+ - "\u0000\u0000\u0000\u00ab\u00a5\u0001\u0000\u0000\u0000\u00ac\u0007\u0001"+ - "\u0000\u0000\u0000\u00ad\u00ae\u0005\u00a9\u0000\u0000\u00ae\t\u0001\u0000"+ - "\u0000\u0000\u00af\u00b3\u0003\u0004\u0002\u0000\u00b0\u00b3\u0003\b\u0004"+ - "\u0000\u00b1\u00b3\u0003\u0006\u0003\u0000\u00b2\u00af\u0001\u0000\u0000"+ - "\u0000\u00b2\u00b0\u0001\u0000\u0000\u0000\u00b2\u00b1\u0001\u0000\u0000"+ - "\u0000\u00b3\u000b\u0001\u0000\u0000\u0000\u00b4\u00b8\u0005\u0085\u0000"+ - "\u0000\u00b5\u00b8\u0005\u0086\u0000\u0000\u00b6\u00b8\u0003\u0016\u000b"+ - "\u0000\u00b7\u00b4\u0001\u0000\u0000\u0000\u00b7\u00b5\u0001\u0000\u0000"+ - "\u0000\u00b7\u00b6\u0001\u0000\u0000\u0000\u00b8\r\u0001\u0000\u0000\u0000"+ - "\u00b9\u00c0\u0003\n\u0005\u0000\u00ba\u00bb\u0005\u0001\u0000\u0000\u00bb"+ - "\u00bc\u0005\f\u0000\u0000\u00bc\u00bd\u0003\n\u0005\u0000\u00bd\u00be"+ - "\u0005\u0002\u0000\u0000\u00be\u00c0\u0001\u0000\u0000\u0000\u00bf\u00b9"+ - "\u0001\u0000\u0000\u0000\u00bf\u00ba\u0001\u0000\u0000\u0000\u00c0\u000f"+ - "\u0001\u0000\u0000\u0000\u00c1\u00c2\u0005\u0001\u0000\u0000\u00c2\u00c3"+ - "\u0005\u0085\u0000\u0000\u00c3\u00c4\u0003\u0016\u000b\u0000\u00c4\u00c5"+ - "\u0005\u0002\u0000\u0000\u00c5\u00cc\u0001\u0000\u0000\u0000\u00c6\u00c7"+ - "\u0005\u0001\u0000\u0000\u00c7\u00c8\u0005\u000e\u0000\u0000\u00c8\u00c9"+ - "\u0003 \u0010\u0000\u00c9\u00ca\u0005\u0002\u0000\u0000\u00ca\u00cc\u0001"+ - "\u0000\u0000\u0000\u00cb\u00c1\u0001\u0000\u0000\u0000\u00cb\u00c6\u0001"+ - "\u0000\u0000\u0000\u00cc\u0011\u0001\u0000\u0000\u0000\u00cd\u00ce\u0005"+ - "\u0001\u0000\u0000\u00ce\u00d8\u0005\u0088\u0000\u0000\u00cf\u00d1\u0003"+ - "\n\u0005\u0000\u00d0\u00cf\u0001\u0000\u0000\u0000\u00d1\u00d4\u0001\u0000"+ - "\u0000\u0000\u00d2\u00d0\u0001\u0000\u0000\u0000\u00d2\u00d3\u0001\u0000"+ - "\u0000\u0000\u00d3\u00d9\u0001\u0000\u0000\u0000\u00d4\u00d2\u0001\u0000"+ - "\u0000\u0000\u00d5\u00d6\u0003\"\u0011\u0000\u00d6\u00d7\u0003\n\u0005"+ - "\u0000\u00d7\u00d9\u0001\u0000\u0000\u0000\u00d8\u00d2\u0001\u0000\u0000"+ - "\u0000\u00d8\u00d5\u0001\u0000\u0000\u0000\u00d9\u00da\u0001\u0000\u0000"+ - "\u0000\u00da\u00dc\u0005\u0002\u0000\u0000\u00db\u00cd\u0001\u0000\u0000"+ - "\u0000\u00dc\u00df\u0001\u0000\u0000\u0000\u00dd\u00db\u0001\u0000\u0000"+ - "\u0000\u00dd\u00de\u0001\u0000\u0000\u0000\u00de\u0013\u0001\u0000\u0000"+ - "\u0000\u00df\u00dd\u0001\u0000\u0000\u0000\u00e0\u00e1\u0005\u0001\u0000"+ - "\u0000\u00e1\u00e5\u0005\u0089\u0000\u0000\u00e2\u00e4\u0003\n\u0005\u0000"+ - "\u00e3\u00e2\u0001\u0000\u0000\u0000\u00e4\u00e7\u0001\u0000\u0000\u0000"+ - "\u00e5\u00e3\u0001\u0000\u0000\u0000\u00e5\u00e6\u0001\u0000\u0000\u0000"+ - "\u00e6\u00e8\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001\u0000\u0000\u0000"+ - "\u00e8\u00ea\u0005\u0002\u0000\u0000\u00e9\u00e0\u0001\u0000\u0000\u0000"+ - "\u00ea\u00ed\u0001\u0000\u0000\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000"+ - "\u00eb\u00ec\u0001\u0000\u0000\u0000\u00ec\u0015\u0001\u0000\u0000\u0000"+ - "\u00ed\u00eb\u0001\u0000\u0000\u0000\u00ee\u00ef\u0003\u0012\t\u0000\u00ef"+ - "\u00f0\u0003\u0014\n\u0000\u00f0\u0017\u0001\u0000\u0000\u0000\u00f1\u00f3"+ - "\u0005\u0003\u0000\u0000\u00f2\u00f4\u0005\u0003\u0000\u0000\u00f3\u00f2"+ - "\u0001\u0000\u0000\u0000\u00f3\u00f4\u0001\u0000\u0000\u0000\u00f4\u00f5"+ - "\u0001\u0000\u0000\u0000\u00f5\u00f6\u0003\u0006\u0003\u0000\u00f6\u0019"+ - "\u0001\u0000\u0000\u0000\u00f7\u00f9\u0005\u0003\u0000\u0000\u00f8\u00fa"+ - "\u0005\u0003\u0000\u0000\u00f9\u00f8\u0001\u0000\u0000\u0000\u00f9\u00fa"+ - "\u0001\u0000\u0000\u0000\u00fa\u001b\u0001\u0000\u0000\u0000\u00fb\u00fc"+ - "\u0005\u0001\u0000\u0000\u00fc\u00fd\u0005\u0084\u0000\u0000\u00fd\u00fe"+ - "\u0003 \u0010\u0000\u00fe\u00ff\u0005\u0002\u0000\u0000\u00ff\u001d\u0001"+ - "\u0000\u0000\u0000\u0100\u0101\u0007\u0001\u0000\u0000\u0101\u001f\u0001"+ - "\u0000\u0000\u0000\u0102\u0103\u0007\u0002\u0000\u0000\u0103!\u0001\u0000"+ - "\u0000\u0000\u0104\u0105\u0005\u00a8\u0000\u0000\u0105#\u0001\u0000\u0000"+ - "\u0000\u0106\u010c\u0003(\u0014\u0000\u0107\u010c\u0003@ \u0000\u0108"+ - "\u010c\u0003F#\u0000\u0109\u010c\u0003*\u0015\u0000\u010a\u010c\u0003"+ - "&\u0013\u0000\u010b\u0106\u0001\u0000\u0000\u0000\u010b\u0107\u0001\u0000"+ - "\u0000\u0000\u010b\u0108\u0001\u0000\u0000\u0000\u010b\u0109\u0001\u0000"+ - "\u0000\u0000\u010b\u010a\u0001\u0000\u0000\u0000\u010c%\u0001\u0000\u0000"+ - "\u0000\u010d\u010e\u0005\u0018\u0000\u0000\u010e\u010f\u0005\u0001\u0000"+ - "\u0000\u010f\u0110\u0003P(\u0000\u0110\u0111\u0005\u0019\u0000\u0000\u0111"+ - "\u0112\u0003P(\u0000\u0112\u0113\u0005\u0019\u0000\u0000\u0113\u0114\u0003"+ - "P(\u0000\u0114\u0115\u0005\u0002\u0000\u0000\u0115\u0116\u0003P(\u0000"+ + "D\u0003D\u040c\bD\u0001E\u0001E\u0001E\u0001E\u0001E\u0001E\u0001E\u0003"+ + "E\u0415\bE\u0001E\u0001E\u0001E\u0001E\u0003E\u041b\bE\u0001F\u0001F\u0001"+ + "F\u0001F\u0003F\u0421\bF\u0001F\u0003F\u0424\bF\u0001F\u0001F\u0001G\u0001"+ + "G\u0001G\u0003G\u042b\bG\u0001G\u0005G\u042e\bG\nG\fG\u0431\tG\u0001G"+ + "\u0001G\u0001G\u0001G\u0003G\u0437\bG\u0001G\u0001G\u0001G\u0001G\u0001"+ + "G\u0003G\u043e\bG\u0001G\u0001G\u0001G\u0001G\u0001G\u0003G\u0445\bG\u0001"+ + "G\u0003G\u0448\bG\u0001H\u0001H\u0001H\u0001H\u0001H\u0001I\u0005I\u0450"+ + "\bI\nI\fI\u0453\tI\u0001J\u0005J\u0456\bJ\nJ\fJ\u0459\tJ\u0001J\u0001"+ + "J\u0004J\u045d\bJ\u000bJ\fJ\u045e\u0001J\u0001J\u0003J\u0463\bJ\u0001"+ + "K\u0001K\u0001K\u0001K\u0005K\u0469\bK\nK\fK\u046c\tK\u0001K\u0003K\u046f"+ + "\bK\u0001K\u0000\u0000L\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012"+ + "\u0014\u0016\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BDFHJLNPRTVXZ\\"+ + "^`bdfhjlnprtvxz|~\u0080\u0082\u0084\u0086\u0088\u008a\u008c\u008e\u0090"+ + "\u0092\u0094\u0096\u0000\u0004\u0001\u0000\u0004\u0005\u0001\u0000\u0003"+ + "\u0005\u0002\u0000\u0003\u0003\u00a8\u00a8\u0001\u0000\u0096\u0097\u04f2"+ + "\u0000\u0098\u0001\u0000\u0000\u0000\u0002\u009a\u0001\u0000\u0000\u0000"+ + "\u0004\u009c\u0001\u0000\u0000\u0000\u0006\u00ab\u0001\u0000\u0000\u0000"+ + "\b\u00ad\u0001\u0000\u0000\u0000\n\u00b2\u0001\u0000\u0000\u0000\f\u00b7"+ + "\u0001\u0000\u0000\u0000\u000e\u00bf\u0001\u0000\u0000\u0000\u0010\u00cb"+ + "\u0001\u0000\u0000\u0000\u0012\u00dd\u0001\u0000\u0000\u0000\u0014\u00eb"+ + "\u0001\u0000\u0000\u0000\u0016\u00ee\u0001\u0000\u0000\u0000\u0018\u00f1"+ + "\u0001\u0000\u0000\u0000\u001a\u00f7\u0001\u0000\u0000\u0000\u001c\u00fb"+ + "\u0001\u0000\u0000\u0000\u001e\u0100\u0001\u0000\u0000\u0000 \u0102\u0001"+ + "\u0000\u0000\u0000\"\u0104\u0001\u0000\u0000\u0000$\u010b\u0001\u0000"+ + "\u0000\u0000&\u010d\u0001\u0000\u0000\u0000(\u0165\u0001\u0000\u0000\u0000"+ + "*\u0167\u0001\u0000\u0000\u0000,\u016f\u0001\u0000\u0000\u0000.\u0175"+ + "\u0001\u0000\u0000\u00000\u0178\u0001\u0000\u0000\u00002\u017b\u0001\u0000"+ + "\u0000\u00004\u0182\u0001\u0000\u0000\u00006\u0187\u0001\u0000\u0000\u0000"+ + "8\u0194\u0001\u0000\u0000\u0000:\u01a1\u0001\u0000\u0000\u0000<\u01bd"+ + "\u0001\u0000\u0000\u0000>\u01cd\u0001\u0000\u0000\u0000@\u01fa\u0001\u0000"+ + "\u0000\u0000B\u0207\u0001\u0000\u0000\u0000D\u0209\u0001\u0000\u0000\u0000"+ + "F\u020c\u0001\u0000\u0000\u0000H\u023a\u0001\u0000\u0000\u0000J\u023d"+ + "\u0001\u0000\u0000\u0000L\u024c\u0001\u0000\u0000\u0000N\u025c\u0001\u0000"+ + "\u0000\u0000P\u0268\u0001\u0000\u0000\u0000R\u026e\u0001\u0000\u0000\u0000"+ + "T\u0270\u0001\u0000\u0000\u0000V\u0285\u0001\u0000\u0000\u0000X\u0287"+ + "\u0001\u0000\u0000\u0000Z\u029a\u0001\u0000\u0000\u0000\\\u02a5\u0001"+ + "\u0000\u0000\u0000^\u02a7\u0001\u0000\u0000\u0000`\u02b5\u0001\u0000\u0000"+ + "\u0000b\u02cf\u0001\u0000\u0000\u0000d\u02ef\u0001\u0000\u0000\u0000f"+ + "\u02f1\u0001\u0000\u0000\u0000h\u0309\u0001\u0000\u0000\u0000j\u030b\u0001"+ + "\u0000\u0000\u0000l\u031c\u0001\u0000\u0000\u0000n\u0346\u0001\u0000\u0000"+ + "\u0000p\u0348\u0001\u0000\u0000\u0000r\u034f\u0001\u0000\u0000\u0000t"+ + "\u0369\u0001\u0000\u0000\u0000v\u036b\u0001\u0000\u0000\u0000x\u0371\u0001"+ + "\u0000\u0000\u0000z\u0376\u0001\u0000\u0000\u0000|\u037f\u0001\u0000\u0000"+ + "\u0000~\u0387\u0001\u0000\u0000\u0000\u0080\u0397\u0001\u0000\u0000\u0000"+ + "\u0082\u0399\u0001\u0000\u0000\u0000\u0084\u03c2\u0001\u0000\u0000\u0000"+ + "\u0086\u03d5\u0001\u0000\u0000\u0000\u0088\u040b\u0001\u0000\u0000\u0000"+ + "\u008a\u041a\u0001\u0000\u0000\u0000\u008c\u041c\u0001\u0000\u0000\u0000"+ + "\u008e\u0447\u0001\u0000\u0000\u0000\u0090\u0449\u0001\u0000\u0000\u0000"+ + "\u0092\u0451\u0001\u0000\u0000\u0000\u0094\u0462\u0001\u0000\u0000\u0000"+ + "\u0096\u046e\u0001\u0000\u0000\u0000\u0098\u0099\u0007\u0000\u0000\u0000"+ + "\u0099\u0001\u0001\u0000\u0000\u0000\u009a\u009b\u0005\u0006\u0000\u0000"+ + "\u009b\u0003\u0001\u0000\u0000\u0000\u009c\u009d\u0005\u0007\u0000\u0000"+ + "\u009d\u0005\u0001\u0000\u0000\u0000\u009e\u00ac\u0005\n\u0000\u0000\u009f"+ + "\u00ac\u0005\u000b\u0000\u0000\u00a0\u00a1\u0005\u0001\u0000\u0000\u00a1"+ + "\u00a2\u0005\r\u0000\u0000\u00a2\u00a3\u0003 \u0010\u0000\u00a3\u00a4"+ + "\u0005\u0002\u0000\u0000\u00a4\u00ac\u0001\u0000\u0000\u0000\u00a5\u00a6"+ + "\u0005\u0001\u0000\u0000\u00a6\u00a7\u0005\r\u0000\u0000\u00a7\u00a8\u0005"+ + "\u000f\u0000\u0000\u00a8\u00a9\u0003 \u0010\u0000\u00a9\u00aa\u0005\u0002"+ + "\u0000\u0000\u00aa\u00ac\u0001\u0000\u0000\u0000\u00ab\u009e\u0001\u0000"+ + "\u0000\u0000\u00ab\u009f\u0001\u0000\u0000\u0000\u00ab\u00a0\u0001\u0000"+ + "\u0000\u0000\u00ab\u00a5\u0001\u0000\u0000\u0000\u00ac\u0007\u0001\u0000"+ + "\u0000\u0000\u00ad\u00ae\u0005\u00a9\u0000\u0000\u00ae\t\u0001\u0000\u0000"+ + "\u0000\u00af\u00b3\u0003\u0004\u0002\u0000\u00b0\u00b3\u0003\b\u0004\u0000"+ + "\u00b1\u00b3\u0003\u0006\u0003\u0000\u00b2\u00af\u0001\u0000\u0000\u0000"+ + "\u00b2\u00b0\u0001\u0000\u0000\u0000\u00b2\u00b1\u0001\u0000\u0000\u0000"+ + "\u00b3\u000b\u0001\u0000\u0000\u0000\u00b4\u00b8\u0005\u0085\u0000\u0000"+ + "\u00b5\u00b8\u0005\u0086\u0000\u0000\u00b6\u00b8\u0003\u0016\u000b\u0000"+ + "\u00b7\u00b4\u0001\u0000\u0000\u0000\u00b7\u00b5\u0001\u0000\u0000\u0000"+ + "\u00b7\u00b6\u0001\u0000\u0000\u0000\u00b8\r\u0001\u0000\u0000\u0000\u00b9"+ + "\u00c0\u0003\n\u0005\u0000\u00ba\u00bb\u0005\u0001\u0000\u0000\u00bb\u00bc"+ + "\u0005\f\u0000\u0000\u00bc\u00bd\u0003\n\u0005\u0000\u00bd\u00be\u0005"+ + "\u0002\u0000\u0000\u00be\u00c0\u0001\u0000\u0000\u0000\u00bf\u00b9\u0001"+ + "\u0000\u0000\u0000\u00bf\u00ba\u0001\u0000\u0000\u0000\u00c0\u000f\u0001"+ + "\u0000\u0000\u0000\u00c1\u00c2\u0005\u0001\u0000\u0000\u00c2\u00c3\u0005"+ + "\u0085\u0000\u0000\u00c3\u00c4\u0003\u0016\u000b\u0000\u00c4\u00c5\u0005"+ + "\u0002\u0000\u0000\u00c5\u00cc\u0001\u0000\u0000\u0000\u00c6\u00c7\u0005"+ + "\u0001\u0000\u0000\u00c7\u00c8\u0005\u000e\u0000\u0000\u00c8\u00c9\u0003"+ + " \u0010\u0000\u00c9\u00ca\u0005\u0002\u0000\u0000\u00ca\u00cc\u0001\u0000"+ + "\u0000\u0000\u00cb\u00c1\u0001\u0000\u0000\u0000\u00cb\u00c6\u0001\u0000"+ + "\u0000\u0000\u00cc\u0011\u0001\u0000\u0000\u0000\u00cd\u00ce\u0005\u0001"+ + "\u0000\u0000\u00ce\u00d8\u0005\u0088\u0000\u0000\u00cf\u00d1\u0003\n\u0005"+ + "\u0000\u00d0\u00cf\u0001\u0000\u0000\u0000\u00d1\u00d4\u0001\u0000\u0000"+ + "\u0000\u00d2\u00d0\u0001\u0000\u0000\u0000\u00d2\u00d3\u0001\u0000\u0000"+ + "\u0000\u00d3\u00d9\u0001\u0000\u0000\u0000\u00d4\u00d2\u0001\u0000\u0000"+ + "\u0000\u00d5\u00d6\u0003\"\u0011\u0000\u00d6\u00d7\u0003\n\u0005\u0000"+ + "\u00d7\u00d9\u0001\u0000\u0000\u0000\u00d8\u00d2\u0001\u0000\u0000\u0000"+ + "\u00d8\u00d5\u0001\u0000\u0000\u0000\u00d9\u00da\u0001\u0000\u0000\u0000"+ + "\u00da\u00dc\u0005\u0002\u0000\u0000\u00db\u00cd\u0001\u0000\u0000\u0000"+ + "\u00dc\u00df\u0001\u0000\u0000\u0000\u00dd\u00db\u0001\u0000\u0000\u0000"+ + "\u00dd\u00de\u0001\u0000\u0000\u0000\u00de\u0013\u0001\u0000\u0000\u0000"+ + "\u00df\u00dd\u0001\u0000\u0000\u0000\u00e0\u00e1\u0005\u0001\u0000\u0000"+ + "\u00e1\u00e5\u0005\u0089\u0000\u0000\u00e2\u00e4\u0003\n\u0005\u0000\u00e3"+ + "\u00e2\u0001\u0000\u0000\u0000\u00e4\u00e7\u0001\u0000\u0000\u0000\u00e5"+ + "\u00e3\u0001\u0000\u0000\u0000\u00e5\u00e6\u0001\u0000\u0000\u0000\u00e6"+ + "\u00e8\u0001\u0000\u0000\u0000\u00e7\u00e5\u0001\u0000\u0000\u0000\u00e8"+ + "\u00ea\u0005\u0002\u0000\u0000\u00e9\u00e0\u0001\u0000\u0000\u0000\u00ea"+ + "\u00ed\u0001\u0000\u0000\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000\u00eb"+ + "\u00ec\u0001\u0000\u0000\u0000\u00ec\u0015\u0001\u0000\u0000\u0000\u00ed"+ + "\u00eb\u0001\u0000\u0000\u0000\u00ee\u00ef\u0003\u0012\t\u0000\u00ef\u00f0"+ + "\u0003\u0014\n\u0000\u00f0\u0017\u0001\u0000\u0000\u0000\u00f1\u00f3\u0005"+ + "\u0003\u0000\u0000\u00f2\u00f4\u0005\u0003\u0000\u0000\u00f3\u00f2\u0001"+ + "\u0000\u0000\u0000\u00f3\u00f4\u0001\u0000\u0000\u0000\u00f4\u00f5\u0001"+ + "\u0000\u0000\u0000\u00f5\u00f6\u0003\u0006\u0003\u0000\u00f6\u0019\u0001"+ + "\u0000\u0000\u0000\u00f7\u00f9\u0005\u0003\u0000\u0000\u00f8\u00fa\u0005"+ + "\u0003\u0000\u0000\u00f9\u00f8\u0001\u0000\u0000\u0000\u00f9\u00fa\u0001"+ + "\u0000\u0000\u0000\u00fa\u001b\u0001\u0000\u0000\u0000\u00fb\u00fc\u0005"+ + "\u0001\u0000\u0000\u00fc\u00fd\u0005\u0084\u0000\u0000\u00fd\u00fe\u0003"+ + " \u0010\u0000\u00fe\u00ff\u0005\u0002\u0000\u0000\u00ff\u001d\u0001\u0000"+ + "\u0000\u0000\u0100\u0101\u0007\u0001\u0000\u0000\u0101\u001f\u0001\u0000"+ + "\u0000\u0000\u0102\u0103\u0007\u0002\u0000\u0000\u0103!\u0001\u0000\u0000"+ + "\u0000\u0104\u0105\u0005\u00a8\u0000\u0000\u0105#\u0001\u0000\u0000\u0000"+ + "\u0106\u010c\u0003(\u0014\u0000\u0107\u010c\u0003@ \u0000\u0108\u010c"+ + "\u0003F#\u0000\u0109\u010c\u0003*\u0015\u0000\u010a\u010c\u0003&\u0013"+ + "\u0000\u010b\u0106\u0001\u0000\u0000\u0000\u010b\u0107\u0001\u0000\u0000"+ + "\u0000\u010b\u0108\u0001\u0000\u0000\u0000\u010b\u0109\u0001\u0000\u0000"+ + "\u0000\u010b\u010a\u0001\u0000\u0000\u0000\u010c%\u0001\u0000\u0000\u0000"+ + "\u010d\u010e\u0005\u0018\u0000\u0000\u010e\u010f\u0005\u0001\u0000\u0000"+ + "\u010f\u0110\u0003P(\u0000\u0110\u0111\u0005\u0019\u0000\u0000\u0111\u0112"+ + "\u0003P(\u0000\u0112\u0113\u0005\u0019\u0000\u0000\u0113\u0114\u0003P"+ + "(\u0000\u0114\u0115\u0005\u0002\u0000\u0000\u0115\u0116\u0003P(\u0000"+ "\u0116\'\u0001\u0000\u0000\u0000\u0117\u0166\u0005\u0014\u0000\u0000\u0118"+ "\u0166\u0005\u0010\u0000\u0000\u0119\u0166\u0005\u0015\u0000\u0000\u011a"+ "\u0166\u00036\u001b\u0000\u011b\u011c\u0005\u001b\u0000\u0000\u011c\u0166"+ @@ -7700,297 +7596,277 @@ public final ModuleContext module() throws RecognitionException { "\u0000\u0000\u02a3\u02a6\u0001\u0000\u0000\u0000\u02a4\u02a6\u0003H$\u0000"+ "\u02a5\u029f\u0001\u0000\u0000\u0000\u02a5\u02a4\u0001\u0000\u0000\u0000"+ "\u02a6]\u0001\u0000\u0000\u0000\u02a7\u02a8\u0005\u0001\u0000\u0000\u02a8"+ - "\u02aa\u0005\u008e\u0000\u0000\u02a9\u02ab\u0003 \u0010\u0000\u02aa\u02a9"+ - "\u0001\u0000\u0000\u0000\u02aa\u02ab\u0001\u0000\u0000\u0000\u02ab\u02ac"+ - "\u0001\u0000\u0000\u0000\u02ac\u02ad\u0005\u0001\u0000\u0000\u02ad\u02ae"+ - "\u0003$\u0012\u0000\u02ae\u02b2\u0005\u0002\u0000\u0000\u02af\u02b1\u0003"+ - " \u0010\u0000\u02b0\u02af\u0001\u0000\u0000\u0000\u02b1\u02b4\u0001\u0000"+ - "\u0000\u0000\u02b2\u02b0\u0001\u0000\u0000\u0000\u02b2\u02b3\u0001\u0000"+ - "\u0000\u0000\u02b3\u02b5\u0001\u0000\u0000\u0000\u02b4\u02b2\u0001\u0000"+ - "\u0000\u0000\u02b5\u02b6\u0005\u0002\u0000\u0000\u02b6\u02d4\u0001\u0000"+ - "\u0000\u0000\u02b7\u02b8\u0005\u0001\u0000\u0000\u02b8\u02ba\u0005\u008e"+ - "\u0000\u0000\u02b9\u02bb\u0003 \u0010\u0000\u02ba\u02b9\u0001\u0000\u0000"+ - "\u0000\u02ba\u02bb\u0001\u0000\u0000\u0000\u02bb\u02bc\u0001\u0000\u0000"+ - "\u0000\u02bc\u02c0\u0003\\.\u0000\u02bd\u02bf\u0003 \u0010\u0000\u02be"+ - "\u02bd\u0001\u0000\u0000\u0000\u02bf\u02c2\u0001\u0000\u0000\u0000\u02c0"+ - "\u02be\u0001\u0000\u0000\u0000\u02c0\u02c1\u0001\u0000\u0000\u0000\u02c1"+ - "\u02c3\u0001\u0000\u0000\u0000\u02c2\u02c0\u0001\u0000\u0000\u0000\u02c3"+ - "\u02c4\u0005\u0002\u0000\u0000\u02c4\u02d4\u0001\u0000\u0000\u0000\u02c5"+ - "\u02c6\u0005\u0001\u0000\u0000\u02c6\u02c8\u0005\u008e\u0000\u0000\u02c7"+ - "\u02c9\u0003 \u0010\u0000\u02c8\u02c7\u0001\u0000\u0000\u0000\u02c8\u02c9"+ - "\u0001\u0000\u0000\u0000\u02c9\u02ca\u0001\u0000\u0000\u0000\u02ca\u02cb"+ - "\u0005\u0094\u0000\u0000\u02cb\u02cf\u0005\u0085\u0000\u0000\u02cc\u02ce"+ - "\u0003 \u0010\u0000\u02cd\u02cc\u0001\u0000\u0000\u0000\u02ce\u02d1\u0001"+ - "\u0000\u0000\u0000\u02cf\u02cd\u0001\u0000\u0000\u0000\u02cf\u02d0\u0001"+ - "\u0000\u0000\u0000\u02d0\u02d2\u0001\u0000\u0000\u0000\u02d1\u02cf\u0001"+ - "\u0000\u0000\u0000\u02d2\u02d4\u0005\u0002\u0000\u0000\u02d3\u02a7\u0001"+ - "\u0000\u0000\u0000\u02d3\u02b7\u0001\u0000\u0000\u0000\u02d3\u02c5\u0001"+ - "\u0000\u0000\u0000\u02d4_\u0001\u0000\u0000\u0000\u02d5\u02d6\u0005\u0001"+ - "\u0000\u0000\u02d6\u02d8\u0005\u008c\u0000\u0000\u02d7\u02d9\u0003\"\u0011"+ - "\u0000\u02d8\u02d7\u0001\u0000\u0000\u0000\u02d8\u02d9\u0001\u0000\u0000"+ - "\u0000\u02d9\u02da\u0001\u0000\u0000\u0000\u02da\u02db\u0003b1\u0000\u02db"+ - "\u02dc\u0005\u0002\u0000\u0000\u02dca\u0001\u0000\u0000\u0000\u02dd\u02f0"+ - "\u0003\u0018\f\u0000\u02de\u02df\u0003r9\u0000\u02df\u02e0\u0003\u0018"+ - "\f\u0000\u02e0\u02f0\u0001\u0000\u0000\u0000\u02e1\u02e2\u0003x<\u0000"+ - "\u02e2\u02e3\u0003b1\u0000\u02e3\u02f0\u0001\u0000\u0000\u0000\u02e4\u02e5"+ - "\u0003\u0006\u0003\u0000\u02e5\u02e6\u0005\u0001\u0000\u0000\u02e6\u02ea"+ - "\u0005\u008e\u0000\u0000\u02e7\u02e9\u0003 \u0010\u0000\u02e8\u02e7\u0001"+ - "\u0000\u0000\u0000\u02e9\u02ec\u0001\u0000\u0000\u0000\u02ea\u02e8\u0001"+ - "\u0000\u0000\u0000\u02ea\u02eb\u0001\u0000\u0000\u0000\u02eb\u02ed\u0001"+ - "\u0000\u0000\u0000\u02ec\u02ea\u0001\u0000\u0000\u0000\u02ed\u02ee\u0005"+ - "\u0002\u0000\u0000\u02ee\u02f0\u0001\u0000\u0000\u0000\u02ef\u02dd\u0001"+ - "\u0000\u0000\u0000\u02ef\u02de\u0001\u0000\u0000\u0000\u02ef\u02e1\u0001"+ - "\u0000\u0000\u0000\u02ef\u02e4\u0001\u0000\u0000\u0000\u02f0c\u0001\u0000"+ - "\u0000\u0000\u02f1\u02f2\u0005\u0001\u0000\u0000\u02f2\u02f4\u0005\u008f"+ - "\u0000\u0000\u02f3\u02f5\u0003 \u0010\u0000\u02f4\u02f3\u0001\u0000\u0000"+ - "\u0000\u02f4\u02f5\u0001\u0000\u0000\u0000\u02f5\u02f6\u0001\u0000\u0000"+ - "\u0000\u02f6\u02f7\u0005\u0001\u0000\u0000\u02f7\u02f8\u0003$\u0012\u0000"+ - "\u02f8\u02fc\u0005\u0002\u0000\u0000\u02f9\u02fb\u0005\u0006\u0000\u0000"+ - "\u02fa\u02f9\u0001\u0000\u0000\u0000\u02fb\u02fe\u0001\u0000\u0000\u0000"+ - "\u02fc\u02fa\u0001\u0000\u0000\u0000\u02fc\u02fd\u0001\u0000\u0000\u0000"+ - "\u02fd\u02ff\u0001\u0000\u0000\u0000\u02fe\u02fc\u0001\u0000\u0000\u0000"+ - "\u02ff\u0300\u0005\u0002\u0000\u0000\u0300\u0310\u0001\u0000\u0000\u0000"+ - "\u0301\u0302\u0005\u0001\u0000\u0000\u0302\u0304\u0005\u008f\u0000\u0000"+ - "\u0303\u0305\u0003 \u0010\u0000\u0304\u0303\u0001\u0000\u0000\u0000\u0304"+ - "\u0305\u0001\u0000\u0000\u0000\u0305\u0306\u0001\u0000\u0000\u0000\u0306"+ - "\u030a\u0003\\.\u0000\u0307\u0309\u0005\u0006\u0000\u0000\u0308\u0307"+ - "\u0001\u0000\u0000\u0000\u0309\u030c\u0001\u0000\u0000\u0000\u030a\u0308"+ - "\u0001\u0000\u0000\u0000\u030a\u030b\u0001\u0000\u0000\u0000\u030b\u030d"+ - "\u0001\u0000\u0000\u0000\u030c\u030a\u0001\u0000\u0000\u0000\u030d\u030e"+ - "\u0005\u0002\u0000\u0000\u030e\u0310\u0001\u0000\u0000\u0000\u030f\u02f1"+ - "\u0001\u0000\u0000\u0000\u030f\u0301\u0001\u0000\u0000\u0000\u0310e\u0001"+ - "\u0000\u0000\u0000\u0311\u0312\u0005\u0001\u0000\u0000\u0312\u0314\u0005"+ - "\u008d\u0000\u0000\u0313\u0315\u0003\"\u0011\u0000\u0314\u0313\u0001\u0000"+ - "\u0000\u0000\u0314\u0315\u0001\u0000\u0000\u0000\u0315\u0316\u0001\u0000"+ - "\u0000\u0000\u0316\u0317\u0003h4\u0000\u0317\u0318\u0005\u0002\u0000\u0000"+ - "\u0318g\u0001\u0000\u0000\u0000\u0319\u032a\u0003\u001a\r\u0000\u031a"+ - "\u031b\u0003r9\u0000\u031b\u031c\u0003\u001a\r\u0000\u031c\u032a\u0001"+ - "\u0000\u0000\u0000\u031d\u031e\u0003x<\u0000\u031e\u031f\u0003h4\u0000"+ - "\u031f\u032a\u0001\u0000\u0000\u0000\u0320\u0321\u0005\u0001\u0000\u0000"+ - "\u0321\u0325\u0005\u008f\u0000\u0000\u0322\u0324\u0005\u0006\u0000\u0000"+ - "\u0323\u0322\u0001\u0000\u0000\u0000\u0324\u0327\u0001\u0000\u0000\u0000"+ - "\u0325\u0323\u0001\u0000\u0000\u0000\u0325\u0326\u0001\u0000\u0000\u0000"+ - "\u0326\u0328\u0001\u0000\u0000\u0000\u0327\u0325\u0001\u0000\u0000\u0000"+ - "\u0328\u032a\u0005\u0002\u0000\u0000\u0329\u0319\u0001\u0000\u0000\u0000"+ - "\u0329\u031a\u0001\u0000\u0000\u0000\u0329\u031d\u0001\u0000\u0000\u0000"+ - "\u0329\u0320\u0001\u0000\u0000\u0000\u032ai\u0001\u0000\u0000\u0000\u032b"+ - "\u032c\u0005\u0001\u0000\u0000\u032c\u032e\u0005\u008b\u0000\u0000\u032d"+ - "\u032f\u0003\"\u0011\u0000\u032e\u032d\u0001\u0000\u0000\u0000\u032e\u032f"+ - "\u0001\u0000\u0000\u0000\u032f\u0330\u0001\u0000\u0000\u0000\u0330\u0331"+ - "\u0003l6\u0000\u0331\u0332\u0005\u0002\u0000\u0000\u0332k\u0001\u0000"+ - "\u0000\u0000\u0333\u0334\u0003\u000e\u0007\u0000\u0334\u0335\u0003R)\u0000"+ - "\u0335\u033d\u0001\u0000\u0000\u0000\u0336\u0337\u0003r9\u0000\u0337\u0338"+ - "\u0003\u000e\u0007\u0000\u0338\u033d\u0001\u0000\u0000\u0000\u0339\u033a"+ - "\u0003x<\u0000\u033a\u033b\u0003l6\u0000\u033b\u033d\u0001\u0000\u0000"+ - "\u0000\u033c\u0333\u0001\u0000\u0000\u0000\u033c\u0336\u0001\u0000\u0000"+ - "\u0000\u033c\u0339\u0001\u0000\u0000\u0000\u033dm\u0001\u0000\u0000\u0000"+ - "\u033e\u033f\u0005\u0001\u0000\u0000\u033f\u0341\u0005\u0085\u0000\u0000"+ - "\u0340\u0342\u0003\"\u0011\u0000\u0341\u0340\u0001\u0000\u0000\u0000\u0341"+ - "\u0342\u0001\u0000\u0000\u0000\u0342\u0343\u0001\u0000\u0000\u0000\u0343"+ - "\u0344\u0003\u001c\u000e\u0000\u0344\u0345\u0005\u0002\u0000\u0000\u0345"+ - "\u0367\u0001\u0000\u0000\u0000\u0346\u0347\u0005\u0001\u0000\u0000\u0347"+ - "\u0349\u0005\u0085\u0000\u0000\u0348\u034a\u0003\"\u0011\u0000\u0349\u0348"+ - "\u0001\u0000\u0000\u0000\u0349\u034a\u0001\u0000\u0000\u0000\u034a\u034b"+ - "\u0001\u0000\u0000\u0000\u034b\u034c\u0003\u0016\u000b\u0000\u034c\u034d"+ - "\u0005\u0002\u0000\u0000\u034d\u0367\u0001\u0000\u0000\u0000\u034e\u034f"+ - "\u0005\u0001\u0000\u0000\u034f\u0351\u0005\u008c\u0000\u0000\u0350\u0352"+ - "\u0003\"\u0011\u0000\u0351\u0350\u0001\u0000\u0000\u0000\u0351\u0352\u0001"+ - "\u0000\u0000\u0000\u0352\u0353\u0001\u0000\u0000\u0000\u0353\u0354\u0003"+ - "\u0018\f\u0000\u0354\u0355\u0005\u0002\u0000\u0000\u0355\u0367\u0001\u0000"+ - "\u0000\u0000\u0356\u0357\u0005\u0001\u0000\u0000\u0357\u0359\u0005\u008d"+ - "\u0000\u0000\u0358\u035a\u0003\"\u0011\u0000\u0359\u0358\u0001\u0000\u0000"+ - "\u0000\u0359\u035a\u0001\u0000\u0000\u0000\u035a\u035b\u0001\u0000\u0000"+ - "\u0000\u035b\u035c\u0003\u001a\r\u0000\u035c\u035d\u0005\u0002\u0000\u0000"+ - "\u035d\u0367\u0001\u0000\u0000\u0000\u035e\u035f\u0005\u0001\u0000\u0000"+ - "\u035f\u0361\u0005\u008b\u0000\u0000\u0360\u0362\u0003\"\u0011\u0000\u0361"+ - "\u0360\u0001\u0000\u0000\u0000\u0361\u0362\u0001\u0000\u0000\u0000\u0362"+ - "\u0363\u0001\u0000\u0000\u0000\u0363\u0364\u0003\u000e\u0007\u0000\u0364"+ - "\u0365\u0005\u0002\u0000\u0000\u0365\u0367\u0001\u0000\u0000\u0000\u0366"+ - "\u033e\u0001\u0000\u0000\u0000\u0366\u0346\u0001\u0000\u0000\u0000\u0366"+ - "\u034e\u0001\u0000\u0000\u0000\u0366\u0356\u0001\u0000\u0000\u0000\u0366"+ - "\u035e\u0001\u0000\u0000\u0000\u0367o\u0001\u0000\u0000\u0000\u0368\u0369"+ - "\u0005\u0001\u0000\u0000\u0369\u036a\u0005\u0091\u0000\u0000\u036a\u036b"+ - "\u0003\u0002\u0001\u0000\u036b\u036c\u0003\u0002\u0001\u0000\u036c\u036d"+ - "\u0003n7\u0000\u036d\u036e\u0005\u0002\u0000\u0000\u036eq\u0001\u0000"+ - "\u0000\u0000\u036f\u0370\u0005\u0001\u0000\u0000\u0370\u0371\u0005\u0091"+ - "\u0000\u0000\u0371\u0372\u0003\u0002\u0001\u0000\u0372\u0373\u0003\u0002"+ - "\u0001\u0000\u0373\u0374\u0005\u0002\u0000\u0000\u0374s\u0001\u0000\u0000"+ - "\u0000\u0375\u0376\u0005\u0001\u0000\u0000\u0376\u0377\u0005\u0085\u0000"+ - "\u0000\u0377\u0378\u0003 \u0010\u0000\u0378\u0379\u0005\u0002\u0000\u0000"+ - "\u0379\u038a\u0001\u0000\u0000\u0000\u037a\u037b\u0005\u0001\u0000\u0000"+ - "\u037b\u037c\u0005\u008c\u0000\u0000\u037c\u037d\u0003 \u0010\u0000\u037d"+ - "\u037e\u0005\u0002\u0000\u0000\u037e\u038a\u0001\u0000\u0000\u0000\u037f"+ - "\u0380\u0005\u0001\u0000\u0000\u0380\u0381\u0005\u008d\u0000\u0000\u0381"+ - "\u0382\u0003 \u0010\u0000\u0382\u0383\u0005\u0002\u0000\u0000\u0383\u038a"+ - "\u0001\u0000\u0000\u0000\u0384\u0385\u0005\u0001\u0000\u0000\u0385\u0386"+ - "\u0005\u008b\u0000\u0000\u0386\u0387\u0003 \u0010\u0000\u0387\u0388\u0005"+ - "\u0002\u0000\u0000\u0388\u038a\u0001\u0000\u0000\u0000\u0389\u0375\u0001"+ - "\u0000\u0000\u0000\u0389\u037a\u0001\u0000\u0000\u0000\u0389\u037f\u0001"+ - "\u0000\u0000\u0000\u0389\u0384\u0001\u0000\u0000\u0000\u038au\u0001\u0000"+ - "\u0000\u0000\u038b\u038c\u0005\u0001\u0000\u0000\u038c\u038d\u0005\u0092"+ - "\u0000\u0000\u038d\u038e\u0003\u0002\u0001\u0000\u038e\u038f\u0003t:\u0000"+ - "\u038f\u0390\u0005\u0002\u0000\u0000\u0390w\u0001\u0000\u0000\u0000\u0391"+ - "\u0392\u0005\u0001\u0000\u0000\u0392\u0393\u0005\u0092\u0000\u0000\u0393"+ - "\u0394\u0003\u0002\u0001\u0000\u0394\u0395\u0005\u0002\u0000\u0000\u0395"+ - "y\u0001\u0000\u0000\u0000\u0396\u0397\u0005\u0001\u0000\u0000\u0397\u0399"+ - "\u0005\u0093\u0000\u0000\u0398\u039a\u0003\"\u0011\u0000\u0399\u0398\u0001"+ - "\u0000\u0000\u0000\u0399\u039a\u0001\u0000\u0000\u0000\u039a\u039b\u0001"+ - "\u0000\u0000\u0000\u039b\u039c\u0003\u001c\u000e\u0000\u039c\u039d\u0003"+ - "\u0016\u000b\u0000\u039d\u039e\u0005\u0002\u0000\u0000\u039e{\u0001\u0000"+ - "\u0000\u0000\u039f\u03a0\u0005\u0001\u0000\u0000\u03a0\u03a2\u0005\u0084"+ - "\u0000\u0000\u03a1\u03a3\u0003\"\u0011\u0000\u03a2\u03a1\u0001\u0000\u0000"+ - "\u0000\u03a2\u03a3\u0001\u0000\u0000\u0000\u03a3\u03a4\u0001\u0000\u0000"+ - "\u0000\u03a4\u03a5\u0003\u0010\b\u0000\u03a5\u03a6\u0005\u0002\u0000\u0000"+ - "\u03a6}\u0001\u0000\u0000\u0000\u03a7\u03a8\u0005\u0001\u0000\u0000\u03a8"+ - "\u03a9\u0005\u0087\u0000\u0000\u03a9\u03aa\u0003 \u0010\u0000\u03aa\u03ab"+ - "\u0005\u0002\u0000\u0000\u03ab\u007f\u0001\u0000\u0000\u0000\u03ac\u03b8"+ - "\u0003|>\u0000\u03ad\u03b8\u0003j5\u0000\u03ae\u03b8\u0003`0\u0000\u03af"+ - "\u03b8\u0003f3\u0000\u03b0\u03b8\u0003T*\u0000\u03b1\u03b8\u0003^/\u0000"+ - "\u03b2\u03b8\u0003d2\u0000\u03b3\u03b8\u0003~?\u0000\u03b4\u03b8\u0003"+ - "p8\u0000\u03b5\u03b8\u0003v;\u0000\u03b6\u03b8\u0003z=\u0000\u03b7\u03ac"+ - "\u0001\u0000\u0000\u0000\u03b7\u03ad\u0001\u0000\u0000\u0000\u03b7\u03ae"+ - "\u0001\u0000\u0000\u0000\u03b7\u03af\u0001\u0000\u0000\u0000\u03b7\u03b0"+ - "\u0001\u0000\u0000\u0000\u03b7\u03b1\u0001\u0000\u0000\u0000\u03b7\u03b2"+ - "\u0001\u0000\u0000\u0000\u03b7\u03b3\u0001\u0000\u0000\u0000\u03b7\u03b4"+ - "\u0001\u0000\u0000\u0000\u03b7\u03b5\u0001\u0000\u0000\u0000\u03b7\u03b6"+ - "\u0001\u0000\u0000\u0000\u03b8\u0081\u0001\u0000\u0000\u0000\u03b9\u03ba"+ - "\u0005\u0001\u0000\u0000\u03ba\u03bc\u0005\u0095\u0000\u0000\u03bb\u03bd"+ - "\u0005\u00a8\u0000\u0000\u03bc\u03bb\u0001\u0000\u0000\u0000\u03bc\u03bd"+ - "\u0001\u0000\u0000\u0000\u03bd\u03c1\u0001\u0000\u0000\u0000\u03be\u03c0"+ - "\u0003\u0080@\u0000\u03bf\u03be\u0001\u0000\u0000\u0000\u03c0\u03c3\u0001"+ - "\u0000\u0000\u0000\u03c1\u03bf\u0001\u0000\u0000\u0000\u03c1\u03c2\u0001"+ - "\u0000\u0000\u0000\u03c2\u03c4\u0001\u0000\u0000\u0000\u03c3\u03c1\u0001"+ - "\u0000\u0000\u0000\u03c4\u03c5\u0005\u0002\u0000\u0000\u03c5\u0083\u0001"+ - "\u0000\u0000\u0000\u03c6\u03e3\u0003\u0082A\u0000\u03c7\u03c8\u0005\u0001"+ - "\u0000\u0000\u03c8\u03ca\u0005\u0095\u0000\u0000\u03c9\u03cb\u0005\u00a8"+ - "\u0000\u0000\u03ca\u03c9\u0001\u0000\u0000\u0000\u03ca\u03cb\u0001\u0000"+ - "\u0000\u0000\u03cb\u03cc\u0001\u0000\u0000\u0000\u03cc\u03d0\u0007\u0003"+ - "\u0000\u0000\u03cd\u03cf\u0005\u0006\u0000\u0000\u03ce\u03cd\u0001\u0000"+ - "\u0000\u0000\u03cf\u03d2\u0001\u0000\u0000\u0000\u03d0\u03ce\u0001\u0000"+ - "\u0000\u0000\u03d0\u03d1\u0001\u0000\u0000\u0000\u03d1\u03d3\u0001\u0000"+ - "\u0000\u0000\u03d2\u03d0\u0001\u0000\u0000\u0000\u03d3\u03e3\u0005\u0002"+ - "\u0000\u0000\u03d4\u03d5\u0005\u0001\u0000\u0000\u03d5\u03d6\u0005\u0095"+ - "\u0000\u0000\u03d6\u03d8\u0005\u0098\u0000\u0000\u03d7\u03d9\u0005\u00a8"+ - "\u0000\u0000\u03d8\u03d7\u0001\u0000\u0000\u0000\u03d8\u03d9\u0001\u0000"+ - "\u0000\u0000\u03d9\u03da\u0001\u0000\u0000\u0000\u03da\u03de\u0005\u0096"+ - "\u0000\u0000\u03db\u03dd\u0005\u0006\u0000\u0000\u03dc\u03db\u0001\u0000"+ - "\u0000\u0000\u03dd\u03e0\u0001\u0000\u0000\u0000\u03de\u03dc\u0001\u0000"+ - "\u0000\u0000\u03de\u03df\u0001\u0000\u0000\u0000\u03df\u03e1\u0001\u0000"+ - "\u0000\u0000\u03e0\u03de\u0001\u0000\u0000\u0000\u03e1\u03e3\u0005\u0002"+ - "\u0000\u0000\u03e2\u03c6\u0001\u0000\u0000\u0000\u03e2\u03c7\u0001\u0000"+ - "\u0000\u0000\u03e2\u03d4\u0001\u0000\u0000\u0000\u03e3\u0085\u0001\u0000"+ - "\u0000\u0000\u03e4\u03e5\u0005\u0001\u0000\u0000\u03e5\u03e7\u0005\u009c"+ - "\u0000\u0000\u03e6\u03e8\u0005\u00a8\u0000\u0000\u03e7\u03e6\u0001\u0000"+ - "\u0000\u0000\u03e7\u03e8\u0001\u0000\u0000\u0000\u03e8\u03e9\u0001\u0000"+ - "\u0000\u0000\u03e9\u03ea\u0003\u0002\u0001\u0000\u03ea\u03eb\u0003\u0092"+ - "I\u0000\u03eb\u03ec\u0005\u0002\u0000\u0000\u03ec\u03f6\u0001\u0000\u0000"+ - "\u0000\u03ed\u03ee\u0005\u0001\u0000\u0000\u03ee\u03f0\u0005\u009d\u0000"+ - "\u0000\u03ef\u03f1\u0005\u00a8\u0000\u0000\u03f0\u03ef\u0001\u0000\u0000"+ - "\u0000\u03f0\u03f1\u0001\u0000\u0000\u0000\u03f1\u03f2\u0001\u0000\u0000"+ - "\u0000\u03f2\u03f3\u0003\u0002\u0001\u0000\u03f3\u03f4\u0005\u0002\u0000"+ - "\u0000\u03f4\u03f6\u0001\u0000\u0000\u0000\u03f5\u03e4\u0001\u0000\u0000"+ - "\u0000\u03f5\u03ed\u0001\u0000\u0000\u0000\u03f6\u0087\u0001\u0000\u0000"+ - "\u0000\u03f7\u03f8\u0005\u0001\u0000\u0000\u03f8\u03f9\u0005\u009e\u0000"+ - "\u0000\u03f9\u03fa\u0003\u0084B\u0000\u03fa\u03fb\u0005\u0006\u0000\u0000"+ - "\u03fb\u03fc\u0005\u0002\u0000\u0000\u03fc\u042c\u0001\u0000\u0000\u0000"+ - "\u03fd\u03fe\u0005\u0001\u0000\u0000\u03fe\u03ff\u0005\u009f\u0000\u0000"+ - "\u03ff\u0400\u0003\u0084B\u0000\u0400\u0401\u0005\u0006\u0000\u0000\u0401"+ - "\u0402\u0005\u0002\u0000\u0000\u0402\u042c\u0001\u0000\u0000\u0000\u0403"+ - "\u0404\u0005\u0001\u0000\u0000\u0404\u0405\u0005\u00a0\u0000\u0000\u0405"+ - "\u0406\u0003\u0084B\u0000\u0406\u0407\u0005\u0006\u0000\u0000\u0407\u0408"+ - "\u0005\u0002\u0000\u0000\u0408\u042c\u0001\u0000\u0000\u0000\u0409\u040a"+ - "\u0005\u0001\u0000\u0000\u040a\u040b\u0005\u00a4\u0000\u0000\u040b\u040c"+ - "\u0003\u0084B\u0000\u040c\u040d\u0005\u0006\u0000\u0000\u040d\u040e\u0005"+ - "\u0002\u0000\u0000\u040e\u042c\u0001\u0000\u0000\u0000\u040f\u0410\u0005"+ - "\u0001\u0000\u0000\u0410\u0411\u0005\u00a1\u0000\u0000\u0411\u0412\u0003"+ - "\u0086C\u0000\u0412\u0413\u0003\u0092I\u0000\u0413\u0414\u0005\u0002\u0000"+ - "\u0000\u0414\u042c\u0001\u0000\u0000\u0000\u0415\u0416\u0005\u0001\u0000"+ - "\u0000\u0416\u0417\u0005\u00a2\u0000\u0000\u0417\u0418\u0003\u0086C\u0000"+ - "\u0418\u0419\u0005\u0002\u0000\u0000\u0419\u042c\u0001\u0000\u0000\u0000"+ - "\u041a\u041b\u0005\u0001\u0000\u0000\u041b\u041c\u0005\u00a3\u0000\u0000"+ - "\u041c\u041d\u0003\u0086C\u0000\u041d\u041e\u0005\u0002\u0000\u0000\u041e"+ - "\u042c\u0001\u0000\u0000\u0000\u041f\u0420\u0005\u0001\u0000\u0000\u0420"+ - "\u0421\u0005\u00a4\u0000\u0000\u0421\u0422\u0003\u0086C\u0000\u0422\u0423"+ - "\u0005\u0006\u0000\u0000\u0423\u0424\u0005\u0002\u0000\u0000\u0424\u042c"+ - "\u0001\u0000\u0000\u0000\u0425\u0426\u0005\u0001\u0000\u0000\u0426\u0427"+ - "\u0005\u00a5\u0000\u0000\u0427\u0428\u0003\u0086C\u0000\u0428\u0429\u0005"+ - "\u0006\u0000\u0000\u0429\u042a\u0005\u0002\u0000\u0000\u042a\u042c\u0001"+ - "\u0000\u0000\u0000\u042b\u03f7\u0001\u0000\u0000\u0000\u042b\u03fd\u0001"+ - "\u0000\u0000\u0000\u042b\u0403\u0001\u0000\u0000\u0000\u042b\u0409\u0001"+ - "\u0000\u0000\u0000\u042b\u040f\u0001\u0000\u0000\u0000\u042b\u0415\u0001"+ - "\u0000\u0000\u0000\u042b\u041a\u0001\u0000\u0000\u0000\u042b\u041f\u0001"+ - "\u0000\u0000\u0000\u042b\u0425\u0001\u0000\u0000\u0000\u042c\u0089\u0001"+ - "\u0000\u0000\u0000\u042d\u043b\u0003\u0086C\u0000\u042e\u043b\u0003\u0088"+ - "D\u0000\u042f\u043b\u0003\u0084B\u0000\u0430\u0431\u0005\u0001\u0000\u0000"+ - "\u0431\u0432\u0005\u009b\u0000\u0000\u0432\u0434\u0003\u0002\u0001\u0000"+ - "\u0433\u0435\u0005\u00a8\u0000\u0000\u0434\u0433\u0001\u0000\u0000\u0000"+ - "\u0434\u0435\u0001\u0000\u0000\u0000\u0435\u0436\u0001\u0000\u0000\u0000"+ - "\u0436\u0437\u0005\u0002\u0000\u0000\u0437\u043b\u0001\u0000\u0000\u0000"+ - "\u0438\u043b\u0003\u008eG\u0000\u0439\u043b\u0003\u008cF\u0000\u043a\u042d"+ - "\u0001\u0000\u0000\u0000\u043a\u042e\u0001\u0000\u0000\u0000\u043a\u042f"+ - "\u0001\u0000\u0000\u0000\u043a\u0430\u0001\u0000\u0000\u0000\u043a\u0438"+ - "\u0001\u0000\u0000\u0000\u043a\u0439\u0001\u0000\u0000\u0000\u043b\u008b"+ - "\u0001\u0000\u0000\u0000\u043c\u043d\u0005\u0001\u0000\u0000\u043d\u043e"+ - "\u0005\u0095\u0000\u0000\u043e\u0440\u0005\u0099\u0000\u0000\u043f\u0441"+ - "\u0005\u00a8\u0000\u0000\u0440\u043f\u0001\u0000\u0000\u0000\u0440\u0441"+ - "\u0001\u0000\u0000\u0000\u0441\u0443\u0001\u0000\u0000\u0000\u0442\u0444"+ - "\u0005\u00a8\u0000\u0000\u0443\u0442\u0001\u0000\u0000\u0000\u0443\u0444"+ - "\u0001\u0000\u0000\u0000\u0444\u0445\u0001\u0000\u0000\u0000\u0445\u0446"+ - "\u0005\u0002\u0000\u0000\u0446\u008d\u0001\u0000\u0000\u0000\u0447\u0448"+ - "\u0005\u0001\u0000\u0000\u0448\u044a\u0005\u009a\u0000\u0000\u0449\u044b"+ - "\u0005\u00a8\u0000\u0000\u044a\u0449\u0001\u0000\u0000\u0000\u044a\u044b"+ - "\u0001\u0000\u0000\u0000\u044b\u044f\u0001\u0000\u0000\u0000\u044c\u044e"+ - "\u0003\u008aE\u0000\u044d\u044c\u0001\u0000\u0000\u0000\u044e\u0451\u0001"+ - "\u0000\u0000\u0000\u044f\u044d\u0001\u0000\u0000\u0000\u044f\u0450\u0001"+ - "\u0000\u0000\u0000\u0450\u0452\u0001\u0000\u0000\u0000\u0451\u044f\u0001"+ - "\u0000\u0000\u0000\u0452\u0468\u0005\u0002\u0000\u0000\u0453\u0454\u0005"+ - "\u0001\u0000\u0000\u0454\u0456\u0005\u00a6\u0000\u0000\u0455\u0457\u0005"+ - "\u00a8\u0000\u0000\u0456\u0455\u0001\u0000\u0000\u0000\u0456\u0457\u0001"+ - "\u0000\u0000\u0000\u0457\u0458\u0001\u0000\u0000\u0000\u0458\u0459\u0005"+ - "\u0006\u0000\u0000\u0459\u0468\u0005\u0002\u0000\u0000\u045a\u045b\u0005"+ - "\u0001\u0000\u0000\u045b\u045d\u0005\u00a7\u0000\u0000\u045c\u045e\u0005"+ - "\u00a8\u0000\u0000\u045d\u045c\u0001\u0000\u0000\u0000\u045d\u045e\u0001"+ - "\u0000\u0000\u0000\u045e\u045f\u0001\u0000\u0000\u0000\u045f\u0460\u0005"+ - "\u0006\u0000\u0000\u0460\u0468\u0005\u0002\u0000\u0000\u0461\u0462\u0005"+ - "\u0001\u0000\u0000\u0462\u0464\u0005\u00a7\u0000\u0000\u0463\u0465\u0005"+ - "\u00a8\u0000\u0000\u0464\u0463\u0001\u0000\u0000\u0000\u0464\u0465\u0001"+ - "\u0000\u0000\u0000\u0465\u0466\u0001\u0000\u0000\u0000\u0466\u0468\u0005"+ - "\u0002\u0000\u0000\u0467\u0447\u0001\u0000\u0000\u0000\u0467\u0453\u0001"+ - "\u0000\u0000\u0000\u0467\u045a\u0001\u0000\u0000\u0000\u0467\u0461\u0001"+ - "\u0000\u0000\u0000\u0468\u008f\u0001\u0000\u0000\u0000\u0469\u046a\u0005"+ - "\u0001\u0000\u0000\u046a\u046b\u0005\b\u0000\u0000\u046b\u046c\u0003\u001e"+ - "\u000f\u0000\u046c\u046d\u0005\u0002\u0000\u0000\u046d\u0091\u0001\u0000"+ - "\u0000\u0000\u046e\u0470\u0003\u0090H\u0000\u046f\u046e\u0001\u0000\u0000"+ - "\u0000\u0470\u0473\u0001\u0000\u0000\u0000\u0471\u046f\u0001\u0000\u0000"+ - "\u0000\u0471\u0472\u0001\u0000\u0000\u0000\u0472\u0093\u0001\u0000\u0000"+ - "\u0000\u0473\u0471\u0001\u0000\u0000\u0000\u0474\u0476\u0003\u008aE\u0000"+ - "\u0475\u0474\u0001\u0000\u0000\u0000\u0476\u0479\u0001\u0000\u0000\u0000"+ - "\u0477\u0475\u0001\u0000\u0000\u0000\u0477\u0478\u0001\u0000\u0000\u0000"+ - "\u0478\u047a\u0001\u0000\u0000\u0000\u0479\u0477\u0001\u0000\u0000\u0000"+ - "\u047a\u0483\u0005\u0000\u0000\u0001\u047b\u047d\u0003\u0080@\u0000\u047c"+ - "\u047b\u0001\u0000\u0000\u0000\u047d\u047e\u0001\u0000\u0000\u0000\u047e"+ - "\u047c\u0001\u0000\u0000\u0000\u047e\u047f\u0001\u0000\u0000\u0000\u047f"+ - "\u0480\u0001\u0000\u0000\u0000\u0480\u0481\u0005\u0000\u0000\u0001\u0481"+ - "\u0483\u0001\u0000\u0000\u0000\u0482\u0477\u0001\u0000\u0000\u0000\u0482"+ - "\u047c\u0001\u0000\u0000\u0000\u0483\u0095\u0001\u0000\u0000\u0000\u0484"+ - "\u0485\u0003\u0082A\u0000\u0485\u0486\u0005\u0000\u0000\u0001\u0486\u048f"+ - "\u0001\u0000\u0000\u0000\u0487\u0489\u0003\u0080@\u0000\u0488\u0487\u0001"+ - "\u0000\u0000\u0000\u0489\u048c\u0001\u0000\u0000\u0000\u048a\u0488\u0001"+ - "\u0000\u0000\u0000\u048a\u048b\u0001\u0000\u0000\u0000\u048b\u048d\u0001"+ - "\u0000\u0000\u0000\u048c\u048a\u0001\u0000\u0000\u0000\u048d\u048f\u0005"+ - "\u0000\u0000\u0001\u048e\u0484\u0001\u0000\u0000\u0000\u048e\u048a\u0001"+ - "\u0000\u0000\u0000\u048f\u0097\u0001\u0000\u0000\u0000|\u00ab\u00b2\u00b7"+ + "\u02a9\u0005\u008e\u0000\u0000\u02a9\u02aa\u0005\u0001\u0000\u0000\u02aa"+ + "\u02ab\u0003$\u0012\u0000\u02ab\u02ac\u0005\u0002\u0000\u0000\u02ac\u02b0"+ + "\u0005\u0085\u0000\u0000\u02ad\u02af\u0003 \u0010\u0000\u02ae\u02ad\u0001"+ + "\u0000\u0000\u0000\u02af\u02b2\u0001\u0000\u0000\u0000\u02b0\u02ae\u0001"+ + "\u0000\u0000\u0000\u02b0\u02b1\u0001\u0000\u0000\u0000\u02b1\u02b3\u0001"+ + "\u0000\u0000\u0000\u02b2\u02b0\u0001\u0000\u0000\u0000\u02b3\u02b4\u0005"+ + "\u0002\u0000\u0000\u02b4_\u0001\u0000\u0000\u0000\u02b5\u02b6\u0005\u0001"+ + "\u0000\u0000\u02b6\u02b8\u0005\u008c\u0000\u0000\u02b7\u02b9\u0003\"\u0011"+ + "\u0000\u02b8\u02b7\u0001\u0000\u0000\u0000\u02b8\u02b9\u0001\u0000\u0000"+ + "\u0000\u02b9\u02ba\u0001\u0000\u0000\u0000\u02ba\u02bb\u0003b1\u0000\u02bb"+ + "\u02bc\u0005\u0002\u0000\u0000\u02bca\u0001\u0000\u0000\u0000\u02bd\u02d0"+ + "\u0003\u0018\f\u0000\u02be\u02bf\u0003r9\u0000\u02bf\u02c0\u0003\u0018"+ + "\f\u0000\u02c0\u02d0\u0001\u0000\u0000\u0000\u02c1\u02c2\u0003x<\u0000"+ + "\u02c2\u02c3\u0003b1\u0000\u02c3\u02d0\u0001\u0000\u0000\u0000\u02c4\u02c5"+ + "\u0003\u0006\u0003\u0000\u02c5\u02c6\u0005\u0001\u0000\u0000\u02c6\u02ca"+ + "\u0005\u008e\u0000\u0000\u02c7\u02c9\u0003 \u0010\u0000\u02c8\u02c7\u0001"+ + "\u0000\u0000\u0000\u02c9\u02cc\u0001\u0000\u0000\u0000\u02ca\u02c8\u0001"+ + "\u0000\u0000\u0000\u02ca\u02cb\u0001\u0000\u0000\u0000\u02cb\u02cd\u0001"+ + "\u0000\u0000\u0000\u02cc\u02ca\u0001\u0000\u0000\u0000\u02cd\u02ce\u0005"+ + "\u0002\u0000\u0000\u02ce\u02d0\u0001\u0000\u0000\u0000\u02cf\u02bd\u0001"+ + "\u0000\u0000\u0000\u02cf\u02be\u0001\u0000\u0000\u0000\u02cf\u02c1\u0001"+ + "\u0000\u0000\u0000\u02cf\u02c4\u0001\u0000\u0000\u0000\u02d0c\u0001\u0000"+ + "\u0000\u0000\u02d1\u02d2\u0005\u0001\u0000\u0000\u02d2\u02d4\u0005\u008f"+ + "\u0000\u0000\u02d3\u02d5\u0003 \u0010\u0000\u02d4\u02d3\u0001\u0000\u0000"+ + "\u0000\u02d4\u02d5\u0001\u0000\u0000\u0000\u02d5\u02d6\u0001\u0000\u0000"+ + "\u0000\u02d6\u02d7\u0005\u0001\u0000\u0000\u02d7\u02d8\u0003$\u0012\u0000"+ + "\u02d8\u02dc\u0005\u0002\u0000\u0000\u02d9\u02db\u0005\u0006\u0000\u0000"+ + "\u02da\u02d9\u0001\u0000\u0000\u0000\u02db\u02de\u0001\u0000\u0000\u0000"+ + "\u02dc\u02da\u0001\u0000\u0000\u0000\u02dc\u02dd\u0001\u0000\u0000\u0000"+ + "\u02dd\u02df\u0001\u0000\u0000\u0000\u02de\u02dc\u0001\u0000\u0000\u0000"+ + "\u02df\u02e0\u0005\u0002\u0000\u0000\u02e0\u02f0\u0001\u0000\u0000\u0000"+ + "\u02e1\u02e2\u0005\u0001\u0000\u0000\u02e2\u02e4\u0005\u008f\u0000\u0000"+ + "\u02e3\u02e5\u0003 \u0010\u0000\u02e4\u02e3\u0001\u0000\u0000\u0000\u02e4"+ + "\u02e5\u0001\u0000\u0000\u0000\u02e5\u02e6\u0001\u0000\u0000\u0000\u02e6"+ + "\u02ea\u0003\\.\u0000\u02e7\u02e9\u0005\u0006\u0000\u0000\u02e8\u02e7"+ + "\u0001\u0000\u0000\u0000\u02e9\u02ec\u0001\u0000\u0000\u0000\u02ea\u02e8"+ + "\u0001\u0000\u0000\u0000\u02ea\u02eb\u0001\u0000\u0000\u0000\u02eb\u02ed"+ + "\u0001\u0000\u0000\u0000\u02ec\u02ea\u0001\u0000\u0000\u0000\u02ed\u02ee"+ + "\u0005\u0002\u0000\u0000\u02ee\u02f0\u0001\u0000\u0000\u0000\u02ef\u02d1"+ + "\u0001\u0000\u0000\u0000\u02ef\u02e1\u0001\u0000\u0000\u0000\u02f0e\u0001"+ + "\u0000\u0000\u0000\u02f1\u02f2\u0005\u0001\u0000\u0000\u02f2\u02f4\u0005"+ + "\u008d\u0000\u0000\u02f3\u02f5\u0003\"\u0011\u0000\u02f4\u02f3\u0001\u0000"+ + "\u0000\u0000\u02f4\u02f5\u0001\u0000\u0000\u0000\u02f5\u02f6\u0001\u0000"+ + "\u0000\u0000\u02f6\u02f7\u0003h4\u0000\u02f7\u02f8\u0005\u0002\u0000\u0000"+ + "\u02f8g\u0001\u0000\u0000\u0000\u02f9\u030a\u0003\u001a\r\u0000\u02fa"+ + "\u02fb\u0003r9\u0000\u02fb\u02fc\u0003\u001a\r\u0000\u02fc\u030a\u0001"+ + "\u0000\u0000\u0000\u02fd\u02fe\u0003x<\u0000\u02fe\u02ff\u0003h4\u0000"+ + "\u02ff\u030a\u0001\u0000\u0000\u0000\u0300\u0301\u0005\u0001\u0000\u0000"+ + "\u0301\u0305\u0005\u008f\u0000\u0000\u0302\u0304\u0005\u0006\u0000\u0000"+ + "\u0303\u0302\u0001\u0000\u0000\u0000\u0304\u0307\u0001\u0000\u0000\u0000"+ + "\u0305\u0303\u0001\u0000\u0000\u0000\u0305\u0306\u0001\u0000\u0000\u0000"+ + "\u0306\u0308\u0001\u0000\u0000\u0000\u0307\u0305\u0001\u0000\u0000\u0000"+ + "\u0308\u030a\u0005\u0002\u0000\u0000\u0309\u02f9\u0001\u0000\u0000\u0000"+ + "\u0309\u02fa\u0001\u0000\u0000\u0000\u0309\u02fd\u0001\u0000\u0000\u0000"+ + "\u0309\u0300\u0001\u0000\u0000\u0000\u030ai\u0001\u0000\u0000\u0000\u030b"+ + "\u030c\u0005\u0001\u0000\u0000\u030c\u030e\u0005\u008b\u0000\u0000\u030d"+ + "\u030f\u0003\"\u0011\u0000\u030e\u030d\u0001\u0000\u0000\u0000\u030e\u030f"+ + "\u0001\u0000\u0000\u0000\u030f\u0310\u0001\u0000\u0000\u0000\u0310\u0311"+ + "\u0003l6\u0000\u0311\u0312\u0005\u0002\u0000\u0000\u0312k\u0001\u0000"+ + "\u0000\u0000\u0313\u0314\u0003\u000e\u0007\u0000\u0314\u0315\u0003R)\u0000"+ + "\u0315\u031d\u0001\u0000\u0000\u0000\u0316\u0317\u0003r9\u0000\u0317\u0318"+ + "\u0003\u000e\u0007\u0000\u0318\u031d\u0001\u0000\u0000\u0000\u0319\u031a"+ + "\u0003x<\u0000\u031a\u031b\u0003l6\u0000\u031b\u031d\u0001\u0000\u0000"+ + "\u0000\u031c\u0313\u0001\u0000\u0000\u0000\u031c\u0316\u0001\u0000\u0000"+ + "\u0000\u031c\u0319\u0001\u0000\u0000\u0000\u031dm\u0001\u0000\u0000\u0000"+ + "\u031e\u031f\u0005\u0001\u0000\u0000\u031f\u0321\u0005\u0085\u0000\u0000"+ + "\u0320\u0322\u0003\"\u0011\u0000\u0321\u0320\u0001\u0000\u0000\u0000\u0321"+ + "\u0322\u0001\u0000\u0000\u0000\u0322\u0323\u0001\u0000\u0000\u0000\u0323"+ + "\u0324\u0003\u001c\u000e\u0000\u0324\u0325\u0005\u0002\u0000\u0000\u0325"+ + "\u0347\u0001\u0000\u0000\u0000\u0326\u0327\u0005\u0001\u0000\u0000\u0327"+ + "\u0329\u0005\u0085\u0000\u0000\u0328\u032a\u0003\"\u0011\u0000\u0329\u0328"+ + "\u0001\u0000\u0000\u0000\u0329\u032a\u0001\u0000\u0000\u0000\u032a\u032b"+ + "\u0001\u0000\u0000\u0000\u032b\u032c\u0003\u0016\u000b\u0000\u032c\u032d"+ + "\u0005\u0002\u0000\u0000\u032d\u0347\u0001\u0000\u0000\u0000\u032e\u032f"+ + "\u0005\u0001\u0000\u0000\u032f\u0331\u0005\u008c\u0000\u0000\u0330\u0332"+ + "\u0003\"\u0011\u0000\u0331\u0330\u0001\u0000\u0000\u0000\u0331\u0332\u0001"+ + "\u0000\u0000\u0000\u0332\u0333\u0001\u0000\u0000\u0000\u0333\u0334\u0003"+ + "\u0018\f\u0000\u0334\u0335\u0005\u0002\u0000\u0000\u0335\u0347\u0001\u0000"+ + "\u0000\u0000\u0336\u0337\u0005\u0001\u0000\u0000\u0337\u0339\u0005\u008d"+ + "\u0000\u0000\u0338\u033a\u0003\"\u0011\u0000\u0339\u0338\u0001\u0000\u0000"+ + "\u0000\u0339\u033a\u0001\u0000\u0000\u0000\u033a\u033b\u0001\u0000\u0000"+ + "\u0000\u033b\u033c\u0003\u001a\r\u0000\u033c\u033d\u0005\u0002\u0000\u0000"+ + "\u033d\u0347\u0001\u0000\u0000\u0000\u033e\u033f\u0005\u0001\u0000\u0000"+ + "\u033f\u0341\u0005\u008b\u0000\u0000\u0340\u0342\u0003\"\u0011\u0000\u0341"+ + "\u0340\u0001\u0000\u0000\u0000\u0341\u0342\u0001\u0000\u0000\u0000\u0342"+ + "\u0343\u0001\u0000\u0000\u0000\u0343\u0344\u0003\u000e\u0007\u0000\u0344"+ + "\u0345\u0005\u0002\u0000\u0000\u0345\u0347\u0001\u0000\u0000\u0000\u0346"+ + "\u031e\u0001\u0000\u0000\u0000\u0346\u0326\u0001\u0000\u0000\u0000\u0346"+ + "\u032e\u0001\u0000\u0000\u0000\u0346\u0336\u0001\u0000\u0000\u0000\u0346"+ + "\u033e\u0001\u0000\u0000\u0000\u0347o\u0001\u0000\u0000\u0000\u0348\u0349"+ + "\u0005\u0001\u0000\u0000\u0349\u034a\u0005\u0091\u0000\u0000\u034a\u034b"+ + "\u0003\u0002\u0001\u0000\u034b\u034c\u0003\u0002\u0001\u0000\u034c\u034d"+ + "\u0003n7\u0000\u034d\u034e\u0005\u0002\u0000\u0000\u034eq\u0001\u0000"+ + "\u0000\u0000\u034f\u0350\u0005\u0001\u0000\u0000\u0350\u0351\u0005\u0091"+ + "\u0000\u0000\u0351\u0352\u0003\u0002\u0001\u0000\u0352\u0353\u0003\u0002"+ + "\u0001\u0000\u0353\u0354\u0005\u0002\u0000\u0000\u0354s\u0001\u0000\u0000"+ + "\u0000\u0355\u0356\u0005\u0001\u0000\u0000\u0356\u0357\u0005\u0085\u0000"+ + "\u0000\u0357\u0358\u0003 \u0010\u0000\u0358\u0359\u0005\u0002\u0000\u0000"+ + "\u0359\u036a\u0001\u0000\u0000\u0000\u035a\u035b\u0005\u0001\u0000\u0000"+ + "\u035b\u035c\u0005\u008c\u0000\u0000\u035c\u035d\u0003 \u0010\u0000\u035d"+ + "\u035e\u0005\u0002\u0000\u0000\u035e\u036a\u0001\u0000\u0000\u0000\u035f"+ + "\u0360\u0005\u0001\u0000\u0000\u0360\u0361\u0005\u008d\u0000\u0000\u0361"+ + "\u0362\u0003 \u0010\u0000\u0362\u0363\u0005\u0002\u0000\u0000\u0363\u036a"+ + "\u0001\u0000\u0000\u0000\u0364\u0365\u0005\u0001\u0000\u0000\u0365\u0366"+ + "\u0005\u008b\u0000\u0000\u0366\u0367\u0003 \u0010\u0000\u0367\u0368\u0005"+ + "\u0002\u0000\u0000\u0368\u036a\u0001\u0000\u0000\u0000\u0369\u0355\u0001"+ + "\u0000\u0000\u0000\u0369\u035a\u0001\u0000\u0000\u0000\u0369\u035f\u0001"+ + "\u0000\u0000\u0000\u0369\u0364\u0001\u0000\u0000\u0000\u036au\u0001\u0000"+ + "\u0000\u0000\u036b\u036c\u0005\u0001\u0000\u0000\u036c\u036d\u0005\u0092"+ + "\u0000\u0000\u036d\u036e\u0003\u0002\u0001\u0000\u036e\u036f\u0003t:\u0000"+ + "\u036f\u0370\u0005\u0002\u0000\u0000\u0370w\u0001\u0000\u0000\u0000\u0371"+ + "\u0372\u0005\u0001\u0000\u0000\u0372\u0373\u0005\u0092\u0000\u0000\u0373"+ + "\u0374\u0003\u0002\u0001\u0000\u0374\u0375\u0005\u0002\u0000\u0000\u0375"+ + "y\u0001\u0000\u0000\u0000\u0376\u0377\u0005\u0001\u0000\u0000\u0377\u0379"+ + "\u0005\u0093\u0000\u0000\u0378\u037a\u0003\"\u0011\u0000\u0379\u0378\u0001"+ + "\u0000\u0000\u0000\u0379\u037a\u0001\u0000\u0000\u0000\u037a\u037b\u0001"+ + "\u0000\u0000\u0000\u037b\u037c\u0003\u001c\u000e\u0000\u037c\u037d\u0003"+ + "\u0016\u000b\u0000\u037d\u037e\u0005\u0002\u0000\u0000\u037e{\u0001\u0000"+ + "\u0000\u0000\u037f\u0380\u0005\u0001\u0000\u0000\u0380\u0382\u0005\u0084"+ + "\u0000\u0000\u0381\u0383\u0003\"\u0011\u0000\u0382\u0381\u0001\u0000\u0000"+ + "\u0000\u0382\u0383\u0001\u0000\u0000\u0000\u0383\u0384\u0001\u0000\u0000"+ + "\u0000\u0384\u0385\u0003\u0010\b\u0000\u0385\u0386\u0005\u0002\u0000\u0000"+ + "\u0386}\u0001\u0000\u0000\u0000\u0387\u0388\u0005\u0001\u0000\u0000\u0388"+ + "\u0389\u0005\u0087\u0000\u0000\u0389\u038a\u0003 \u0010\u0000\u038a\u038b"+ + "\u0005\u0002\u0000\u0000\u038b\u007f\u0001\u0000\u0000\u0000\u038c\u0398"+ + "\u0003|>\u0000\u038d\u0398\u0003j5\u0000\u038e\u0398\u0003`0\u0000\u038f"+ + "\u0398\u0003f3\u0000\u0390\u0398\u0003T*\u0000\u0391\u0398\u0003^/\u0000"+ + "\u0392\u0398\u0003d2\u0000\u0393\u0398\u0003~?\u0000\u0394\u0398\u0003"+ + "p8\u0000\u0395\u0398\u0003v;\u0000\u0396\u0398\u0003z=\u0000\u0397\u038c"+ + "\u0001\u0000\u0000\u0000\u0397\u038d\u0001\u0000\u0000\u0000\u0397\u038e"+ + "\u0001\u0000\u0000\u0000\u0397\u038f\u0001\u0000\u0000\u0000\u0397\u0390"+ + "\u0001\u0000\u0000\u0000\u0397\u0391\u0001\u0000\u0000\u0000\u0397\u0392"+ + "\u0001\u0000\u0000\u0000\u0397\u0393\u0001\u0000\u0000\u0000\u0397\u0394"+ + "\u0001\u0000\u0000\u0000\u0397\u0395\u0001\u0000\u0000\u0000\u0397\u0396"+ + "\u0001\u0000\u0000\u0000\u0398\u0081\u0001\u0000\u0000\u0000\u0399\u039a"+ + "\u0005\u0001\u0000\u0000\u039a\u039c\u0005\u0095\u0000\u0000\u039b\u039d"+ + "\u0005\u00a8\u0000\u0000\u039c\u039b\u0001\u0000\u0000\u0000\u039c\u039d"+ + "\u0001\u0000\u0000\u0000\u039d\u03a1\u0001\u0000\u0000\u0000\u039e\u03a0"+ + "\u0003\u0080@\u0000\u039f\u039e\u0001\u0000\u0000\u0000\u03a0\u03a3\u0001"+ + "\u0000\u0000\u0000\u03a1\u039f\u0001\u0000\u0000\u0000\u03a1\u03a2\u0001"+ + "\u0000\u0000\u0000\u03a2\u03a4\u0001\u0000\u0000\u0000\u03a3\u03a1\u0001"+ + "\u0000\u0000\u0000\u03a4\u03a5\u0005\u0002\u0000\u0000\u03a5\u0083\u0001"+ + "\u0000\u0000\u0000\u03a6\u03c3\u0003\u0082A\u0000\u03a7\u03a8\u0005\u0001"+ + "\u0000\u0000\u03a8\u03aa\u0005\u0095\u0000\u0000\u03a9\u03ab\u0005\u00a8"+ + "\u0000\u0000\u03aa\u03a9\u0001\u0000\u0000\u0000\u03aa\u03ab\u0001\u0000"+ + "\u0000\u0000\u03ab\u03ac\u0001\u0000\u0000\u0000\u03ac\u03b0\u0007\u0003"+ + "\u0000\u0000\u03ad\u03af\u0005\u0006\u0000\u0000\u03ae\u03ad\u0001\u0000"+ + "\u0000\u0000\u03af\u03b2\u0001\u0000\u0000\u0000\u03b0\u03ae\u0001\u0000"+ + "\u0000\u0000\u03b0\u03b1\u0001\u0000\u0000\u0000\u03b1\u03b3\u0001\u0000"+ + "\u0000\u0000\u03b2\u03b0\u0001\u0000\u0000\u0000\u03b3\u03c3\u0005\u0002"+ + "\u0000\u0000\u03b4\u03b5\u0005\u0001\u0000\u0000\u03b5\u03b6\u0005\u0095"+ + "\u0000\u0000\u03b6\u03b8\u0005\u0098\u0000\u0000\u03b7\u03b9\u0005\u00a8"+ + "\u0000\u0000\u03b8\u03b7\u0001\u0000\u0000\u0000\u03b8\u03b9\u0001\u0000"+ + "\u0000\u0000\u03b9\u03ba\u0001\u0000\u0000\u0000\u03ba\u03be\u0005\u0096"+ + "\u0000\u0000\u03bb\u03bd\u0005\u0006\u0000\u0000\u03bc\u03bb\u0001\u0000"+ + "\u0000\u0000\u03bd\u03c0\u0001\u0000\u0000\u0000\u03be\u03bc\u0001\u0000"+ + "\u0000\u0000\u03be\u03bf\u0001\u0000\u0000\u0000\u03bf\u03c1\u0001\u0000"+ + "\u0000\u0000\u03c0\u03be\u0001\u0000\u0000\u0000\u03c1\u03c3\u0005\u0002"+ + "\u0000\u0000\u03c2\u03a6\u0001\u0000\u0000\u0000\u03c2\u03a7\u0001\u0000"+ + "\u0000\u0000\u03c2\u03b4\u0001\u0000\u0000\u0000\u03c3\u0085\u0001\u0000"+ + "\u0000\u0000\u03c4\u03c5\u0005\u0001\u0000\u0000\u03c5\u03c7\u0005\u009c"+ + "\u0000\u0000\u03c6\u03c8\u0005\u00a8\u0000\u0000\u03c7\u03c6\u0001\u0000"+ + "\u0000\u0000\u03c7\u03c8\u0001\u0000\u0000\u0000\u03c8\u03c9\u0001\u0000"+ + "\u0000\u0000\u03c9\u03ca\u0003\u0002\u0001\u0000\u03ca\u03cb\u0003\u0092"+ + "I\u0000\u03cb\u03cc\u0005\u0002\u0000\u0000\u03cc\u03d6\u0001\u0000\u0000"+ + "\u0000\u03cd\u03ce\u0005\u0001\u0000\u0000\u03ce\u03d0\u0005\u009d\u0000"+ + "\u0000\u03cf\u03d1\u0005\u00a8\u0000\u0000\u03d0\u03cf\u0001\u0000\u0000"+ + "\u0000\u03d0\u03d1\u0001\u0000\u0000\u0000\u03d1\u03d2\u0001\u0000\u0000"+ + "\u0000\u03d2\u03d3\u0003\u0002\u0001\u0000\u03d3\u03d4\u0005\u0002\u0000"+ + "\u0000\u03d4\u03d6\u0001\u0000\u0000\u0000\u03d5\u03c4\u0001\u0000\u0000"+ + "\u0000\u03d5\u03cd\u0001\u0000\u0000\u0000\u03d6\u0087\u0001\u0000\u0000"+ + "\u0000\u03d7\u03d8\u0005\u0001\u0000\u0000\u03d8\u03d9\u0005\u009e\u0000"+ + "\u0000\u03d9\u03da\u0003\u0084B\u0000\u03da\u03db\u0005\u0006\u0000\u0000"+ + "\u03db\u03dc\u0005\u0002\u0000\u0000\u03dc\u040c\u0001\u0000\u0000\u0000"+ + "\u03dd\u03de\u0005\u0001\u0000\u0000\u03de\u03df\u0005\u009f\u0000\u0000"+ + "\u03df\u03e0\u0003\u0084B\u0000\u03e0\u03e1\u0005\u0006\u0000\u0000\u03e1"+ + "\u03e2\u0005\u0002\u0000\u0000\u03e2\u040c\u0001\u0000\u0000\u0000\u03e3"+ + "\u03e4\u0005\u0001\u0000\u0000\u03e4\u03e5\u0005\u00a0\u0000\u0000\u03e5"+ + "\u03e6\u0003\u0084B\u0000\u03e6\u03e7\u0005\u0006\u0000\u0000\u03e7\u03e8"+ + "\u0005\u0002\u0000\u0000\u03e8\u040c\u0001\u0000\u0000\u0000\u03e9\u03ea"+ + "\u0005\u0001\u0000\u0000\u03ea\u03eb\u0005\u00a4\u0000\u0000\u03eb\u03ec"+ + "\u0003\u0084B\u0000\u03ec\u03ed\u0005\u0006\u0000\u0000\u03ed\u03ee\u0005"+ + "\u0002\u0000\u0000\u03ee\u040c\u0001\u0000\u0000\u0000\u03ef\u03f0\u0005"+ + "\u0001\u0000\u0000\u03f0\u03f1\u0005\u00a1\u0000\u0000\u03f1\u03f2\u0003"+ + "\u0086C\u0000\u03f2\u03f3\u0003\u0092I\u0000\u03f3\u03f4\u0005\u0002\u0000"+ + "\u0000\u03f4\u040c\u0001\u0000\u0000\u0000\u03f5\u03f6\u0005\u0001\u0000"+ + "\u0000\u03f6\u03f7\u0005\u00a2\u0000\u0000\u03f7\u03f8\u0003\u0086C\u0000"+ + "\u03f8\u03f9\u0005\u0002\u0000\u0000\u03f9\u040c\u0001\u0000\u0000\u0000"+ + "\u03fa\u03fb\u0005\u0001\u0000\u0000\u03fb\u03fc\u0005\u00a3\u0000\u0000"+ + "\u03fc\u03fd\u0003\u0086C\u0000\u03fd\u03fe\u0005\u0002\u0000\u0000\u03fe"+ + "\u040c\u0001\u0000\u0000\u0000\u03ff\u0400\u0005\u0001\u0000\u0000\u0400"+ + "\u0401\u0005\u00a4\u0000\u0000\u0401\u0402\u0003\u0086C\u0000\u0402\u0403"+ + "\u0005\u0006\u0000\u0000\u0403\u0404\u0005\u0002\u0000\u0000\u0404\u040c"+ + "\u0001\u0000\u0000\u0000\u0405\u0406\u0005\u0001\u0000\u0000\u0406\u0407"+ + "\u0005\u00a5\u0000\u0000\u0407\u0408\u0003\u0086C\u0000\u0408\u0409\u0005"+ + "\u0006\u0000\u0000\u0409\u040a\u0005\u0002\u0000\u0000\u040a\u040c\u0001"+ + "\u0000\u0000\u0000\u040b\u03d7\u0001\u0000\u0000\u0000\u040b\u03dd\u0001"+ + "\u0000\u0000\u0000\u040b\u03e3\u0001\u0000\u0000\u0000\u040b\u03e9\u0001"+ + "\u0000\u0000\u0000\u040b\u03ef\u0001\u0000\u0000\u0000\u040b\u03f5\u0001"+ + "\u0000\u0000\u0000\u040b\u03fa\u0001\u0000\u0000\u0000\u040b\u03ff\u0001"+ + "\u0000\u0000\u0000\u040b\u0405\u0001\u0000\u0000\u0000\u040c\u0089\u0001"+ + "\u0000\u0000\u0000\u040d\u041b\u0003\u0086C\u0000\u040e\u041b\u0003\u0088"+ + "D\u0000\u040f\u041b\u0003\u0084B\u0000\u0410\u0411\u0005\u0001\u0000\u0000"+ + "\u0411\u0412\u0005\u009b\u0000\u0000\u0412\u0414\u0003\u0002\u0001\u0000"+ + "\u0413\u0415\u0005\u00a8\u0000\u0000\u0414\u0413\u0001\u0000\u0000\u0000"+ + "\u0414\u0415\u0001\u0000\u0000\u0000\u0415\u0416\u0001\u0000\u0000\u0000"+ + "\u0416\u0417\u0005\u0002\u0000\u0000\u0417\u041b\u0001\u0000\u0000\u0000"+ + "\u0418\u041b\u0003\u008eG\u0000\u0419\u041b\u0003\u008cF\u0000\u041a\u040d"+ + "\u0001\u0000\u0000\u0000\u041a\u040e\u0001\u0000\u0000\u0000\u041a\u040f"+ + "\u0001\u0000\u0000\u0000\u041a\u0410\u0001\u0000\u0000\u0000\u041a\u0418"+ + "\u0001\u0000\u0000\u0000\u041a\u0419\u0001\u0000\u0000\u0000\u041b\u008b"+ + "\u0001\u0000\u0000\u0000\u041c\u041d\u0005\u0001\u0000\u0000\u041d\u041e"+ + "\u0005\u0095\u0000\u0000\u041e\u0420\u0005\u0099\u0000\u0000\u041f\u0421"+ + "\u0005\u00a8\u0000\u0000\u0420\u041f\u0001\u0000\u0000\u0000\u0420\u0421"+ + "\u0001\u0000\u0000\u0000\u0421\u0423\u0001\u0000\u0000\u0000\u0422\u0424"+ + "\u0005\u00a8\u0000\u0000\u0423\u0422\u0001\u0000\u0000\u0000\u0423\u0424"+ + "\u0001\u0000\u0000\u0000\u0424\u0425\u0001\u0000\u0000\u0000\u0425\u0426"+ + "\u0005\u0002\u0000\u0000\u0426\u008d\u0001\u0000\u0000\u0000\u0427\u0428"+ + "\u0005\u0001\u0000\u0000\u0428\u042a\u0005\u009a\u0000\u0000\u0429\u042b"+ + "\u0005\u00a8\u0000\u0000\u042a\u0429\u0001\u0000\u0000\u0000\u042a\u042b"+ + "\u0001\u0000\u0000\u0000\u042b\u042f\u0001\u0000\u0000\u0000\u042c\u042e"+ + "\u0003\u008aE\u0000\u042d\u042c\u0001\u0000\u0000\u0000\u042e\u0431\u0001"+ + "\u0000\u0000\u0000\u042f\u042d\u0001\u0000\u0000\u0000\u042f\u0430\u0001"+ + "\u0000\u0000\u0000\u0430\u0432\u0001\u0000\u0000\u0000\u0431\u042f\u0001"+ + "\u0000\u0000\u0000\u0432\u0448\u0005\u0002\u0000\u0000\u0433\u0434\u0005"+ + "\u0001\u0000\u0000\u0434\u0436\u0005\u00a6\u0000\u0000\u0435\u0437\u0005"+ + "\u00a8\u0000\u0000\u0436\u0435\u0001\u0000\u0000\u0000\u0436\u0437\u0001"+ + "\u0000\u0000\u0000\u0437\u0438\u0001\u0000\u0000\u0000\u0438\u0439\u0005"+ + "\u0006\u0000\u0000\u0439\u0448\u0005\u0002\u0000\u0000\u043a\u043b\u0005"+ + "\u0001\u0000\u0000\u043b\u043d\u0005\u00a7\u0000\u0000\u043c\u043e\u0005"+ + "\u00a8\u0000\u0000\u043d\u043c\u0001\u0000\u0000\u0000\u043d\u043e\u0001"+ + "\u0000\u0000\u0000\u043e\u043f\u0001\u0000\u0000\u0000\u043f\u0440\u0005"+ + "\u0006\u0000\u0000\u0440\u0448\u0005\u0002\u0000\u0000\u0441\u0442\u0005"+ + "\u0001\u0000\u0000\u0442\u0444\u0005\u00a7\u0000\u0000\u0443\u0445\u0005"+ + "\u00a8\u0000\u0000\u0444\u0443\u0001\u0000\u0000\u0000\u0444\u0445\u0001"+ + "\u0000\u0000\u0000\u0445\u0446\u0001\u0000\u0000\u0000\u0446\u0448\u0005"+ + "\u0002\u0000\u0000\u0447\u0427\u0001\u0000\u0000\u0000\u0447\u0433\u0001"+ + "\u0000\u0000\u0000\u0447\u043a\u0001\u0000\u0000\u0000\u0447\u0441\u0001"+ + "\u0000\u0000\u0000\u0448\u008f\u0001\u0000\u0000\u0000\u0449\u044a\u0005"+ + "\u0001\u0000\u0000\u044a\u044b\u0005\b\u0000\u0000\u044b\u044c\u0003\u001e"+ + "\u000f\u0000\u044c\u044d\u0005\u0002\u0000\u0000\u044d\u0091\u0001\u0000"+ + "\u0000\u0000\u044e\u0450\u0003\u0090H\u0000\u044f\u044e\u0001\u0000\u0000"+ + "\u0000\u0450\u0453\u0001\u0000\u0000\u0000\u0451\u044f\u0001\u0000\u0000"+ + "\u0000\u0451\u0452\u0001\u0000\u0000\u0000\u0452\u0093\u0001\u0000\u0000"+ + "\u0000\u0453\u0451\u0001\u0000\u0000\u0000\u0454\u0456\u0003\u008aE\u0000"+ + "\u0455\u0454\u0001\u0000\u0000\u0000\u0456\u0459\u0001\u0000\u0000\u0000"+ + "\u0457\u0455\u0001\u0000\u0000\u0000\u0457\u0458\u0001\u0000\u0000\u0000"+ + "\u0458\u045a\u0001\u0000\u0000\u0000\u0459\u0457\u0001\u0000\u0000\u0000"+ + "\u045a\u0463\u0005\u0000\u0000\u0001\u045b\u045d\u0003\u0080@\u0000\u045c"+ + "\u045b\u0001\u0000\u0000\u0000\u045d\u045e\u0001\u0000\u0000\u0000\u045e"+ + "\u045c\u0001\u0000\u0000\u0000\u045e\u045f\u0001\u0000\u0000\u0000\u045f"+ + "\u0460\u0001\u0000\u0000\u0000\u0460\u0461\u0005\u0000\u0000\u0001\u0461"+ + "\u0463\u0001\u0000\u0000\u0000\u0462\u0457\u0001\u0000\u0000\u0000\u0462"+ + "\u045c\u0001\u0000\u0000\u0000\u0463\u0095\u0001\u0000\u0000\u0000\u0464"+ + "\u0465\u0003\u0082A\u0000\u0465\u0466\u0005\u0000\u0000\u0001\u0466\u046f"+ + "\u0001\u0000\u0000\u0000\u0467\u0469\u0003\u0080@\u0000\u0468\u0467\u0001"+ + "\u0000\u0000\u0000\u0469\u046c\u0001\u0000\u0000\u0000\u046a\u0468\u0001"+ + "\u0000\u0000\u0000\u046a\u046b\u0001\u0000\u0000\u0000\u046b\u046d\u0001"+ + "\u0000\u0000\u0000\u046c\u046a\u0001\u0000\u0000\u0000\u046d\u046f\u0005"+ + "\u0000\u0000\u0001\u046e\u0464\u0001\u0000\u0000\u0000\u046e\u046a\u0001"+ + "\u0000\u0000\u0000\u046f\u0097\u0001\u0000\u0000\u0000v\u00ab\u00b2\u00b7"+ "\u00bf\u00cb\u00d2\u00d8\u00dd\u00e5\u00eb\u00f3\u00f9\u010b\u0123\u0136"+ "\u0139\u013d\u0140\u0165\u016c\u0180\u0185\u018c\u0191\u0194\u019b\u01a1"+ "\u01a9\u01af\u01b7\u01bd\u01c7\u01cd\u01d4\u01d9\u01dd\u01e2\u01e6\u01eb"+ "\u01ee\u01f2\u01fa\u0201\u0207\u0214\u021d\u0222\u0227\u022d\u0238\u023a"+ "\u023d\u0246\u024c\u0256\u025c\u0262\u0268\u026c\u0273\u0279\u027e\u0285"+ - "\u028f\u0295\u029a\u02a5\u02aa\u02b2\u02ba\u02c0\u02c8\u02cf\u02d3\u02d8"+ - "\u02ea\u02ef\u02f4\u02fc\u0304\u030a\u030f\u0314\u0325\u0329\u032e\u033c"+ - "\u0341\u0349\u0351\u0359\u0361\u0366\u0389\u0399\u03a2\u03b7\u03bc\u03c1"+ - "\u03ca\u03d0\u03d8\u03de\u03e2\u03e7\u03f0\u03f5\u042b\u0434\u043a\u0440"+ - "\u0443\u044a\u044f\u0456\u045d\u0464\u0467\u0471\u0477\u047e\u0482\u048a"+ - "\u048e"; + "\u028f\u0295\u029a\u02a5\u02b0\u02b8\u02ca\u02cf\u02d4\u02dc\u02e4\u02ea"+ + "\u02ef\u02f4\u0305\u0309\u030e\u031c\u0321\u0329\u0331\u0339\u0341\u0346"+ + "\u0369\u0379\u0382\u0397\u039c\u03a1\u03aa\u03b0\u03b8\u03be\u03c2\u03c7"+ + "\u03d0\u03d5\u040b\u0414\u041a\u0420\u0423\u042a\u042f\u0436\u043d\u0444"+ + "\u0447\u0451\u0457\u045e\u0462\u046a\u046e"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/scala/wasm/AST.scala b/src/main/scala/wasm/AST.scala index 274b2b508..60cf0c4fb 100644 --- a/src/main/scala/wasm/AST.scala +++ b/src/main/scala/wasm/AST.scala @@ -15,7 +15,7 @@ case class Table(id: Option[String], f: TableField) extends Definition case class Memory(id: Option[String], f: MemoryField) extends Definition case class Global(id: Option[String], f: GlobalField) extends Definition case class Elem(id: Option[Int], offset: List[Instr], elemList: ElemList) extends Definition -case class Data(id: Option[String], value: String) extends Definition +case class Data(id: Option[String], offset: Instr, value: String) extends Definition case class Start(id: Int) extends Definition case class Import(mod: String, name: String, desc: ImportDesc) extends Definition with Callable case class Export(name: String, desc: ExportDesc) extends Definition @@ -27,7 +27,7 @@ case class ImportFuncTy(name: Option[String], t: FuncType) extends ImportDesc case class ImportFuncTyUse(name: Option[String], u: Int) extends ImportDesc abstract class ElemList extends WIR -case class ElemListFunc(funcs: List[String]) extends ElemList +case class ElemListFunc(funcs: List[Int]) extends ElemList case class ElemListExpr(exprs: List[List[Instr]]) extends ElemList abstract class FuncField extends WIR diff --git a/src/main/scala/wasm/Parser.scala b/src/main/scala/wasm/Parser.scala index 0ce9fa94e..27b215fab 100644 --- a/src/main/scala/wasm/Parser.scala +++ b/src/main/scala/wasm/Parser.scala @@ -170,6 +170,28 @@ class GSWasmVisitor extends WatParserBaseVisitor[WIR] { f } + override def visitData(ctx: DataContext): Data = { + val instr = visit(ctx.instr()).asInstanceOf[Instr] + val str = ctx.STRING_.asScala.toList.map(_.getText.substring(1).dropRight(1)).mkString + Data(None, instr, str) + } + + override def visitElem(ctx: ElemContext): Elem = { + val offsetInstrs = List(visit(ctx.instr()).asInstanceOf[Instr]) + val funcs = ctx.idx().asScala.map(getVar(_)).map { id => + try id.toInt + catch { + case _: NumberFormatException => + if (fnMap.contains(id)) fnMap(id) + else { + System.err.println(s"[Parser] Warning: unresolved elem function reference: $id") + -1 + } + } + }.toList + Elem(None, offsetInstrs, ElemListFunc(funcs)) + } + override def visitSimport(ctx: SimportContext): WIR = { val module = ctx.name(0).getText.substring(1).dropRight(1) val name = ctx.name(1).getText.substring(1).dropRight(1) diff --git a/src/main/scala/wasm/StagedConcolicMiniWasm.scala b/src/main/scala/wasm/StagedConcolicMiniWasm.scala new file mode 100644 index 000000000..0d0de8ec4 --- /dev/null +++ b/src/main/scala/wasm/StagedConcolicMiniWasm.scala @@ -0,0 +1,2050 @@ +package gensym.wasm.stagedconcolicminiwasm + +import scala.collection.mutable.{ArrayBuffer, HashMap} + +import lms.core.stub.Adapter +import lms.core.virtualize +import lms.macros.SourceContext +import lms.core.stub.{Base, ScalaGenBase, CGenBase} +import lms.core.Backend._ +import lms.core.Backend.{Block => LMSBlock, Const => LMSConst} +import lms.core.Graph + +import gensym.wasm.ast._ +import gensym.wasm.ast.{Const => WasmConst, Block => WasmBlock} +import gensym.wasm.miniwasm.{ModuleInstance} +import gensym.wasm.symbolic.{SymVal} +import gensym.lmsx.{SAIDriver, StringOps, SAIOps, SAICodeGenBase, CppSAIDriver, CppSAICodeGenBase} +import gensym.wasm.symbolic.Concrete +import gensym.wasm.symbolic.ExploreTree +import gensym.structure.freer.Explore + +object Counter { + var currentId: Int = 0 + + // WIR is the branch's corresponding ast, while the Int stands for the nth + // branch of the AST(a WIR may contain multiple branches, e.g., br_table) + private val dict = new HashMap[(WIR, Int), Int]() + + def reset(): Unit = { + currentId = 0 + dict.clear() + } + + def getId(): Int = { + val id = currentId + currentId += 1 + id + } + + def getId(wir: WIR, nth: Int = 0): Int = { + if (dict.contains((wir, nth))) { + dict((wir, nth)) + } else { + val id = currentId + currentId += 1 + dict((wir, nth)) = id + id + } + + } + + def getId(wir: WIR): Int = { + getId(wir, 0) + } +} +@virtualize +trait StagedWasmEvaluator extends SAIOps { + def module: ModuleInstance + + case class StagedConcreteNum(tipe: ValueType, i: Rep[Num]) { + def toStagedSymbolicNum: StagedSymbolicNum = { + StagedSymbolicNum(tipe, "Concrete".reflectCtrlWith[SymVal](i)) + } + } + + + case class StagedSymbolicNum(tipe: ValueType, s: Rep[SymVal]) + + def toStagedNum(num: Num): StagedConcreteNum = { + num match { + case I32V(_) => StagedConcreteNum(NumType(I32Type), num) + case I64V(_) => StagedConcreteNum(NumType(I64Type), num) + case F32V(_) => StagedConcreteNum(NumType(F32Type), num) + case F64V(_) => StagedConcreteNum(NumType(F64Type), num) + } + } + + def toStagedSymbolicNum(num: Num): StagedSymbolicNum = { + num match { + case I32V(_) => StagedSymbolicNum(NumType(I32Type), Concrete(num)) + case I64V(_) => StagedSymbolicNum(NumType(I64Type), Concrete(num)) + case F32V(_) => StagedSymbolicNum(NumType(F32Type), Concrete(num)) + case F64V(_) => StagedSymbolicNum(NumType(F64Type), Concrete(num)) + } + } + + implicit class ValueTypeOps(ty: ValueType) { + def size: Int = ty match { + case NumType(I32Type) => 4 + case NumType(I64Type) => 8 + case NumType(F32Type) => 4 + case NumType(F64Type) => 8 + } + } + + case class Context( + stackTypes: List[ValueType], + frameTypes: List[ValueType] + ) { + def push(ty: ValueType): Context = { + this.copy(stackTypes = ty :: stackTypes) + } + + def peek: ValueType = { + stackTypes.head + } + + def pop(): (ValueType, Context) = { + val (ty :: rest) = stackTypes + (ty, this.copy(stackTypes = rest)) + } + + def take(n: Int): Context = { + Predef.assert(n <= stackTypes.size, s"Context.take size $n is larger than stack size ${stackTypes.size}") + val (taken, rest) = stackTypes.splitAt(n) + this.copy(stackTypes = rest) + } + + def shift(offset: Int, size: Int): Context = { + // Predef.println(s"[DEBUG] Shifting stack by $offset, size $size, $this") + Predef.assert(offset >= 0, s"Context shift offset must be non-negative, get $offset") + if (offset == 0) { + this + } else { + this.copy( + stackTypes = stackTypes.take(size) ++ stackTypes.drop(offset + size) + ) + } + } + } + + class MCont[A] + type Cont[A] = (MCont[A]) => A + type Trail[A] = List[Context => Rep[Cont[A]]] + trait Func + + // a cache storing the compiled code for each function, to reduce re-compilation + val compileCache = new HashMap[Int, Rep[(MCont[Unit]) => Unit]] + + def funHere[A:Manifest,B:Manifest](f: Rep[A] => Rep[B], dummy: Rep[Unit]): Rep[A => B] = { + // to avoid LMS lifting a function, we create a dummy node and read it inside function + fun((x: Rep[A]) => { + "dummy-op".reflectCtrlWith[Unit](dummy) + f(x) + }) + } + + def makeInitMCont[A:Manifest](f: Rep[Unit => A]): Rep[MCont[A]] = { + "make-init-mcont".reflectCtrlWith[MCont[A]](f) + } + + implicit class MContOps[A:Manifest](mk: Rep[MCont[A]]) { + def prependCont(k: Rep[Cont[A]]): Rep[MCont[A]] = { + "mcont-prepend".reflectCtrlWith[MCont[A]](mk, k) + } + + def enter(): Rep[A] = { + "mcont-enter".reflectCtrlWith[A](mk) + } + } + + trait Control + + // Save the current control information into a structure Control + // We need to store the control information, so we can resume the execution later + def makeControl(kont: Rep[Cont[Unit]], mkont: Rep[MCont[Unit]]): Rep[Control] = { + "control-make".reflectCtrlWith[Control](kont, mkont) + } + + var instrCost: Int = 0 + + def addInstrCost(): Rep[Unit] = { + "add-instr-cost".reflectCtrlWith[Unit](instrCost) + instrCost = 0 + () + } + + def evalSymbolic(ty: ValueType, + rest: List[Instr], + kont: Context => Rep[Cont[Unit]], + mkont: Rep[MCont[Unit]], + trail: Trail[Unit])(implicit ctx: Context) = { + Stack.popC(ty) + val id = Stack.popS(ty) + val symVal = id.makeSymbolic(ty) + val num = SymEnv.read(symVal.s) + Stack.pushC(StagedConcreteNum(ty, num)) + Stack.pushS(symVal) + val newCtx = ctx.pop()._2.push(ty) + eval(rest, kont, mkont, trail)(newCtx) + } + + def eval(insts: List[Instr], + kont: Context => Rep[Cont[Unit]], + mkont: Rep[MCont[Unit]], + trail: Trail[Unit]) + (implicit ctx: Context): Rep[Unit] = { + if (insts.isEmpty) return kont(ctx)(mkont) + instrCost += 1 + // Predef.println(s"[DEBUG] Evaluating instructions: ${insts.mkString(", ")}") + // Predef.println(s"[DEBUG] Current context: $ctx") + + val (inst, rest) = (insts.head, insts.tail) + inst match { + case Drop => + val (ty, newCtx) = ctx.pop() + Stack.popC(ty) + Stack.popS(ty) + eval(rest, kont, mkont, trail)(newCtx) + case WasmConst(num) => + Stack.pushC(toStagedNum(num)) + Stack.pushS(toStagedSymbolicNum(num)) + val newCtx = ctx.push(num.tipe(module)) + eval(rest, kont, mkont, trail)(newCtx) + case Symbolic(ty) => evalSymbolic(ty, rest, kont, mkont, trail)(ctx) + case LocalGet(i) => + Stack.pushC(Frames.getC(i)) + Stack.pushS(Frames.getS(i)) + val newCtx = ctx.push(ctx.frameTypes(i)) + eval(rest, kont, mkont, trail)(newCtx) + case Select(ty) => + val (ty1, newCtx1) = ctx.pop() + val cond = Stack.popC(ty1) + val condSym = Stack.popS(ty1) + val (ty2, newCtx2) = newCtx1.pop() + val falseVal = Stack.popC(ty2) + val falseSym = Stack.popS(ty2) + val (ty3, newCtx3) = newCtx2.pop() + val trueVal = Stack.popC(ty3) + val trueSym = Stack.popS(ty3) + if (cond.toInt != 0) { + Stack.pushC(trueVal) + Stack.pushS(trueSym) + } else { + Stack.pushC(falseVal) + Stack.pushS(falseSym) + } + val newCtx4 = newCtx3.push(ty2) + eval(rest, kont, mkont, trail)(newCtx4) + case LocalSet(i) => + val (ty, newCtx) = ctx.pop() + val num = Stack.popC(ty) + val sym = Stack.popS(ty) + Frames.setC(i, num) + Frames.setS(i, sym) + eval(rest, kont, mkont, trail)(newCtx) + case LocalTee(i) => + val ty = ctx.pop()._1 + val num = Stack.peekC(ty) + val sym = Stack.peekS(ty) + Frames.setC(i, num) + Frames.setS(i, sym) + eval(rest, kont, mkont, trail)(ctx) + case GlobalGet(i) => + Stack.pushC(Globals.getC(i)) + Stack.pushS(Globals.getS(i)) + val newCtx = ctx.push(module.globals(i).ty.ty) + eval(rest, kont, mkont, trail)(newCtx) + case GlobalSet(i) => + val (ty, newCtx) = ctx.pop() + val num = Stack.popC(ty) + val sym = Stack.popS(ty) + module.globals(i).ty match { + case GlobalType(tipe, true) => { + Globals.setC(i, num) + Globals.setS(i, sym) + } + case _ => throw new Exception("Cannot set immutable global") + } + eval(rest, kont, mkont, trail)(newCtx) + case Store(StoreOp(align, offset, ty, None)) => + val (ty1, newCtx1) = ctx.pop() + val value = Stack.popC(ty1) + val symValue = Stack.popS(ty1) + val (ty2, newCtx2) = newCtx1.pop() + val addr = Stack.popC(ty2) + val symAddr = Stack.popS(ty2) + Memory.storeInt(addr.toInt, offset, (value.toInt, symValue)) + eval(rest, kont, mkont, trail)(newCtx2) + case Nop => eval(rest, kont, mkont, trail) + case Load(LoadOp(align, offset, ty, None, None)) => + val (ty1, newCtx1) = ctx.pop() + val addr = Stack.popC(ty1) + Stack.popS(ty1) + val num = Memory.loadIntC(addr.toInt, offset) + val sym = Memory.loadIntS(addr.toInt, offset) + Stack.pushC(num) + Stack.pushS(sym) + val newCtx2 = newCtx1.push(ty) + eval(rest, kont, mkont, trail)(newCtx2) + case MemorySize => ??? + case MemoryGrow => + val (ty, newCtx) = ctx.pop() + val delta = Stack.popC(ty) + Stack.popS(ty) + val ret = Memory.grow(delta.toInt) + val retNum = Values.I32V(ret) + // For now, we assume that the result of memory.grow only depends on the execution path, + // we can relax this by turning it return to a symbol value and mimic the memory.grow's result as input. + val retSym = "Concrete".reflectCtrlWith[SymVal](retNum) + Stack.pushC(StagedConcreteNum(NumType(I32Type), retNum)) + Stack.pushS(StagedSymbolicNum(NumType(I32Type), retSym)) + val newCtx2 = newCtx.push(NumType(I32Type)) + eval(rest, kont, mkont, trail)(newCtx2) + case MemoryFill => ??? + case Unreachable => unreachable() + case Test(op) => + val (ty, newCtx1) = ctx.pop() + val v = Stack.popC(ty) + val s = Stack.popS(ty) + Stack.pushC(evalTestOpC(op, v)) + Stack.pushS(evalTestOpS(op, s)) + val newCtx2 = newCtx1.push(NumType(I32Type)) + eval(rest, kont, mkont, trail)(newCtx2) + case Unary(op) => + val (ty, newCtx1) = ctx.pop() + val v = Stack.popC(ty) + val s = Stack.popS(ty) + val res = evalUnaryOpC(op, v) + Stack.pushC(res) + Stack.pushS(evalUnaryOpS(op, s, res)) + val newCtx2 = newCtx1.push(res.tipe) + eval(rest, kont, mkont, trail)(newCtx2) + case Binary(op) => + val (ty2, newCtx1) = ctx.pop() + val v2 = Stack.popC(ty2) + val s2 = Stack.popS(ty2) + val (ty1, newCtx2) = newCtx1.pop() + val v1 = Stack.popC(ty1) + val s1 = Stack.popS(ty1) + val res = evalBinOpC(op, v1, v2) + Stack.pushC(res) + Stack.pushS(evalBinOpS(op, s1, s2, res)) + val newCtx3 = newCtx2.push(res.tipe) + eval(rest, kont, mkont, trail)(newCtx3) + case Compare(op) => + val (ty2, newCtx1) = ctx.pop() + val v2 = Stack.popC(ty2) + val s2 = Stack.popS(ty2) + val (ty1, newCtx2) = newCtx1.pop() + val v1 = Stack.popC(ty1) + val s1 = Stack.popS(ty1) + val res = evalRelOpC(op, v1, v2) + Stack.pushC(res) + Stack.pushS(evalRelOpS(op, s1, s2, res)) + val newCtx3 = newCtx2.push(res.tipe) + eval(rest, kont, mkont, trail)(newCtx3) + case WasmBlock(ty, inner) => + // no need to modify the stack when entering a block + // the type system guarantees that we will never take more than the input size from the stack + val funcTy = ty.funcType + val exitSize = ctx.stackTypes.size - funcTy.inps.size + funcTy.out.size + def restK(restCtx: Context): Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Exiting the block, stackSize =", Stack.size) + val offset = restCtx.stackTypes.size - exitSize + Stack.shiftC(offset, funcTy.out.size) + Stack.shiftS(offset, funcTy.out.size) + val newRestCtx = restCtx.shift(offset, funcTy.out.size) + eval(rest, kont, mk, trail)(newRestCtx) + }) + eval(inner, restK _, mkont, restK _ :: trail) + case Loop(ty, inner) => + val funcTy = ty.funcType + val exitSize = ctx.stackTypes.size - funcTy.inps.size + funcTy.out.size + def restK(restCtx: Context): Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Exiting the loop, stackSize =", Stack.size) + val offset = restCtx.stackTypes.size - exitSize + Stack.shiftC(offset, funcTy.out.size) + Stack.shiftS(offset, funcTy.out.size) + val newRestCtx = restCtx.shift(offset, funcTy.out.size) + eval(rest, kont, mk, trail)(newRestCtx) + }) + val enterSize = ctx.stackTypes.size + def loop(restCtx: Context): Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Entered the loop, stackSize =", Stack.size) + val offset = restCtx.stackTypes.size - enterSize + Stack.shiftC(offset, funcTy.inps.size) + Stack.shiftS(offset, funcTy.inps.size) + val newRestCtx = restCtx.shift(offset, funcTy.inps.size) + eval(inner, restK _, mk, loop _ :: trail)(newRestCtx) + }) + loop(ctx)(mkont) + case If(ty, thn, els) => + val funcTy = ty.funcType + val (condTy, newCtx) = ctx.pop() + val cond = Stack.popC(condTy) + val symCond = Stack.popS(condTy) + val exitSize = newCtx.stackTypes.size - funcTy.inps.size + funcTy.out.size + def restK(restCtx: Context): Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Exiting the if, stackSize =", Stack.size) + val offset = restCtx.stackTypes.size - exitSize + Stack.shiftC(offset, funcTy.out.size) + Stack.shiftS(offset, funcTy.out.size) + val newRestCtx = restCtx.shift(offset, funcTy.out.size) + eval(rest, kont, mk, trail)(newRestCtx) + }) + val id = Counter.getId(inst) + ExploreTree.fillWithIfElse(symCond.s, id) + def thnK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Entering the true branch $id of the if") + eval(thn, restK _, mk, restK _ :: trail)(newCtx) + }) + def elsK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Entering the false branch $id of the if") + eval(els, restK _, mk, restK _ :: trail)(newCtx) + }) + if (cond.toInt != 0) { + val control = makeControl(elsK, mkont) + ExploreTree.moveCursor(true, control) + thnK(mkont) + } else { + val control = makeControl(thnK, mkont) + ExploreTree.moveCursor(false, control) + elsK(mkont) + } + () + case Br(label) => + info(s"Jump to $label") + addInstrCost() + trail(label)(ctx)(mkont) + case BrIf(label) => + addInstrCost() + val (ty, newCtx) = ctx.pop() + val cond = Stack.popC(ty) + val symCond = Stack.popS(ty) + info(s"The br_if(${label})'s condition is ", cond.toInt) + val id = Counter.getId(inst) + ExploreTree.fillWithIfElse(symCond.s, id) + def thnK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + trail(label)(newCtx)(mk) + }) + def elsK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + eval(rest, kont, mk, trail)(newCtx) + }) + if (cond.toInt != 0) { + info(s"Jump to $label") + val control = makeControl(elsK, mkont) + ExploreTree.moveCursor(true, control) + thnK(mkont) + } else { + info(s"Continue") + val control = makeControl(thnK, mkont) + ExploreTree.moveCursor(false, control) + elsK(mkont) + } + () + case BrTable(labels, default) => + addInstrCost() + val (ty, newCtx) = ctx.pop() + def aux(choices: List[Int], idx: Int, mkont: Rep[MCont[Unit]]): Rep[Unit] = { + if (choices.isEmpty) { + Stack.popC(ty) + Stack.popS(ty) + trail(default)(newCtx)(mkont) + } else { + val label = Stack.peekC(ty) + val labelSym = Stack.peekS(ty) + val cond = (label - toStagedNum(I32V(idx))).isZero() + val condSym = (labelSym - toStagedSymbolicNum(I32V(idx))).isZero() + val id = Counter.getId(inst, idx) + ExploreTree.fillWithIfElse(condSym.s, id) + // When moving the cursor to a branch, we mark another branch as + // snapshotNode (this is done by moveCursor's runtime implementation) + // TODO: store snapshot into this snapshot node + def thnK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Entering the true branch $id of the br_table") + Stack.popC(ty) + Stack.popS(ty) + trail(choices.head)(newCtx)(mk) + }) + def elsK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Entering the false branch $id of the br_table") + aux(choices.tail, idx + 1, mk) + }) + if (cond.toInt != 0) { + val control = makeControl(elsK, mkont) + ExploreTree.moveCursor(true, control) + thnK(mkont) + } + else { + val control = makeControl(thnK, mkont) + ExploreTree.moveCursor(false, control) + elsK(mkont) + } + } + } + aux(labels, 0, mkont) + case Return => trail.last(ctx)(mkont) + case Call(f) => evalCall(rest, kont, mkont, trail, f) + case ReturnCall(f) => evalCall(rest, kont, mkont, trail, f) + case CallIndirect(ty, table) => + Predef.assert(table == 0, "Currently we can only have one table!") + val functy = module.types(ty) + Predef.println(s"Table = ") + evalCallIndirect(rest, kont, mkont, trail, functy.asInstanceOf[FuncType]) + case _ => + val todo = "todo-op".reflectCtrlWith[Unit]() + Predef.println(s"[WARNING] Encountered unimplemented instruction $inst, treat it as NOP") + Predef.assert(false, s"Unimplemented instruction $inst") + eval(rest, kont, mkont, trail) + } + } + + def forwardKont: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => mk.enter()) + + def readFuncTable(index: Rep[Int]): Rep[Func] = { + "read-func-table".reflectCtrlWith[Func](index) + } + + def invokeWithMCont(func: Rep[Func], mkont: Rep[MCont[Unit]]): Rep[Unit] = { + "invoke-func-with-mcont".reflectCtrlWith[Unit](func, mkont) + } + + def evalCallIndirect(rest: List[Instr], + kont: Context => Rep[Cont[Unit]], + mkont: Rep[MCont[Unit]], + trail: Trail[Unit], + functy: FuncType) + (implicit ctx: Context): Rep[Unit] = { + val (ty, newCtx) = ctx.pop() + val index = Stack.popC(ty) + val symIndex = Stack.popS(ty) + Predef.assert(ty == NumType(I32Type)) + val id = Counter.getId() + ExploreTree.fillWithCallIndirect(symIndex.s, id) + ExploreTree.moveCursor(index.toInt) + val func = readFuncTable(index.toInt) + val restK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Returned from call_indirect, stackSize =", Stack.size) + eval(rest, kont, mk, trail)(newCtx.copy(stackTypes = functy.out.reverse ++ newCtx.stackTypes.drop(functy.inps.size))) + }) + val newMKont: Rep[MCont[Unit]] = mkont.prependCont(restK) + + val argsC = Stack.takeC(functy.inps) + val argsS = Stack.takeS(functy.inps) + Frames.pushFrameC(functy.inps) + Frames.pushFrameS(functy.inps) + Frames.putAllC(argsC) + Frames.putAllS(argsS) + invokeWithMCont(func, newMKont) + } + + def evalFunc(ty: FuncType, body: List[Instr], funcIndex: Int, inps: List[ValueType], locals: List[ValueType]): Rep[(MCont[Unit]) => Unit] = { + if (compileCache.contains(funcIndex)) { + compileCache(funcIndex) + } else { + val func = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Entered the function at $funcIndex, stackSize =", Stack.size) + // the return instruction is also stack polymorphic + def retK(ctx: Context): Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Return from the function at $funcIndex, stackSize =", Stack.size) + val offset = ctx.stackTypes.size - ty.out.size + Stack.shiftC(offset, ty.out.size) + Stack.shiftS(offset, ty.out.size) + mk.enter() + }) + eval(body, retK _, mk, retK _::Nil)(Context(Nil, inps ++ locals)) + }) + compileCache(funcIndex) = func + func + } + } + + def evalCall(rest: List[Instr], + kont: Context => Rep[Cont[Unit]], + mkont: Rep[MCont[Unit]], + trail: Trail[Unit], + funcIndex: Int) + (implicit ctx: Context): Rep[Unit] = { + module.funcs(funcIndex) match { + case FuncDef(_, FuncBodyDef(ty, _, bodyLocals, body)) => + instrCost += (ty.inps ++ bodyLocals).size * 2 - 1 + addInstrCost() + val callee = evalFunc(ty, body, funcIndex, ty.inps, bodyLocals) + // Predef.println(s"[DEBUG] locals size: ${locals.size}") + val newCtx = ctx.take(ty.inps.size) + val argsC = Stack.takeC(ty.inps) + val argsS = Stack.takeS(ty.inps) + // We make a new trail by `restK`, since function creates a new block to escape + // (more or less like `return`) + val restK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Exiting the function at $funcIndex, stackSize =", Stack.size) + Frames.popFrameC(ty.inps.size + bodyLocals.size) + Frames.popFrameS(ty.inps.size + bodyLocals.size) + eval(rest, kont, mk, trail)(newCtx.copy(stackTypes = ty.out.reverse ++ ctx.stackTypes.drop(ty.inps.size))) + }) + val newMKont: Rep[MCont[Unit]] = mkont.prependCont(restK) + Frames.pushFrameC(ty.inps ++ bodyLocals) + Frames.pushFrameS(ty.inps ++ bodyLocals) + Frames.putAllC(argsC) + Frames.putAllS(argsS) + callee(newMKont) + case Import("console", "log", _) + | Import("spectest", "print_i32", _) => + //println(s"[DEBUG] current stack: $stack") + addInstrCost() + val (ty, newCtx) = ctx.pop() + val v = Stack.popC(ty) + Stack.popS(ty) + println(v.toInt) + eval(rest, kont, mkont, trail)(newCtx) + case Import("console", "assert", _) => + addInstrCost() + val (ty, newCtx) = ctx.pop() + val v = Stack.popC(ty) + // TODO: We should also add s into exploration tree + val s = Stack.popS(ty) + runtimeAssert(v.toInt != 0) + eval(rest, kont, mkont, trail)(newCtx) + case Import("i32", "symbolic", _) => + evalSymbolic(NumType(I32Type), rest, kont, mkont, trail)(ctx) + case Import("i32", "sym_assume", _) => + // symbolic assume is just like an if else that only has one branch, while another + // is marked as not-to-explore + val (condTy, newCtx) = ctx.pop() + Predef.assert(condTy == NumType(I32Type), s"sym_assume only supports i32 condition, get $condTy") + val cond = Stack.popC(condTy) + val symCond = Stack.popS(condTy) + val id = Counter.getId() + ExploreTree.fillWithIfElse(symCond.s, id) + def thnK: Rep[Cont[Unit]] = topFun((mk: Rep[MCont[Unit]]) => { + info(s"Successfully assumed condition at $id") + eval(rest, kont, mk, trail)(newCtx) + }) + if (cond.toInt != 0) { + ExploreTree.moveCursor(true) + eval(rest, kont, mkont, trail)(newCtx) + } else { + val control = makeControl(thnK, mkont) + ExploreTree.moveCursor(false, control) + // just stop the execution at here + ExploreTree.fillWithNotToExplore() + } + () + case Import("i32", "sym_assert", _) => + val (condTy, newCtx) = ctx.pop() + val v = Stack.popC(condTy) + val s = Stack.popS(condTy) + runtimeSymAssert(s) + runtimeAssert(v.toInt != 0) + eval(rest, kont, mkont, trail)(newCtx) + case Import("mem", "alloc", _) => + // this semantics here is not standardized in wasp, here is wasp's impl + // https://github.com/formalsec/wasp/blob/release/0.2.3/wasp/symbolic/concolic.ml#L449 + val (_, newCtx1) = ctx.pop() + val a = Stack.popC(NumType(I32Type)) + Stack.popS(NumType(I32Type)) + val (_, newCtx2) = newCtx1.pop() + val b = Stack.popC(NumType(I32Type)) + Stack.popS(NumType(I32Type)) + Stack.pushC(b) + val s = "Concrete".reflectCtrlWith[SymVal](Values.I32V(b.toInt)) + Stack.pushS(StagedSymbolicNum(NumType(I32Type), s)) + eval(rest, kont, mkont, trail)(newCtx1) + case Import("mem", "free", _) => + val (_, newCtx) = ctx.pop() + Stack.popC(NumType(I32Type)) + Stack.popS(NumType(I32Type)) + eval(rest, kont, mkont, trail)(newCtx) + case Import("env", "proc_exit", _) => + val (_, newCtx) = ctx.pop() + val code = Stack.popC(NumType(I32Type)) + Stack.popS(NumType(I32Type)) + info(s"Program exiting") + eval(rest, kont, mkont, trail)(newCtx) + case Import(m, f, _) => throw new Exception(s"Unknown import $m.$f at $funcIndex") + case _ => throw new Exception(s"Definition at $funcIndex is not callable") + } + } + + def evalTestOpC(op: TestOp, value: StagedConcreteNum): StagedConcreteNum = op match { + case Eqz(_) => value.isZero + } + + def evalTestOpS(op: TestOp, value: StagedSymbolicNum): StagedSymbolicNum = op match { + case Eqz(_) => value.isZero + } + + def evalUnaryOpC(op: UnaryOp, value: StagedConcreteNum): StagedConcreteNum = op match { + case Clz(_) => value.clz() + case Ctz(_) => value.ctz() + case Popcnt(_) => value.popcnt() + case _ => ??? + } + + def evalUnaryOpS(op: UnaryOp, value: StagedSymbolicNum, c: StagedConcreteNum): StagedSymbolicNum = { + val res = if (allConcrete(value)) { + c.toStagedSymbolicNum.s + } else { + (op match { + case Clz(_) => value.clz() + case Ctz(_) => value.ctz() + case Popcnt(_) => value.popcnt() + case _ => throw new Exception(s"Unknown unary operation $op") + }).s + } + StagedSymbolicNum(c.tipe, res) + } + + def evalBinOpC(op: BinOp, v1: StagedConcreteNum, v2: StagedConcreteNum): StagedConcreteNum = op match { + case Add(_) => v1 + v2 + case Mul(_) => v1 * v2 + case Sub(_) => v1 - v2 + case Shl(_) => v1 << v2 + // case ShrS(_) => v1 >> v2 // TODO: signed shift right + case ShrU(_) => v1 >> v2 + case And(_) => v1 & v2 + case DivS(_) => v1 divs v2 + case DivU(_) => v1 divu v2 + case Div(_) => v1 div v2 + case Xor(_) => v1 xor v2 + case _ => + throw new Exception(s"Unknown binary operation $op") + } + + def evalBinOpS(op: BinOp, v1: StagedSymbolicNum, v2: StagedSymbolicNum, c: StagedConcreteNum): StagedSymbolicNum = { + val res = if (allConcrete(v1, v2)) { + c.toStagedSymbolicNum.s + } else { + (op match { + case Add(_) => v1 + v2 + case Mul(_) => v1 * v2 + case Sub(_) => v1 - v2 + case Shl(_) => v1 << v2 + // case ShrS(_) => v1 >> v2 // TODO: signed shift right + case ShrU(_) => v1 >> v2 + case And(_) => v1 & v2 + case DivS(_) => v1 divs v2 + case DivU(_) => v1 divu v2 + case Div(_) => v1 div v2 + case Xor(_) => v1 xor v2 + case _ => + throw new Exception(s"Unknown binary operation $op") + }).s + } + StagedSymbolicNum(c.tipe, res) + } + + def evalRelOpC(op: RelOp, v1: StagedConcreteNum, v2: StagedConcreteNum): StagedConcreteNum = op match { + case Eq(_) => v1 numEq v2 + case Ne(_) => v1 numNe v2 + case LtS(_) => v1 < v2 + case LtU(_) => v1 ltu v2 + case GtS(_) => v1 > v2 + case GtU(_) => v1 gtu v2 + case LeS(_) => v1 <= v2 + case LeU(_) => v1 leu v2 + case GeS(_) => v1 >= v2 + case GeU(_) => v1 geu v2 + case Lt(_) => v1 lt v2 + case Le(_) => v1 le v2 + case Gt(_) => v1 gt v2 + case Ge(_) => v1 ge v2 + case _ => ??? + } + + def evalRelOpS(op: RelOp, v1: StagedSymbolicNum, v2: StagedSymbolicNum, c: StagedConcreteNum): StagedSymbolicNum = { + val res = if (allConcrete(v1, v2)) { + c.toStagedSymbolicNum.s + } else { + (op match { + case Eq(_) => v1 numEq v2 + case Ne(_) => v1 numNe v2 + case LtS(_) => v1 < v2 + case LtU(_) => v1 ltu v2 + case GtS(_) => v1 > v2 + case GtU(_) => v1 gtu v2 + case LeS(_) => v1 <= v2 + case LeU(_) => v1 leu v2 + case GeS(_) => v1 >= v2 + case GeU(_) => v1 geu v2 + case Lt(_) => v1 lt v2 + case Le(_) => v1 le v2 + case Gt(_) => v1 gt v2 + case Ge(_) => v1 ge v2 + case _ => throw new Exception(s"Unknown relational operation $op") + }).s + } + StagedSymbolicNum(c.tipe, res) + } + + def evalTop(mkont: Rep[MCont[Unit]], main: Option[String]): Rep[Unit] = { + Counter.reset() + val funBody: FuncBodyDef = main match { + case Some(func_name) => + module.defs.flatMap({ + case Export(`func_name`, ExportFunc(fid)) => + Predef.println(s"Now compiling start with function $main") + module.funcs(fid) match { + case FuncDef(_, body@FuncBodyDef(_,_,_,_)) => Some(body) + case _ => throw new Exception("Entry function has no concrete body") + } + case _ => None + }).head + case None => + val startIds = module.defs.flatMap { + case Start(id) => Some(id) + case _ => None + } + Predef.printf("module defs = %s", module.defs) + val startId = startIds.headOption.getOrElse { throw new Exception("No start function") } + module.funcs(startId) match { + case FuncDef(_, body@FuncBodyDef(_,_,_,_)) => body + case _ => + throw new Exception("Entry function has no concrete body") + } + } + val (instrs, locals) = (funBody.body, funBody.locals) + // resetStacks() // Don't manually reset the global states (like stack), manage them in the driver + initGlobals(module.globals) + initTable(module) + initMemory() + Frames.pushFrameC(locals) + Frames.pushFrameS(locals) + eval(instrs, (_: Context) => forwardKont, mkont, ((_: Context) => forwardKont)::Nil)(Context(Nil, locals)) + Frames.popFrameC(locals.size) + Frames.popFrameS(locals.size) + } + + def evalTop(main: Option[String], printRes: Boolean): Rep[Unit] = { + val haltK: Rep[Unit] => Rep[Unit] = (_) => { + info("Exiting the program...") + if (printRes) { + Stack.print() + } + ExploreTree.fillWithFinished() + "no-op".reflectCtrlWith[Unit]() + } + val temp: Rep[MCont[Unit]] = makeInitMCont(topFun(haltK)) + evalTop(temp, main) + } + + def runtimeAssert(b: Rep[Boolean]): Rep[Unit] = { + "assert-true".reflectCtrlWith[Unit](b) + } + + def runtimeSymAssert(s: StagedSymbolicNum): Rep[Unit] = { + "sym-assert-true".reflectCtrlWith[Unit](s.s) + } + + // stack operations + object Stack { + def shiftC(offset: Int, size: Int) = { + if (offset > 0) { + "stack-shift".reflectCtrlWith[Unit](offset, size) + } + } + + def shiftS(offset: Int, size: Int) = { + if (offset > 0) { + "sym-stack-shift".reflectCtrlWith[Unit](offset, size) + } + } + + def initialize(): Rep[Unit] = { + "stack-init".reflectCtrlWith[Unit]() + } + + def popC(ty: ValueType): StagedConcreteNum = { + StagedConcreteNum(ty, "stack-pop".reflectCtrlWith[Num]()) + } + + def popS(ty: ValueType): StagedSymbolicNum = { + StagedSymbolicNum(ty, "sym-stack-pop".reflectCtrlWith[SymVal]()) + } + + def peekC(ty: ValueType): StagedConcreteNum = { + StagedConcreteNum(ty, "stack-peek".reflectCtrlWith[Num]()) + } + + def peekS(ty: ValueType): StagedSymbolicNum = { + StagedSymbolicNum(ty, "sym-stack-peek".reflectCtrlWith[SymVal]()) + } + + def pushC(num: StagedConcreteNum) = "stack-push".reflectCtrlWith[Unit](num.i) + + def pushS(num: StagedSymbolicNum) = "sym-stack-push".reflectCtrlWith[Unit](num.s) + + def takeC(types: List[ValueType]): List[StagedConcreteNum] = types match { + case Nil => Nil + case t :: ts => + val v = popC(t) + val rest = takeC(ts) + v :: rest + } + + def takeS(types: List[ValueType]): List[StagedSymbolicNum] = types match { + case Nil => Nil + case t :: ts => + val v = popS(t) + val rest = takeS(ts) + v :: rest + } + + def print(): Rep[Unit] = { + "stack-print".reflectCtrlWith[Unit]() + } + + def size: Rep[Int] = { + "stack-size".reflectCtrlWith[Int]() + } + } + + object Frames { + def getC(i: Int)(implicit ctx: Context): StagedConcreteNum = { + // val offset = ctx.frameTypes.take(i).map(_.size).sum + StagedConcreteNum(ctx.frameTypes(i), "frame-get".reflectCtrlWith[Num](i)) + } + + def getS(i: Int)(implicit ctx: Context): StagedSymbolicNum = { + StagedSymbolicNum(ctx.frameTypes(i), "sym-frame-get".reflectCtrlWith[SymVal](i)) + } + + def setC(i: Int, v: StagedConcreteNum): Rep[Unit] = { + "frame-set".reflectCtrlWith[Unit](i, v.i) + } + + def setS(i: Int, s: StagedSymbolicNum): Rep[Unit] = { + "sym-frame-set".reflectCtrlWith[Unit](i, s.s) + } + + def pushFrameC(locals: List[ValueType]): Rep[Unit] = { + // Predef.println(s"[DEBUG] push frame: $locals") + val size = locals.size + "frame-push".reflectCtrlWith[Unit](size) + } + + def extendFrameC(size: Int): Rep[Unit] = { + if (size > 0) "frame-extend".reflectCtrlWith[Unit](size) + } + + def pushFrameS(locals: List[ValueType]): Rep[Unit] = { + // Predef.println(s"[DEBUG] push frame: $locals") + val size = locals.size + "sym-frame-push".reflectCtrlWith[Unit](size) + } + + def extendFrameS(size: Int): Rep[Unit] = { + if (size > 0) "sym-frame-extend".reflectCtrlWith[Unit](size) + } + + def popFrameC(size: Int): Rep[Unit] = { + "frame-pop".reflectCtrlWith[Unit](size) + } + + def popFrameS(size: Int): Rep[Unit] = { + "sym-frame-pop".reflectCtrlWith[Unit](size) + } + + def putAllC(args: List[StagedConcreteNum]): Rep[Unit] = { + for ((arg, i) <- args.view.reverse.zipWithIndex) { + Frames.setC(i, arg) + } + } + + def putAllS(args: List[StagedSymbolicNum]): Rep[Unit] = { + for ((arg, i) <- args.view.reverse.zipWithIndex) { + Frames.setS(i, arg) + } + } + } + + object Memory { + // TODO: why this is only one function, rather than `storeInC` and `storeInS`? + // TODO: what should the type of SymVal be? + def storeInt(base: Rep[Int], offset: Int, value: (Rep[Int], StagedSymbolicNum)): Rep[Unit] = { + "memory-store-int".reflectCtrlWith[Unit](base, offset, value._1) + "sym-store-int".reflectCtrlWith[Unit](base, offset, value._2.s) + } + + def loadIntC(base: Rep[Int], offset: Int): StagedConcreteNum = { + StagedConcreteNum(NumType(I32Type), "I32V".reflectCtrlWith[Num]("memory-load-int".reflectCtrlWith[Int](base, offset))) + } + + def loadIntS(base: Rep[Int], offset: Int): StagedSymbolicNum = { + StagedSymbolicNum(NumType(I32Type), "sym-load-int".reflectCtrlWith[SymVal](base, offset)) + } + + // Returns the previous memory size on success, or -1 if the memory cannot be grown. + def grow(delta: Rep[Int]): Rep[Int] = { + "memory-grow".reflectCtrlWith[Int](delta) + } + } + + def resetStacks(): Rep[Unit] = { + "reset-stacks".reflectCtrlWith[Unit]() + } + + def initGlobals(globals: List[RTGlobal]): Rep[Unit] = { + Globals.reserveSpace(globals.size) + for ((g, i) <- globals.view.zipWithIndex) { + val initValue = g.value match { + case n: Num => n + case _ => throw new RuntimeException("Non-numeric global value is not supported yet") + } + Globals.setC(i, toStagedNum(initValue)) + Globals.setS(i, toStagedSymbolicNum(initValue)) + } + } + + def initTable(module: ModuleInstance): Rep[Unit] = { + val haltK: Rep[Unit] => Rep[Unit] = (_) => { } + val mkont: Rep[MCont[Unit]] = makeInitMCont(topFun(haltK)) + for (definition <- module.defs) { + definition match { + case Elem(_, offset, funcIndices) => + eval(offset, (_: Context) => forwardKont, mkont, ((_: Context) => forwardKont)::Nil)(Context(Nil, Nil)) + val offsetC = Stack.popC(NumType(I32Type)) + Stack.popS(NumType(I32Type)) + Predef.println(s"funcIndices: $funcIndices") + for ((fidx, i) <- funcIndices.asInstanceOf[ElemListFunc].funcs.view.zipWithIndex) { + val FuncDef(_, FuncBodyDef(ty, _, bodyLocals, body)) = module.funcs(fidx) + val func = evalFunc(ty, body, fidx, ty.inps, bodyLocals) + "init-func-table".reflectCtrlWith[Unit](offsetC.i, i, func) + } + case _ => () + } + } + } + + def initMemory(): Rep[Unit] = { + for (definition <- module.defs) { + definition match { + case Data(_, offsetInstr, bytes) => + val haltK: Rep[Unit] => Rep[Unit] = (_) => { } + val mkont: Rep[MCont[Unit]] = makeInitMCont(topFun(haltK)) + eval(offsetInstr::Nil, (_: Context) => forwardKont, mkont, ((_: Context) => forwardKont)::Nil)(Context(Nil, Nil)) + val offsetC = Stack.popC(NumType(I32Type)) + Stack.popS(NumType(I32Type)) + Predef.printf("Initializing memory of %s\n", bytes) + "memory-initialize".reflectCtrlWith[Unit](offsetC.toInt, bytes) + case _ => () + } + } + } + + def allConcrete(syms: StagedSymbolicNum*): Rep[Boolean] = { + "allConcrete".reflectCtrlWith[Boolean](syms.map(_.s): _*) + } + + // call unreachable + def unreachable(): Rep[Unit] = { + "unreachable".reflectCtrlWith[Unit]() + } + + def info(xs: Rep[_]*): Rep[Unit] = { + "info".reflectCtrlWith[Unit](xs: _*) + } + + // runtime values + object Values { + def I32V(i: Rep[Int]): Rep[Num] = { + "I32V".reflectCtrlWith[Num](i) + } + + def I64V(i: Rep[Long]): Rep[Num] = { + "I64V".reflectCtrlWith[Num](i) + } + } + + // global read/write + object Globals { + def reserveSpace(size: Int): Rep[Unit] = { + "global-reserve".reflectCtrlWith[Unit](size) + "sym-global-reserve".reflectCtrlWith[Unit](size) + } + + def getC(i: Int): StagedConcreteNum = { + StagedConcreteNum(module.globals(i).ty.ty, "global-get".reflectCtrlWith[Num](i)) + } + + def getS(i: Int): StagedSymbolicNum = { + StagedSymbolicNum(module.globals(i).ty.ty, "sym-global-get".reflectCtrlWith[SymVal](i)) + } + + def setC(i: Int, v: StagedConcreteNum): Rep[Unit] = { + "global-set".reflectCtrlWith[Unit](i, v.i) + } + + def setS(i: Int, s: StagedSymbolicNum): Rep[Unit] = { + "sym-global-set".reflectCtrlWith[Unit](i, s.s) + } + } + + // Exploration tree, + object ExploreTree { + def fillWithIfElse(s: Rep[SymVal], id: Int): Rep[Unit] = { + "tree-fill-if-else".reflectCtrlWith[Unit](s, id) + } + + def fillWithCallIndirect(s: Rep[SymVal], id: Int): Rep[Unit] = { + "tree-fill-call-indirect".reflectCtrlWith[Unit](s, id) + } + + def fillWithNotToExplore(): Rep[Unit] = { + "tree-fill-not-to-explore".reflectCtrlWith[Unit]() + } + + def fillWithFinished(): Rep[Unit] = { + "tree-fill-finished".reflectCtrlWith[Unit]() + } + + def moveCursor(branch: Boolean, control: Rep[Control]): Rep[Unit] = { + // when moving cursor from to an unexplored node, we need to change the reuse state + "tree-move-cursor".reflectCtrlWith[Unit](branch, control) + } + + def moveCursor(branch: Boolean): Rep[Unit] = { + // when moving cursor from to an unexplored node, we need to change the reuse state + "tree-move-cursor-no-control".reflectCtrlWith[Unit](branch) + } + + def moveCursor(index: Rep[Int]): Rep[Unit] = { + "tree-move-cursor-call-indirect-index".reflectCtrlWith[Unit](index) + } + + def print(): Rep[Unit] = { + "tree-print".reflectCtrlWith[Unit]() + } + + def dumpGraphiviz(filePath: String): Rep[Unit] = { + "tree-dump-graphviz".reflectCtrlWith[Unit](filePath) + } + } + + object SymEnv { + def read(sym: Rep[SymVal]): Rep[Num] = { + "sym-env-read".reflectCtrlWith[Num](sym) + } + } + + // runtime Num type + implicit class StagedConcreteNumOps(num: StagedConcreteNum) { + + def makeSymbolic(ty: ValueType): StagedSymbolicNum = num.tipe match { + case NumType(I32Type) => + StagedSymbolicNum(NumType(I32Type), "make-symbolic-concrete".reflectCtrlWith[SymVal](num.toInt)) + } + + def toInt: Rep[Int] = "num-to-int".reflectCtrlWith[Int](num.i) + + def isZero(): StagedConcreteNum = num.tipe match { + case NumType(I32Type) => + StagedConcreteNum(NumType(I32Type), Values.I32V("is-zero".reflectCtrlWith[Int](num.toInt))) + } + + def clz(): StagedConcreteNum = num.tipe match { + case NumType(I32Type) => StagedConcreteNum(NumType(I32Type), "clz".reflectCtrlWith[Num](num.i)) + case NumType(I64Type) => StagedConcreteNum(NumType(I64Type), "clz".reflectCtrlWith[Num](num.i)) + } + + def ctz(): StagedConcreteNum = num.tipe match { + case NumType(I32Type) => StagedConcreteNum(NumType(I32Type), "ctz".reflectCtrlWith[Num](num.i)) + case NumType(I64Type) => StagedConcreteNum(NumType(I64Type), "ctz".reflectCtrlWith[Num](num.i)) + } + + def popcnt(): StagedConcreteNum = num.tipe match { + case NumType(I32Type) => StagedConcreteNum(NumType(I32Type), "popcnt".reflectCtrlWith[Num](num.i)) + case NumType(I64Type) => StagedConcreteNum(NumType(I64Type), "popcnt".reflectCtrlWith[Num](num.i)) + } + + def +(rhs: StagedConcreteNum): StagedConcreteNum = (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-add".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-add".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-add".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-add".reflectCtrlWith[Num](num.i, rhs.i)) + } + + def -(rhs: StagedConcreteNum): StagedConcreteNum = (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-sub".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-sub".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-sub".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-sub".reflectCtrlWith[Num](num.i, rhs.i)) + } + + def *(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-mul".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-mul".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-mul".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-mul".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def divs(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-div".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-div".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def divu(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-div-u".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-div-u".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def div(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-div".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-div".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def xor(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-xor".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def <<(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-shl".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-shl".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-shl".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-shl".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def >>(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-shr".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-shr".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-shr".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-shr".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def &(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-binary-and".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I64Type), "i64-binary-and".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(F32Type), "f32-binary-and".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(F64Type), "f64-binary-and".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def numEq(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-eq".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-eq".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def numNe(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-ne".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-ne".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def <(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-lts".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-lts".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def ltu(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-ltu".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-ltu".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def >(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-gt".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-gt".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def gtu(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-gtu".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-gtu".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def <=(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-les".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-les".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def leu(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-leu".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-leu".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def >=(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-ges".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-ges".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def geu(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedConcreteNum(NumType(I32Type), "i32-relation-geu".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(I64Type), NumType(I64Type)) => + StagedConcreteNum(NumType(I32Type), "i64-relation-geu".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def lt(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(I32Type), "f32-relation-lt".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(I32Type), "f64-relation-lt".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def le(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(I32Type), "f32-relation-le".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(I32Type), "f64-relation-le".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def gt(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(I32Type), "f32-relation-gt".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(I32Type), "f64-relation-gt".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + + def ge(rhs: StagedConcreteNum): StagedConcreteNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedConcreteNum(NumType(I32Type), "f32-relation-ge".reflectCtrlWith[Num](num.i, rhs.i)) + case (NumType(F64Type), NumType(F64Type)) => + StagedConcreteNum(NumType(I32Type), "f64-relation-ge".reflectCtrlWith[Num](num.i, rhs.i)) + } + } + } + + implicit class StagedSymbolicNumOps(num: StagedSymbolicNum) { + def makeSymbolic(ty: ValueType): StagedSymbolicNum = num.tipe match { + case NumType(I32Type) => StagedSymbolicNum(NumType(I32Type), "make-symbolic".reflectCtrlWith[SymVal](num.s)) + case _ => throw new RuntimeException("Symbol index must be an i32") + } + + def isZero(): StagedSymbolicNum = num.tipe match { + case NumType(I32Type) => StagedSymbolicNum(NumType(I32Type), "sym-is-zero".reflectCtrlWith[SymVal](num.s)) + } + + def clz(): StagedSymbolicNum = num.tipe match { + case NumType(I32Type) => StagedSymbolicNum(NumType(I32Type), "sym-clz".reflectCtrlWith[SymVal](num.s)) + case NumType(I64Type) => StagedSymbolicNum(NumType(I64Type), "sym-clz".reflectCtrlWith[SymVal](num.s)) + } + + def ctz(): StagedSymbolicNum = num.tipe match { + case NumType(I32Type) => StagedSymbolicNum(NumType(I32Type), "sym-ctz".reflectCtrlWith[SymVal](num.s)) + case NumType(I64Type) => StagedSymbolicNum(NumType(I64Type), "sym-ctz".reflectCtrlWith[SymVal](num.s)) + } + + def popcnt(): StagedSymbolicNum = num.tipe match { + case NumType(I32Type) => StagedSymbolicNum(NumType(I32Type), "sym-popcnt".reflectCtrlWith[SymVal](num.s)) + case NumType(I64Type) => StagedSymbolicNum(NumType(I64Type), "sym-popcnt".reflectCtrlWith[SymVal](num.s)) + } + + def +(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-add".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-add".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-add".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-add".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def -(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-sub".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-sub".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-sub".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-sub".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def *(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-mul".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-mul".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-mul".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-mul".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def /(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def divs(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def divu(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-div-u".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-div-u".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def div(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-div".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def xor(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-xor".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def <<(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-shl".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-shl".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-shl".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-shl".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def >>(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-shr".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-shr".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-shr".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-shr".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def &(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-binary-and".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I64Type), "sym-binary-and".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(F32Type), "sym-binary-and".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(F64Type), "sym-binary-and".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def numEq(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-eq".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-eq".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def numNe(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-ne".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-ne".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def <(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-lts".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-lts".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def ltu(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "relation-ltu".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "relation-ltu".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def >(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-gt".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-gt".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def gtu(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-gtu".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-gtu".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def <=(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-les".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-les".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def leu(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-leu".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-leu".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def >=(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-ges".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-ges".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def geu(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(I32Type), NumType(I32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-geu".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(I64Type), NumType(I64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-geu".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def lt(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-lt".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-lt".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def le(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-le".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-le".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def gt(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-gt".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-gt".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + + def ge(rhs: StagedSymbolicNum): StagedSymbolicNum = { + (num.tipe, rhs.tipe) match { + case (NumType(F32Type), NumType(F32Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-ge".reflectCtrlWith[SymVal](num.s, rhs.s)) + case (NumType(F64Type), NumType(F64Type)) => + StagedSymbolicNum(NumType(I32Type), "sym-relation-ge".reflectCtrlWith[SymVal](num.s, rhs.s)) + } + } + } + implicit class SymbolicOps(s: Rep[SymVal]) { + def not(): Rep[SymVal] = { + "sym-not".reflectCtrlWith(s) + } + } +} + +trait StagedWasmCppGen extends CGenBase with CppSAICodeGenBase { + // clear include path and headers by first + includePaths.clear() + headers.clear() + + registerHeader("headers", "\"wasm.hpp\"") + registerHeader("") + registerHeader("") + registerHeader("") + registerHeader("") + + override def mayInline(n: Node): Boolean = n match { + case Node(_, "stack-pop", _, _) + | Node(_, "stack-peek", _, _) + | Node(_, "sym-stack-pop", _, _) + => false + case _ => super.mayInline(n) + } + + override def remap(m: Manifest[_]): String = { + if (m.toString.endsWith("Num")) "Num" + else if (m.toString.endsWith("Frame")) "Frame" + else if (m.toString.endsWith("Stack")) "Stack" + else if (m.toString.endsWith("Global")) "Global" + else if (m.toString.endsWith("I32V")) "I32V" + else if (m.toString.endsWith("I64V")) "I64V" + else if (m.toString.endsWith("SymVal")) "SymVal" + else if (m.toString.endsWith("Snapshot")) "Snapshot_t" + else if (m.toString.endsWith("MCont[Unit]")) "MCont_t" + else if (m.toString.endsWith("Func")) "Func_t" + else super.remap(m) + } + + override def traverse(n: Node): Unit = n match { + case Node(_, "stack-push", List(value), _) => + emit("Stack.push("); shallow(value); emit(");\n") + case Node(_, "sym-stack-push", List(s_value), _) => + emit("SymStack.push("); shallow(s_value); emit(");\n") + case Node(_, "stack-drop", List(n), _) => + emit("Stack.drop("); shallow(n); emit(");\n") + case Node(_, "stack-init", _, _) => + emit("Stack.initialize();\n") + case Node(_, "stack-print", _, _) => + emit("Stack.print();\n") + case Node(_, "frame-push", List(i), _) => + emit("Frames.pushFrame("); shallow(i); emit(");\n") + case Node(_, "sym-frame-push", List(i), _) => + emit("SymFrames.pushFrame("); shallow(i); emit(");\n") + case Node(_, "frame-pop", List(i), _) => + emit("Frames.popFrame("); shallow(i); emit(");\n") + case Node(_, "frame-set", List(i, value), _) => + emit("Frames.set("); shallow(i); emit(", "); shallow(value); emit(");\n") + case Node(_, "sym-frame-set", List(i, s_value), _) => + emit("SymFrames.set("); shallow(i); emit(", "); shallow(s_value); emit(");\n") + // Note: The following code is copied from the traverse of CppBackend.scala, try to avoid duplicated code + case n @ Node(f, "λ", (b: LMSBlock)::LMSConst(0)::rest, _) => + // TODO: Is a leading block followed by 0 a hint for top function? + super.traverse(n) + case n @ Node(f, "λ", (b: LMSBlock)::rest, _) => + val retType = remap(typeBlockRes(b.res)) + val argTypes = b.in.map(a => remap(typeMap(a))).mkString(", ") + emitln(s"std::function<$retType(${argTypes})> ${quote(f)};") + emit(quote(f)); emit(" = ") + // We need to capture by value here, because we want to save a function in + // snapshot, and use the function later, while the local variables have + // been released. + quoteTypedBlock(b, false, true, capture = "=") + emitln(";") + case _ => super.traverse(n) + } + + override def shallow(n: Node): Unit = n match { + case Node(_, "reset-stacks", _, _) => + emit("reset_stacks()") + case Node(_, "frame-get", List(i), _) => + emit("Frames.get("); shallow(i); emit(")") + case Node(_, "sym-frame-get", List(i), _) => + emit("SymFrames.get("); shallow(i); emit(")") + case Node(_, "stack-drop", List(n), _) => + emit("Stack.drop("); shallow(n); emit(")") + case Node(_, "stack-push", List(value), _) => + emit("Stack.push("); shallow(value); emit(")") + case Node(_, "stack-shift", List(offset, size), _) => + emit("Stack.shift("); shallow(offset); emit(", "); shallow(size); emit(")") + case Node(_, "sym-stack-shift", List(offset, size), _) => + emit("SymStack.shift("); shallow(offset); emit(", "); shallow(size); emit(")") + case Node(_, "stack-pop", _, _) => + emit("Stack.pop()") + case Node(_, "sym-stack-pop", _, _) => + emit("SymStack.pop()") + case Node(_, "frame-extend", List(i), _) => + emit("Frames.extendFrame("); shallow(i); emit(")") + case Node(_, "sym-frame-extend", List(i), _) => + emit("SymFrames.extendFrame("); shallow(i); emit(")") + case Node(_, "control-make", List(k, mk), _) => + emit("makeControl("); shallow(k); emit(", "); shallow(mk); emit(")") + case Node(_, "frame-pop", List(i), _) => + emit("Frames.popFrame("); shallow(i); emit(")") + case Node(_, "sym-frame-pop", List(i), _) => + emit("SymFrames.popFrame("); shallow(i); emit(")") + case Node(_, "stack-peek", _, _) => + emit("Stack.peek()") + case Node(_, "sym-stack-peek", _, _) => + emit("SymStack.peek()") + case Node(_, "stack-take", List(n), _) => + emit("Stack.take("); shallow(n); emit(")") + case Node(_, "slice-reverse", List(slice), _) => + shallow(slice); emit(".reverse") + case Node(_, "memory-store-int", List(base, offset, value), _) => + emit("Memory.storeInt("); shallow(base); emit(", "); shallow(offset); emit(", "); shallow(value); emit(")") + case Node(_, "memory-load-int", List(base, offset), _) => + emit("Memory.loadInt("); shallow(base); emit(", "); shallow(offset); emit(")") + case Node(_, "memory-grow", List(delta), _) => + emit("Memory.grow("); shallow(delta); emit(")") + case Node(_, "stack-size", _, _) => + emit("Stack.size()") + // Symbolic Memory + case Node(_, "sym-store-int", List(base, offset, s_value), _) => + emit("SymMemory.storeSym("); shallow(base); emit(", "); shallow(offset); emit(", "); shallow(s_value); emit(")") + case Node(_, "sym-load-int", List(base, offset), _) => + emit("SymMemory.loadSym("); shallow(base); emit(", "); shallow(offset); emit(")") + case Node(_, "sym-memory-grow", List(delta), _) => + emit("SymMemory.grow("); shallow(delta); emit(")") + // Globals + case Node(_, "global-get", List(i), _) => + emit("Globals.get("); shallow(i); emit(")") + case Node(_, "sym-global-get", List(i), _) => + emit("SymGlobals.get("); shallow(i); emit(")") + case Node(_, "global-set", List(i, value), _) => + emit("Globals.set("); shallow(i); emit(", "); shallow(value); emit(")") + case Node(_, "sym-global-set", List(i, s_value), _) => + emit("SymGlobals.set("); shallow(i); emit(", "); shallow(s_value); emit(")") + case Node(_, "global-reserve", List(i), _) => + emit("Globals.pushFrame("); shallow(i); emit(")") + case Node(_, "sym-global-reserve", List(i), _) => + emit("SymGlobals.pushFrame("); shallow(i); emit(")") + case Node(_, "is-zero", List(num), _) => + emit("(0 == "); shallow(num); emit(")") + case Node(_, "sym-is-zero", List(s_num), _) => + shallow(s_num); emit(".is_zero()") + case Node(_, "i32-binary-add", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_add("); shallow(rhs); emit(")") + case Node(_, "i32-binary-sub", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_sub("); shallow(rhs); emit(")") + case Node(_, "i32-binary-mul", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_mul("); shallow(rhs); emit(")") + case Node(_, "i32-binary-div", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_div_s("); shallow(rhs); emit(")") + case Node(_, "i32-binary-shl", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_shl("); shallow(rhs); emit(")") + case Node(_, "i32-binary-shr", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_shr_s("); shallow(rhs); emit(")") + case Node(_, "i32-binary-and", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_and("); shallow(rhs); emit(")") + case Node(_, "i32-relation-eq", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_eq("); shallow(rhs); emit(")") + case Node(_, "i32-relation-ne", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_ne("); shallow(rhs); emit(")") + case Node(_, "i32-relation-lts", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_lt_s("); shallow(rhs); emit(")") + case Node(_, "i32-relation-ltu", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_lt_u("); shallow(rhs); emit(")") + case Node(_, "i32-relation-gt", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_gt_s("); shallow(rhs); emit(")") + case Node(_, "i32-relation-gtu", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_gt_u("); shallow(rhs); emit(")") + case Node(_, "i32-relation-les", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_le_s("); shallow(rhs); emit(")") + case Node(_, "i32-relation-leu", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_le_u("); shallow(rhs); emit(")") + case Node(_, "i32-relation-ges", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_ge_s("); shallow(rhs); emit(")") + case Node(_, "i32-relation-geu", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_ge_u("); shallow(rhs); emit(")") + case Node(_, "i32-binary-xor", List(lhs, rhs), _) => + shallow(lhs); emit(".i32_xor("); shallow(rhs); emit(")") + case Node(_, "f32-binary-add", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_add("); shallow(rhs); emit(")") + case Node(_, "f32-binary-sub", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_sub("); shallow(rhs); emit(")") + case Node(_, "f32-binary-mul", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_mul("); shallow(rhs); emit(")") + case Node(_, "f32-binary-div", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_div("); shallow(rhs); emit(")") + case Node(_, "f32-relation-gt", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_gt("); shallow(rhs); emit(")") + case Node(_, "f32-relation-lt", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_lt("); shallow(rhs); emit(")") + case Node(_, "f32-relation-le", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_le("); shallow(rhs); emit(")") + case Node(_, "f32-relation-ge", List(lhs, rhs), _) => + shallow(lhs); emit(".f32_ge("); shallow(rhs); emit(")") + case Node(_, "sym-binary-add", List(lhs, rhs), _) => + shallow(lhs); emit(".add("); shallow(rhs); emit(")") + case Node(_, "sym-binary-sub", List(lhs, rhs), _) => + shallow(lhs); emit(".minus("); shallow(rhs); emit(")") + case Node(_, "sym-binary-mul", List(lhs, rhs), _) => + shallow(lhs); emit(".mul("); shallow(rhs); emit(")") + case Node(_, "sym-binary-div", List(lhs, rhs), _) => + shallow(lhs); emit(".div("); shallow(rhs); emit(")") + case Node(_, "sym-binary-and", List(lhs, rhs), _) => + shallow(lhs); emit(".bitwise_and("); shallow(rhs); emit(")") + case Node(_, "sym-relation-les", List(lhs, rhs), _) => + shallow(lhs); emit(".le("); shallow(rhs); emit(")") + case Node(_, "sym-relation-leu", List(lhs, rhs), _) => + shallow(lhs); emit(".leu("); shallow(rhs); emit(")") + case Node(_, "sym-relation-lts", List(lhs, rhs), _) => + shallow(lhs); emit(".lt("); shallow(rhs); emit(")") + case Node(_, "sym-binary-xor", List(lhs, rhs), _) => + shallow(lhs); emit(".bitwise_xor("); shallow(rhs); emit(")") + case Node(_, "relation-ltu", List(lhs, rhs), _) => + shallow(lhs); emit(".ltu("); shallow(rhs); emit(")") + case Node(_, "sym-relation-ges", List(lhs, rhs), _) => + shallow(lhs); emit(".ge("); shallow(rhs); emit(")") + case Node(_, "sym-relation-geu", List(lhs, rhs), _) => + shallow(lhs); emit(".geu("); shallow(rhs); emit(")") + case Node(_, "sym-relation-eq", List(lhs, rhs), _) => + shallow(lhs); emit(".eq("); shallow(rhs); emit(")") + case Node(_, "sym-relation-ne", List(lhs, rhs), _) => + shallow(lhs); emit(".neq("); shallow(rhs); emit(")") + case Node(_, "sym-relation-gt", List(lhs, rhs), _) => + shallow(lhs); emit(".gt("); shallow(rhs); emit(")") + case Node(_, "sym-relation-gtu", List(lhs, rhs), _) => + shallow(lhs); emit(".gtu("); shallow(rhs); emit(")") + case Node(_, "sym-binary-shr", List(lhs, rhs), _) => + shallow(lhs); emit(".shr("); shallow(rhs); emit(")") + case Node(_, "num-to-int", List(num), _) => + shallow(num); emit(".toInt()") + case Node(_, "make-symbolic", List(num), _) => + shallow(num); emit(".makeSymbolic()") + case Node(_, "make-symbolic-concrete", List(num), _) => + emit("make_symbolic("); shallow(num); emit(")") + case Node(_, "sym-env-read", List(sym), _) => + emit("SymEnv.read("); shallow(sym); emit(")") + case Node(_, "assert-true", List(cond), _) => + emit("GENSYM_ASSERT("); shallow(cond); emit(")") + case Node(_, "sym-assert-true", List(s_cond), _) => + emit("GENSYM_SYM_ASSERT("); shallow(s_cond); emit(")") + case Node(_, "tree-fill-if-else", List(sym, id), _) => + emit("ExploreTree.fillIfElseNode("); shallow(sym); emit(", "); emit(id.toString); emit(")") + case Node(_, "tree-fill-not-to-explore", List(), _) => + emit("ExploreTree.fillNotToExploredNode()") + case Node(_, "tree-fill-finished", List(), _) => + emit("ExploreTree.fillFinishedNode()") + case Node(_, "tree-move-cursor", List(b, snapshot), _) => + emit("ExploreTree.moveCursor("); shallow(b); emit(", "); shallow(snapshot); emit(")") + case Node(_, "tree-move-cursor-no-control", List(b), _) => + emit("ExploreTree.moveCursorNoControl("); shallow(b); emit(")") + case Node(_, "add-instr-cost", List(n), _) => + emit("CostManager.add_instr_cost("); shallow(n); emit(")") + case Node(_, "tree-print", List(), _) => + emit("ExploreTree.print()") + case Node(_, "tree-dump-graphviz", List(f), _) => + emit("ExploreTree.dump_graphviz("); shallow(f); emit(")") + case Node(_, "sym-not", List(s), _) => + shallow(s); emit(".negate()") + case Node(_, "make-init-mcont", List(haltK), _) => + emit("MCont_t("); shallow(haltK); emit(")") + case Node(_, "mcont-prepend", List(mkont, kont), _) => + emit("prependCont("); shallow(kont); emit(", "); shallow(mkont); emit(")") + case Node(_, "mcont-enter", List(mkont), _) => + shallow(mkont); emit(".enter()") + case Node(_, "init-func-table", List(offset, i, func), _) => + emit("FuncTable.set("); shallow(offset); emit(", "); shallow(i); emit(", "); shallow(func); emit(")") + case Node(_, "tree-fill-call-indirect", List(s, id), _) => + emit("ExploreTree.fillCallIndirectNode("); shallow(s); emit(", "); emit(id.toString); emit(")") + case Node(_, "invoke-func-with-mcont", List(f, mkont), _) => + shallow(f); emit("("); shallow(mkont); emit(")") + case Node(_, "read-func-table", List(funcIndex), _) => + emit("FuncTable.read("); shallow(funcIndex); emit(")") + case Node(_, "tree-move-cursor-call-indirect-index", List(index), _) => + emit("ExploreTree.moveCursorIndirect("); shallow(index); emit(")") + case Node(_, "memory-initialize", List(offset, str), _) => + emit("memoryInitialize("); shallow(offset); emit(", "); shallow(str); emit(")") + case Node(_, "dummy", _, _) => emit("std::monostate()") + case Node(_, "dummy-op", _, _) => emit("std::monostate()") + case Node(_, "no-op", _, _) => + emit("std::monostate()") + case _ => super.shallow(n) + } + + override def registerTopLevelFunction(id: String, streamId: String = "general")(f: => Unit) = + if (!registeredFunctions(id)) { + //if (ongoingFun(streamId)) ??? + //ongoingFun += streamId + registeredFunctions += id + withStream(functionsStreams.getOrElseUpdate(id, { + val functionsStream = new java.io.ByteArrayOutputStream() + val functionsWriter = new java.io.PrintStream(functionsStream) + (functionsWriter, functionsStream) + })._1)(f) + //ongoingFun -= streamId + } else { + // If a function is registered, don't re-register it. + // withStream(functionsStreams(id)._1)(f) + } + + override def emitAll(g: Graph, name: String)(m1: Manifest[_], m2: Manifest[_]): Unit = { + val ng = init(g) + emitHeaders(stream) + emitln(""" + |/***************************************** + |Emitting Generated Code + |*******************************************/ + """.stripMargin) + val src = run(name, ng) + emitFunctionDecls(stream) + emitDatastructures(stream) + emitFunctions(stream) + emit(src) + emitln(s""" + |/***************************************** + |End of Generated Code + |*******************************************/ + |int main(int argc, char *argv[]) { + | start_concolic_execution_with(Snippet, ${Counter.currentId}); + | return 0; + |}""".stripMargin) + } +} + +trait WasmToCppCompilerDriver[A, B] extends CppSAIDriver[A, B] with StagedWasmEvaluator { q => + override val codegen = new StagedWasmCppGen { + val IR: q.type = q + import IR._ + } +} + +object WasmToCppCompiler { + case class GeneratedCpp(source: String, headerFolders: List[String]) + + def compile(moduleInst: ModuleInstance, main: Option[String], printRes: Boolean): GeneratedCpp = { + println(s"Now compiling wasm module with entry function $main") + val driver = new WasmToCppCompilerDriver[Unit, Unit] { + def module: ModuleInstance = moduleInst + def snippet(x: Rep[Unit]): Rep[Unit] = { + evalTop(main, printRes) + } + } + GeneratedCpp(driver.code, driver.codegen.includePaths.toList) + } + + def compileToExe(moduleInst: ModuleInstance, + main: Option[String], + outputCpp: String, + outputExe: String, + printRes: Boolean, + optimizeLevel: Int, + macros: String*): Unit = { + val generated = compile(moduleInst, main, printRes) + val code = generated.source + + val writer = new java.io.PrintWriter(new java.io.File(outputCpp)) + try { + writer.write(code) + } finally { + writer.close() + } + + import sys.process._ + val includeFlags = generated.headerFolders.map(f => s"-I$f").mkString(" ") + val macroFlags = macros.map(m => s"-D$m").mkString(" ") + val command = s"g++ -std=c++17 $outputCpp -o $outputExe -O$optimizeLevel -g -l z3 " + includeFlags + " " + macroFlags + if (command.! != 0) { + throw new RuntimeException(s"Compilation failed for $outputCpp") + } + } + +} + + diff --git a/src/main/scala/wasm/StagedMiniWasm.scala b/src/main/scala/wasm/StagedMiniWasm.scala index 2e22e7a71..ea9dc9c6f 100644 --- a/src/main/scala/wasm/StagedMiniWasm.scala +++ b/src/main/scala/wasm/StagedMiniWasm.scala @@ -1,4 +1,4 @@ -package gensym.wasm.miniwasm +package gensym.wasm.stagedminiwasm import scala.collection.mutable.{ArrayBuffer, HashMap} @@ -12,6 +12,7 @@ import lms.core.Graph import gensym.wasm.ast._ import gensym.wasm.ast.{Const => WasmConst, Block => WasmBlock} +import gensym.wasm.miniwasm.ModuleInstance import gensym.lmsx.{SAIDriver, StringOps, SAIOps, SAICodeGenBase, CppSAIDriver, CppSAICodeGenBase} @virtualize @@ -433,10 +434,10 @@ trait StagedWasmEvaluator extends SAIOps { def push(v: StagedNum)(implicit ctx: Context): Context = { v match { - case I32(v) => NumType(I32Type); "stack-push".reflectCtrlWith[Unit](v) - case I64(v) => NumType(I64Type); "stack-push".reflectCtrlWith[Unit](v) - case F32(v) => NumType(F32Type); "stack-push".reflectCtrlWith[Unit](v) - case F64(v) => NumType(F64Type); "stack-push".reflectCtrlWith[Unit](v) + case I32(v) => "stack-push".reflectCtrlWith[Unit](v) + case I64(v) => "stack-push".reflectCtrlWith[Unit](v) + case F32(v) => "stack-push".reflectCtrlWith[Unit](v) + case F64(v) => "stack-push".reflectCtrlWith[Unit](v) } ctx.push(v.tipe) } diff --git a/src/test/scala/genwasym/TestBenchmarkBtree.scala b/src/test/scala/genwasym/TestBenchmarkBtree.scala new file mode 100644 index 000000000..8e9bc0c29 --- /dev/null +++ b/src/test/scala/genwasym/TestBenchmarkBtree.scala @@ -0,0 +1,42 @@ +package gensym.wasm + +import org.scalatest.FunSuite + +import lms.core.stub.Adapter + +import gensym.wasm.miniwasm.{ModuleInstance} +import gensym.wasm.parser._ +import gensym.wasm.stagedconcolicminiwasm._ + +// This 'test file' is not intended to test functionality, but to generate compiled code for btree benchmarks +class TestBenchmarkBtree extends FunSuite { + def compileToCpp(filename: String, + main: Option[String] = None) = { + import sys.process._ + + println(s"Compiling $filename to C++") + val moduleInst = ModuleInstance(Parser.parseFile(filename)) + val cppFile = s"$filename.cpp" + val generated = WasmToCppCompiler.compile(moduleInst, main, false) + + val code = generated.source + val writer = new java.io.PrintWriter(new java.io.File(cppFile)) + try { + writer.write(code) + } finally { + writer.close() + } + } + + def compileDirToCpp(dir: String, + main: Option[String] = None) = { + import java.io.File + val d = new File(dir) + d.listFiles().filter(_.getName.endsWith(".wat")).foreach { file => + compileToCpp(file.getAbsolutePath, main) + } + } + + test("compile-btree-benchmarks") { compileDirToCpp("./benchmarks/pldi2026/btree/", Some("main")) } + +} diff --git a/src/test/scala/genwasym/TestStagedConcolicEval.scala b/src/test/scala/genwasym/TestStagedConcolicEval.scala new file mode 100644 index 000000000..2a243825f --- /dev/null +++ b/src/test/scala/genwasym/TestStagedConcolicEval.scala @@ -0,0 +1,205 @@ +package gensym.wasm + +import org.scalatest.FunSuite + +import lms.core.stub.Adapter + +import gensym.wasm.miniwasm.{ModuleInstance} +import gensym.wasm.parser._ +import gensym.wasm.stagedconcolicminiwasm._ + +class TestStagedConcolicEval extends FunSuite { + def testFileConcolicCpp(filename: String, + main: Option[String] = None, + exitByCoverage: Boolean = false) = { + import sys.process._ + + + val moduleInst = ModuleInstance(Parser.parseFile(filename)) + val cppFile = s"$filename.cpp" + val exploreTreeFile = { + // Do concolic execution with snapshot reuse + val exe = s"$cppFile.exe" + val exploreTreeFile = s"$filename.tree.dot" + WasmToCppCompiler.compileToExe(moduleInst, main, cppFile, exe, true, optimizeLevel=0, if (exitByCoverage) "BY_COVERAGE" else "EARLY_EXIT") + println(s"Running compiled concolic execution with snapshot reuse: $exe") + val result = Process(s"./$exe", None, "TREE_FILE" -> exploreTreeFile).!! + println(result) + exploreTreeFile + } + val exploreTreeFileNoReuse = { + // Do concolic execution without snapshot reuse + val exe = s"$cppFile.noreuse.exe" + val exploreTreeFile = s"$filename.noreuse.tree.dot" + WasmToCppCompiler.compileToExe(moduleInst, main, cppFile, exe, false, optimizeLevel=0, if (exitByCoverage) "BY_COVERAGE" else "EARLY_EXIT") + println(s"Running compiled concolic execution without snapshot reuse: $exe") + val result = Process(s"./$exe", None, "TREE_FILE" -> exploreTreeFile).!! + println(result) + exploreTreeFile + } + val exploreTreeFileImm = { + // Do concolic execution with immutable data structure and snapshot reuse + val exe = s"$cppFile.imm.exe" + val exploreTreeFile = s"$filename.imm.tree.dot" + WasmToCppCompiler.compileToExe(moduleInst, main, cppFile, exe, true, optimizeLevel=0, if (exitByCoverage) "BY_COVERAGE" else "EARLY_EXIT", "USE_IMM") + println(s"Running compiled concolic execution with immutable data structure and snapshot reuse: $exe") + val result = Process(s"./$exe", None, "TREE_FILE" -> exploreTreeFile).!! + println(result) + exploreTreeFile + } + // The explore tree generated by two executions should be same + import java.nio.file.Files + assert( + Files.readAllBytes(java.nio.file.Paths.get(exploreTreeFile)) + sameElements Files.readAllBytes(java.nio.file.Paths.get(exploreTreeFileNoReuse)), + s"Explore trees $exploreTreeFile and $exploreTreeFileNoReuse are different!" + ) + assert( + Files.readAllBytes(java.nio.file.Paths.get(exploreTreeFile)) + sameElements Files.readAllBytes(java.nio.file.Paths.get(exploreTreeFileImm)), + s"Explore trees $exploreTreeFile and $exploreTreeFileImm are different!" + ) + } + + // only test concrete execution and its result + def testFileConcreteCpp(filename: String, main: Option[String] = None, expect: Option[List[Float]] = None) = { + val moduleInst = ModuleInstance(Parser.parseFile(filename)) + val cppFile = s"$filename.cpp" + val exe = s"$cppFile.exe" + WasmToCppCompiler.compileToExe(moduleInst, main, cppFile, exe, true, optimizeLevel=0, "NO_INFO", "RUN_ONCE", "USE_IMM") + + import sys.process._ + val result = s"./$exe".!! + println(result) + + expect.map(vs => { + val stackValues = { + val startMarker = "Stack contents: \n" + val endMarker = "End of Stack contents" + val start = result.indexOf(startMarker) + val end = if (start >= 0) result.indexOf(endMarker, start + startMarker.length) else -1 + require(start >= 0 && end >= 0, s"Could not find markers '$startMarker' and '$endMarker' in output") + result.substring(start + startMarker.length, end).trim + .split("\n") + .map(_.toFloat) + .toList + } + assert(vs == stackValues) + }) + } + + test("ack-cpp-concolic") { testFileConcolicCpp("./benchmarks/wasm/ack.wat", Some("real_main")) } + + test("bug-finding-concolic") { + testFileConcolicCpp("./benchmarks/wasm/branch-strip-buggy.wat", Some("real_main")) + } + + test("brtable-bug-finding-concolic") { + testFileConcolicCpp("./benchmarks/wasm/staged/brtable_concolic.wat") + } + + test("bug-finding-cov-concolic") { + testFileConcolicCpp("./benchmarks/wasm/branch-strip-buggy.wat", Some("real_main"), exitByCoverage=true) + } + + test("brtable-bug-finding-cov-concolic") { + testFileConcolicCpp("./benchmarks/wasm/staged/brtable_concolic.wat", exitByCoverage=true) + } + + test("simple-global-bug-finding-cov-concolic") { + testFileConcolicCpp("./benchmarks/wasm/staged/simple_global.wat", Some("real_main"), exitByCoverage=true) + } + + test("mem-sym-concolic") { + testFileConcolicCpp("./benchmarks/wasm/mem-sym.wat", None, exitByCoverage=true) + } + + test("mem-sym-extract-concolic") { + testFileConcolicCpp("./benchmarks/wasm/mem-sym-extract.wat", None, exitByCoverage=true) + } + test("btree-bug-finding-concolic") { testFileConcolicCpp("./benchmarks/wasm/btree/2o1u-unlabeled.wat", exitByCoverage = true) } + + // Don't run this test by default since it takes too long and is only for performance comparison + // test("long-trivial-execution-concrete") { + // // This is a example to show how much performance improvement we can get by immutable data structure + // testFileConcreteCpp("./benchmarks/wasm/staged/long-trivial-execution.wat", None) + // } + + test("return-poly - concrete") { + testFileConcreteCpp("./benchmarks/wasm/staged/return_poly.wat", Some("$real_main"), expect=Some(List(42))) + } + test("ack-cpp - concrete") { testFileConcreteCpp("./benchmarks/wasm/ack.wat", Some("real_main"), expect=Some(List(7))) } + test("power - concrete") { testFileConcreteCpp("./benchmarks/wasm/pow.wat", Some("real_main"), expect=Some(List(1024))) } + test("start - concrete") { testFileConcreteCpp("./benchmarks/wasm/start.wat") } + test("fact - concrete") { testFileConcreteCpp("./benchmarks/wasm/fact.wat", None, expect=Some(List(120))) } + // TODO: Waiting more symbolic operators' implementations + // test("loop - concrete") { testFileConcreteCpp("./benchmarks/wasm/loop.wat", None, expect=Some(List(10))) } + test("even-odd - concrete") { testFileConcreteCpp("./benchmarks/wasm/even_odd.wat", None, expect=Some(List(1))) } + test("global - concrete") { testFileConcreteCpp("./benchmarks/wasm/global-sym.wat", None) } + // TODO: Waiting symbolic memory's implementations + test("load - concrete") { testFileConcreteCpp("./benchmarks/wasm/load.wat", None, expect=Some(List(1))) } + test("load overflow 1 - concrete") { testFileConcreteCpp("./benchmarks/wasm/load-overflow1.wat", None, expect=Some(List(1))) } + test("load overflow 2 - concrete") { testFileConcreteCpp("./benchmarks/wasm/load-overflow2.wat", None, expect=Some(List(1))) } + + test("load offset - concrete") { testFileConcreteCpp("./benchmarks/wasm/load-offset.wat", None, expect=Some(List(1))) } + + // test("btree - concrete") { testFileConcreteCpp("./benchmarks/wasm/btree/2o1u-unlabeled.wat") } + test("fib - concrete") { testFileConcreteCpp("./benchmarks/wasm/fib.wat", None, expect=Some(List(144))) } + test("tribonacci - concrete") { testFileConcreteCpp("./benchmarks/wasm/tribonacci.wat", None, expect=Some(List(504))) } + + // test("return - concrete") { + // Since all of the thrown exceptions had been captured in concolic driver, this test is not valid anymore + // intercept[java.lang.RuntimeException] { + // testFileConcreteCpp("./benchmarks/wasm/return.wat", Some("$real_main")) + // } + // } + + test("return_call - concrete") { + testFileConcreteCpp("./benchmarks/wasm/sum.wat", Some("sum10"), expect=Some(List(55))) + } + + test("block input - concrete") { + testFileConcreteCpp("./benchmarks/wasm/block.wat", Some("real_main"), expect=Some(List(9))) + } + test("loop block input - concrete") { + testFileConcreteCpp("./benchmarks/wasm/block.wat", Some("test_loop_input"), expect=Some(List(55))) + } + test("if block input - concrete") { + testFileConcreteCpp("./benchmarks/wasm/block.wat", Some("test_if_input"), expect=Some(List(25))) + } + test("block input - poly br - concrete") { + testFileConcreteCpp("./benchmarks/wasm/block.wat", Some("test_poly_br"), expect=Some(List(0))) + } + test("loop block - poly br - concrete") { + testFileConcreteCpp("./benchmarks/wasm/loop_poly.wat", None, expect=Some(List(2, 1))) + } + + test("brtable-cpp - concrete") { + testFileConcreteCpp("./benchmarks/wasm/staged/brtable.wat") + } + + test("large-branch-concrete") { + testFileConcreteCpp("./benchmarks/wasm/compare_wasp/large-branch.wat") + } + + test("small-snapshot-concrete") { + testFileConcreteCpp("./benchmarks/wasm/compare_wasp/small-snapshot.wat", Some("main")) + } + + test("f32-operations-concrete") { + testFileConcreteCpp("./benchmarks/wasm/f32_test.wat", Some("test_f32")) + } + + test("call-indirect-concrete") { + testFileConcreteCpp("./benchmarks/wasm/call_indirect_test.wat", expect=Some(List(42))) + } + + test("data-section-concrete") { + testFileConcreteCpp("./benchmarks/wasm/data_sec.wat", expect=Some(List(67305985))) + } + + // test("diverge") { + // testFileConcolicCpp("./benchmarks/wasm/diverge.wat", Some("main")) + // } + +} diff --git a/src/test/scala/genwasym/TestStagedEval.scala b/src/test/scala/genwasym/TestStagedEval.scala index d4d1e960f..ec7c43bed 100644 --- a/src/test/scala/genwasym/TestStagedEval.scala +++ b/src/test/scala/genwasym/TestStagedEval.scala @@ -6,6 +6,7 @@ import lms.core.stub.Adapter import gensym.wasm.parser._ import gensym.wasm.miniwasm._ +import gensym.wasm.stagedminiwasm._ class TestStagedEval extends FunSuite { def testFileToScala(filename: String, main: Option[String] = None, printRes: Boolean = false) = { @@ -35,11 +36,17 @@ class TestStagedEval extends FunSuite { println(result) expect.map(vs => { - val stackValues = result - .split("Stack contents: \n")(1) - .split("\n") - .map(_.toFloat) - .toList + val stackValues = { + val startMarker = "Stack contents: \n" + val endMarker = "End of Stack contents" + val start = result.indexOf(startMarker) + val end = if (start >= 0) result.indexOf(endMarker, start + startMarker.length) else -1 + require(start >= 0 && end >= 0, s"Could not find markers '$startMarker' and '$endMarker' in output") + result.substring(start + startMarker.length, end).trim + .split("\n") + .map(_.toFloat) + .toList + } assert(vs == stackValues) }) }