diff --git a/fe25519_25/fe25519_invert.wat b/fe25519_25/fe25519_invert.wat new file mode 100644 index 0000000..218c1ed --- /dev/null +++ b/fe25519_25/fe25519_invert.wat @@ -0,0 +1,1171 @@ +(module + (func $i32.log (import "debug" "log") (param i32)) + (func $i32.log_tee (import "debug" "log_tee") (param i32) (result i32)) + ;; No i64 interop with JS yet - but maybe coming with WebAssembly BigInt + ;; So we can instead fake this by splitting the i64 into two i32 limbs, + ;; however these are WASM functions using i32x2.log: + (func $i32x2.log (import "debug" "log") (param i32) (param i32)) + (func $f32.log (import "debug" "log") (param f32)) + (func $f32.log_tee (import "debug" "log_tee") (param f32) (result f32)) + (func $f64.log (import "debug" "log") (param f64)) + (func $f64.log_tee (import "debug" "log_tee") (param f64) (result f64)) + + (memory $0 1) + (export "memory" (memory $0)) + + ;; i64 logging by splitting into two i32 limbs + (func $i64.log + (param $0 i64) + (call $i32x2.log + ;; Upper limb + (i32.wrap/i64 + (i64.shr_s (get_local $0) + (i64.const 32))) + ;; Lower limb + (i32.wrap/i64 (get_local $0)))) + + (func $i64.log_tee + (param $0 i64) + (result i64) + (call $i64.log (get_local $0)) + (return (get_local $0))) + + (global $tmp0 (mut i64) (i64.const 0)) + (global $tmp1 (mut i64) (i64.const 0)) + (global $tmp2 (mut i64) (i64.const 0)) + (global $tmp3 (mut i64) (i64.const 0)) + (global $tmp4 (mut i64) (i64.const 0)) + (global $tmp5 (mut i64) (i64.const 0)) + (global $tmp6 (mut i64) (i64.const 0)) + (global $tmp7 (mut i64) (i64.const 0)) + (global $tmp8 (mut i64) (i64.const 0)) + (global $tmp9 (mut i64) (i64.const 0)) + + (func $mul + (param $f0 i64) + (param $f1 i64) + (param $f2 i64) + (param $f3 i64) + (param $f4 i64) + (param $f5 i64) + (param $f6 i64) + (param $f7 i64) + (param $f8 i64) + (param $f9 i64) + + (param $g0 i64) + (param $g1 i64) + (param $g2 i64) + (param $g3 i64) + (param $g4 i64) + (param $g5 i64) + (param $g6 i64) + (param $g7 i64) + (param $g8 i64) + (param $g9 i64) + + (local $h0 i64) + (local $h1 i64) + (local $h2 i64) + (local $h3 i64) + (local $h4 i64) + (local $h5 i64) + (local $h6 i64) + (local $h7 i64) + (local $h8 i64) + (local $h9 i64) + + (local $carry0 i64) + (local $carry1 i64) + (local $carry2 i64) + (local $carry3 i64) + (local $carry4 i64) + (local $carry5 i64) + (local $carry6 i64) + (local $carry7 i64) + (local $carry8 i64) + (local $carry9 i64) + + (local $g1_19 i64) + (local $g2_19 i64) + (local $g3_19 i64) + (local $g4_19 i64) + (local $g5_19 i64) + (local $g6_19 i64) + (local $g7_19 i64) + (local $g8_19 i64) + (local $g9_19 i64) + (local $f1_2 i64) + (local $f3_2 i64) + (local $f5_2 i64) + (local $f7_2 i64) + (local $f9_2 i64) + + (local $f0g0 i64) + (local $f0g1 i64) + (local $f0g2 i64) + (local $f0g3 i64) + (local $f0g4 i64) + (local $f0g5 i64) + (local $f0g6 i64) + (local $f0g7 i64) + (local $f0g8 i64) + (local $f0g9 i64) + (local $f1g0 i64) + (local $f1g1_2 i64) + (local $f1g2 i64) + (local $f1g3_2 i64) + (local $f1g4 i64) + (local $f1g5_2 i64) + (local $f1g6 i64) + (local $f1g7_2 i64) + (local $f1g8 i64) + (local $f1g9_38 i64) + (local $f2g0 i64) + (local $f2g1 i64) + (local $f2g2 i64) + (local $f2g3 i64) + (local $f2g4 i64) + (local $f2g5 i64) + (local $f2g6 i64) + (local $f2g7 i64) + (local $f2g8_19 i64) + (local $f2g9_19 i64) + (local $f3g0 i64) + (local $f3g1_2 i64) + (local $f3g2 i64) + (local $f3g3_2 i64) + (local $f3g4 i64) + (local $f3g5_2 i64) + (local $f3g6 i64) + (local $f3g7_38 i64) + (local $f3g8_19 i64) + (local $f3g9_38 i64) + (local $f4g0 i64) + (local $f4g1 i64) + (local $f4g2 i64) + (local $f4g3 i64) + (local $f4g4 i64) + (local $f4g5 i64) + (local $f4g6_19 i64) + (local $f4g7_19 i64) + (local $f4g8_19 i64) + (local $f4g9_19 i64) + (local $f5g0 i64) + (local $f5g1_2 i64) + (local $f5g2 i64) + (local $f5g3_2 i64) + (local $f5g4 i64) + (local $f5g5_38 i64) + (local $f5g6_19 i64) + (local $f5g7_38 i64) + (local $f5g8_19 i64) + (local $f5g9_38 i64) + (local $f6g0 i64) + (local $f6g1 i64) + (local $f6g2 i64) + (local $f6g3 i64) + (local $f6g4_19 i64) + (local $f6g5_19 i64) + (local $f6g6_19 i64) + (local $f6g7_19 i64) + (local $f6g8_19 i64) + (local $f6g9_19 i64) + (local $f7g0 i64) + (local $f7g1_2 i64) + (local $f7g2 i64) + (local $f7g3_38 i64) + (local $f7g4_19 i64) + (local $f7g5_38 i64) + (local $f7g6_19 i64) + (local $f7g7_38 i64) + (local $f7g8_19 i64) + (local $f7g9_38 i64) + (local $f8g0 i64) + (local $f8g1 i64) + (local $f8g2_19 i64) + (local $f8g3_19 i64) + (local $f8g4_19 i64) + (local $f8g5_19 i64) + (local $f8g6_19 i64) + (local $f8g7_19 i64) + (local $f8g8_19 i64) + (local $f8g9_19 i64) + (local $f9g0 i64) + (local $f9g1_38 i64) + (local $f9g2_19 i64) + (local $f9g3_38 i64) + (local $f9g4_19 i64) + (local $f9g5_38 i64) + (local $f9g6_19 i64) + (local $f9g7_38 i64) + (local $f9g8_19 i64) + (local $f9g9_38 i64) + + (set_local $f0 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f0)))) + (set_local $f1 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f1)))) + (set_local $f2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f2)))) + (set_local $f3 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f3)))) + (set_local $f4 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f4)))) + (set_local $f5 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f5)))) + (set_local $f6 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f6)))) + (set_local $f7 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f7)))) + (set_local $f8 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f8)))) + (set_local $f9 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f9)))) + + (set_local $g0 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g0)))) + (set_local $g1 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g1)))) + (set_local $g2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g2)))) + (set_local $g3 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g3)))) + (set_local $g4 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g4)))) + (set_local $g5 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g5)))) + (set_local $g6 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g6)))) + (set_local $g7 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g7)))) + (set_local $g8 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g8)))) + (set_local $g9 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g9)))) + + (set_local $g1_19 (i64.sub (i64.mul (i64.const 19) (get_local $g1)) (i64.mul (i64.shl (i64.and (get_local $g1) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g2_19 (i64.sub (i64.mul (i64.const 19) (get_local $g2)) (i64.mul (i64.shl (i64.and (get_local $g2) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g3_19 (i64.sub (i64.mul (i64.const 19) (get_local $g3)) (i64.mul (i64.shl (i64.and (get_local $g3) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g4_19 (i64.sub (i64.mul (i64.const 19) (get_local $g4)) (i64.mul (i64.shl (i64.and (get_local $g4) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g5_19 (i64.sub (i64.mul (i64.const 19) (get_local $g5)) (i64.mul (i64.shl (i64.and (get_local $g5) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g6_19 (i64.sub (i64.mul (i64.const 19) (get_local $g6)) (i64.mul (i64.shl (i64.and (get_local $g6) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g7_19 (i64.sub (i64.mul (i64.const 19) (get_local $g7)) (i64.mul (i64.shl (i64.and (get_local $g7) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g8_19 (i64.sub (i64.mul (i64.const 19) (get_local $g8)) (i64.mul (i64.shl (i64.and (get_local $g8) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + (set_local $g9_19 (i64.sub (i64.mul (i64.const 19) (get_local $g9)) (i64.mul (i64.shl (i64.and (get_local $g9) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) + + (set_local $f1_2 (i64.sub (i64.mul (i64.const 2) (get_local $f1)) (i64.mul (i64.shl (i64.and (get_local $f1) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) + (set_local $f3_2 (i64.sub (i64.mul (i64.const 2) (get_local $f3)) (i64.mul (i64.shl (i64.and (get_local $f3) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) + (set_local $f5_2 (i64.sub (i64.mul (i64.const 2) (get_local $f5)) (i64.mul (i64.shl (i64.and (get_local $f5) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) + (set_local $f7_2 (i64.sub (i64.mul (i64.const 2) (get_local $f7)) (i64.mul (i64.shl (i64.and (get_local $f7) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) + (set_local $f9_2 (i64.sub (i64.mul (i64.const 2) (get_local $f9)) (i64.mul (i64.shl (i64.and (get_local $f9) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) + + (set_local $g1_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g1_19)))) + (set_local $g2_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g2_19)))) + (set_local $g3_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g3_19)))) + (set_local $g4_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g4_19)))) + (set_local $g5_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g5_19)))) + (set_local $g6_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g6_19)))) + (set_local $g7_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g7_19)))) + (set_local $g8_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g8_19)))) + (set_local $g9_19 (i64.extend_s/i32 (i32.wrap/i64 (get_local $g9_19)))) + + (set_local $f1_2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f1_2)))) + (set_local $f3_2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f3_2)))) + (set_local $f5_2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f5_2)))) + (set_local $f7_2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f7_2)))) + (set_local $f9_2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f9_2)))) + + (set_local $f0g0 (i64.mul (get_local $f0 ) (get_local $g0))) + (set_local $f0g1 (i64.mul (get_local $f0 ) (get_local $g1))) + (set_local $f0g2 (i64.mul (get_local $f0 ) (get_local $g2))) + (set_local $f0g3 (i64.mul (get_local $f0 ) (get_local $g3))) + (set_local $f0g4 (i64.mul (get_local $f0 ) (get_local $g4))) + (set_local $f0g5 (i64.mul (get_local $f0 ) (get_local $g5))) + (set_local $f0g6 (i64.mul (get_local $f0 ) (get_local $g6))) + (set_local $f0g7 (i64.mul (get_local $f0 ) (get_local $g7))) + (set_local $f0g8 (i64.mul (get_local $f0 ) (get_local $g8))) + (set_local $f0g9 (i64.mul (get_local $f0 ) (get_local $g9))) + (set_local $f1g0 (i64.mul (get_local $f1 ) (get_local $g0))) + (set_local $f1g1_2 (i64.mul (get_local $f1_2) (get_local $g1))) + (set_local $f1g2 (i64.mul (get_local $f1 ) (get_local $g2))) + (set_local $f1g3_2 (i64.mul (get_local $f1_2) (get_local $g3))) + (set_local $f1g4 (i64.mul (get_local $f1 ) (get_local $g4))) + (set_local $f1g5_2 (i64.mul (get_local $f1_2) (get_local $g5))) + (set_local $f1g6 (i64.mul (get_local $f1 ) (get_local $g6))) + (set_local $f1g7_2 (i64.mul (get_local $f1_2) (get_local $g7))) + (set_local $f1g8 (i64.mul (get_local $f1 ) (get_local $g8))) + (set_local $f1g9_38 (i64.mul (get_local $f1_2) (get_local $g9_19))) + (set_local $f2g0 (i64.mul (get_local $f2 ) (get_local $g0))) + (set_local $f2g1 (i64.mul (get_local $f2 ) (get_local $g1))) + (set_local $f2g2 (i64.mul (get_local $f2 ) (get_local $g2))) + (set_local $f2g3 (i64.mul (get_local $f2 ) (get_local $g3))) + (set_local $f2g4 (i64.mul (get_local $f2 ) (get_local $g4))) + (set_local $f2g5 (i64.mul (get_local $f2 ) (get_local $g5))) + (set_local $f2g6 (i64.mul (get_local $f2 ) (get_local $g6))) + (set_local $f2g7 (i64.mul (get_local $f2 ) (get_local $g7))) + (set_local $f2g8_19 (i64.mul (get_local $f2 ) (get_local $g8_19))) + (set_local $f2g9_19 (i64.mul (get_local $f2 ) (get_local $g9_19))) + (set_local $f3g0 (i64.mul (get_local $f3 ) (get_local $g0))) + (set_local $f3g1_2 (i64.mul (get_local $f3_2) (get_local $g1))) + (set_local $f3g2 (i64.mul (get_local $f3 ) (get_local $g2))) + (set_local $f3g3_2 (i64.mul (get_local $f3_2) (get_local $g3))) + (set_local $f3g4 (i64.mul (get_local $f3 ) (get_local $g4))) + (set_local $f3g5_2 (i64.mul (get_local $f3_2) (get_local $g5))) + (set_local $f3g6 (i64.mul (get_local $f3 ) (get_local $g6))) + (set_local $f3g7_38 (i64.mul (get_local $f3_2) (get_local $g7_19))) + (set_local $f3g8_19 (i64.mul (get_local $f3 ) (get_local $g8_19))) + (set_local $f3g9_38 (i64.mul (get_local $f3_2) (get_local $g9_19))) + (set_local $f4g0 (i64.mul (get_local $f4) (get_local $g0))) + (set_local $f4g1 (i64.mul (get_local $f4) (get_local $g1))) + (set_local $f4g2 (i64.mul (get_local $f4) (get_local $g2))) + (set_local $f4g3 (i64.mul (get_local $f4) (get_local $g3))) + (set_local $f4g4 (i64.mul (get_local $f4) (get_local $g4))) + (set_local $f4g5 (i64.mul (get_local $f4) (get_local $g5))) + (set_local $f4g6_19 (i64.mul (get_local $f4) (get_local $g6_19))) + (set_local $f4g7_19 (i64.mul (get_local $f4) (get_local $g7_19))) + (set_local $f4g8_19 (i64.mul (get_local $f4) (get_local $g8_19))) + (set_local $f4g9_19 (i64.mul (get_local $f4) (get_local $g9_19))) + (set_local $f5g0 (i64.mul (get_local $f5) (get_local $g0))) + (set_local $f5g1_2 (i64.mul (get_local $f5_2) (get_local $g1))) + (set_local $f5g2 (i64.mul (get_local $f5) (get_local $g2))) + (set_local $f5g3_2 (i64.mul (get_local $f5_2) (get_local $g3))) + (set_local $f5g4 (i64.mul (get_local $f5) (get_local $g4))) + (set_local $f5g5_38 (i64.mul (get_local $f5_2) (get_local $g5_19))) + (set_local $f5g6_19 (i64.mul (get_local $f5) (get_local $g6_19))) + (set_local $f5g7_38 (i64.mul (get_local $f5_2) (get_local $g7_19))) + (set_local $f5g8_19 (i64.mul (get_local $f5) (get_local $g8_19))) + (set_local $f5g9_38 (i64.mul (get_local $f5_2) (get_local $g9_19))) + (set_local $f6g0 (i64.mul (get_local $f6) (get_local $g0))) + (set_local $f6g1 (i64.mul (get_local $f6) (get_local $g1))) + (set_local $f6g2 (i64.mul (get_local $f6) (get_local $g2))) + (set_local $f6g3 (i64.mul (get_local $f6) (get_local $g3))) + (set_local $f6g4_19 (i64.mul (get_local $f6) (get_local $g4_19))) + (set_local $f6g5_19 (i64.mul (get_local $f6) (get_local $g5_19))) + (set_local $f6g6_19 (i64.mul (get_local $f6) (get_local $g6_19))) + (set_local $f6g7_19 (i64.mul (get_local $f6) (get_local $g7_19))) + (set_local $f6g8_19 (i64.mul (get_local $f6) (get_local $g8_19))) + (set_local $f6g9_19 (i64.mul (get_local $f6) (get_local $g9_19))) + (set_local $f7g0 (i64.mul (get_local $f7) (get_local $g0))) + (set_local $f7g1_2 (i64.mul (get_local $f7_2) (get_local $g1))) + (set_local $f7g2 (i64.mul (get_local $f7) (get_local $g2))) + (set_local $f7g3_38 (i64.mul (get_local $f7_2) (get_local $g3_19))) + (set_local $f7g4_19 (i64.mul (get_local $f7) (get_local $g4_19))) + (set_local $f7g5_38 (i64.mul (get_local $f7_2) (get_local $g5_19))) + (set_local $f7g6_19 (i64.mul (get_local $f7) (get_local $g6_19))) + (set_local $f7g7_38 (i64.mul (get_local $f7_2) (get_local $g7_19))) + (set_local $f7g8_19 (i64.mul (get_local $f7) (get_local $g8_19))) + (set_local $f7g9_38 (i64.mul (get_local $f7_2) (get_local $g9_19))) + (set_local $f8g0 (i64.mul (get_local $f8) (get_local $g0))) + (set_local $f8g1 (i64.mul (get_local $f8) (get_local $g1))) + (set_local $f8g2_19 (i64.mul (get_local $f8) (get_local $g2_19))) + (set_local $f8g3_19 (i64.mul (get_local $f8) (get_local $g3_19))) + (set_local $f8g4_19 (i64.mul (get_local $f8) (get_local $g4_19))) + (set_local $f8g5_19 (i64.mul (get_local $f8) (get_local $g5_19))) + (set_local $f8g6_19 (i64.mul (get_local $f8) (get_local $g6_19))) + (set_local $f8g7_19 (i64.mul (get_local $f8) (get_local $g7_19))) + (set_local $f8g8_19 (i64.mul (get_local $f8) (get_local $g8_19))) + (set_local $f8g9_19 (i64.mul (get_local $f8) (get_local $g9_19))) + (set_local $f9g0 (i64.mul (get_local $f9) (get_local $g0))) + (set_local $f9g1_38 (i64.mul (get_local $f9_2) (get_local $g1_19))) + (set_local $f9g2_19 (i64.mul (get_local $f9) (get_local $g2_19))) + (set_local $f9g3_38 (i64.mul (get_local $f9_2) (get_local $g3_19))) + (set_local $f9g4_19 (i64.mul (get_local $f9) (get_local $g4_19))) + (set_local $f9g5_38 (i64.mul (get_local $f9_2) (get_local $g5_19))) + (set_local $f9g6_19 (i64.mul (get_local $f9) (get_local $g6_19))) + (set_local $f9g7_38 (i64.mul (get_local $f9_2) (get_local $g7_19))) + (set_local $f9g8_19 (i64.mul (get_local $f9) (get_local $g8_19))) + (set_local $f9g9_38 (i64.mul (get_local $f9_2) (get_local $g9_19))) + + (set_local $h0 (i64.add (get_local $f0g0) (i64.add (get_local $f1g9_38) (i64.add (get_local $f2g8_19) (i64.add (get_local $f3g7_38) (i64.add (get_local $f4g6_19) (i64.add (get_local $f5g5_38) (i64.add (get_local $f6g4_19) (i64.add (get_local $f7g3_38) (i64.add (get_local $f8g2_19) (get_local $f9g1_38))))))))))) + (set_local $h1 (i64.add (get_local $f0g1) (i64.add (get_local $f1g0) (i64.add (get_local $f2g9_19) (i64.add (get_local $f3g8_19) (i64.add (get_local $f4g7_19) (i64.add (get_local $f5g6_19) (i64.add (get_local $f6g5_19) (i64.add (get_local $f7g4_19) (i64.add (get_local $f8g3_19) (get_local $f9g2_19))))))))))) + (set_local $h2 (i64.add (get_local $f0g2) (i64.add (get_local $f1g1_2) (i64.add (get_local $f2g0) (i64.add (get_local $f3g9_38) (i64.add (get_local $f4g8_19) (i64.add (get_local $f5g7_38) (i64.add (get_local $f6g6_19) (i64.add (get_local $f7g5_38) (i64.add (get_local $f8g4_19) (get_local $f9g3_38))))))))))) + (set_local $h3 (i64.add (get_local $f0g3) (i64.add (get_local $f1g2) (i64.add (get_local $f2g1) (i64.add (get_local $f3g0) (i64.add (get_local $f4g9_19) (i64.add (get_local $f5g8_19) (i64.add (get_local $f6g7_19) (i64.add (get_local $f7g6_19) (i64.add (get_local $f8g5_19) (get_local $f9g4_19))))))))))) + (set_local $h4 (i64.add (get_local $f0g4) (i64.add (get_local $f1g3_2) (i64.add (get_local $f2g2) (i64.add (get_local $f3g1_2) (i64.add (get_local $f4g0) (i64.add (get_local $f5g9_38) (i64.add (get_local $f6g8_19) (i64.add (get_local $f7g7_38) (i64.add (get_local $f8g6_19) (get_local $f9g5_38))))))))))) + (set_local $h5 (i64.add (get_local $f0g5) (i64.add (get_local $f1g4) (i64.add (get_local $f2g3) (i64.add (get_local $f3g2) (i64.add (get_local $f4g1) (i64.add (get_local $f5g0) (i64.add (get_local $f6g9_19) (i64.add (get_local $f7g8_19) (i64.add (get_local $f8g7_19) (get_local $f9g6_19))))))))))) + (set_local $h6 (i64.add (get_local $f0g6) (i64.add (get_local $f1g5_2) (i64.add (get_local $f2g4) (i64.add (get_local $f3g3_2) (i64.add (get_local $f4g2) (i64.add (get_local $f5g1_2) (i64.add (get_local $f6g0) (i64.add (get_local $f7g9_38) (i64.add (get_local $f8g8_19) (get_local $f9g7_38))))))))))) + (set_local $h7 (i64.add (get_local $f0g7) (i64.add (get_local $f1g6) (i64.add (get_local $f2g5) (i64.add (get_local $f3g4) (i64.add (get_local $f4g3) (i64.add (get_local $f5g2) (i64.add (get_local $f6g1) (i64.add (get_local $f7g0) (i64.add (get_local $f8g9_19) (get_local $f9g8_19))))))))))) + (set_local $h8 (i64.add (get_local $f0g8) (i64.add (get_local $f1g7_2) (i64.add (get_local $f2g6) (i64.add (get_local $f3g5_2) (i64.add (get_local $f4g4) (i64.add (get_local $f5g3_2) (i64.add (get_local $f6g2) (i64.add (get_local $f7g1_2) (i64.add (get_local $f8g0) (get_local $f9g9_38))))))))))) + (set_local $h9 (i64.add (get_local $f0g9) (i64.add (get_local $f1g8) (i64.add (get_local $f2g7) (i64.add (get_local $f3g6) (i64.add (get_local $f4g5) (i64.add (get_local $f5g4) (i64.add (get_local $f6g3) (i64.add (get_local $f7g2) (i64.add (get_local $f8g1) (get_local $f9g0))))))))))) + + (set_local $carry0 (i64.shr_s (i64.add (get_local $h0) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp1 (i64.add (get_global $tmp1) (get_local $carry0))) + (set_global $tmp0 (i64.sub (get_global $tmp0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26))))) + (set_local $carry4 (i64.shr_s (i64.add (get_global $tmp4) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp5 (i64.add (get_global $tmp5) (get_local $carry4))) + (set_global $tmp4 (i64.sub (get_global $tmp4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 26))))) + + (set_local $carry1 (i64.shr_s (i64.add (get_global $tmp1) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_global $tmp2 (i64.add (get_global $tmp2) (get_local $carry1))) + (set_global $tmp1 (i64.sub (get_global $tmp1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 25))))) + (set_local $carry5 (i64.shr_s (i64.add (get_global $tmp5) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_global $tmp6 (i64.add (get_global $tmp6) (get_local $carry5))) + (set_global $tmp5 (i64.sub (get_global $tmp5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 25))))) + + (set_local $carry2 (i64.shr_s (i64.add (get_global $tmp2) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp3 (i64.add (get_global $tmp3) (get_local $carry2))) + (set_global $tmp2 (i64.sub (get_global $tmp2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 26))))) + (set_local $carry6 (i64.shr_s (i64.add (get_global $tmp6) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp7 (i64.add (get_global $tmp7) (get_local $carry6))) + (set_global $tmp6 (i64.sub (get_global $tmp6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 26))))) + + (set_local $carry3 (i64.shr_s (i64.add (get_global $tmp3) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_global $tmp4 (i64.add (get_global $tmp4) (get_local $carry3))) + (set_global $tmp3 (i64.sub (get_global $tmp3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 25))))) + (set_local $carry7 (i64.shr_s (i64.add (get_global $tmp7) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_global $tmp8 (i64.add (get_global $tmp8) (get_local $carry7))) + (set_global $tmp7 (i64.sub (get_global $tmp7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 25))))) + + (set_local $carry4 (i64.shr_s (i64.add (get_global $tmp4) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp5 (i64.add (get_global $tmp5) (get_local $carry4))) + (set_global $tmp4 (i64.sub (get_global $tmp4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 26))))) + (set_local $carry8 (i64.shr_s (i64.add (get_global $tmp8) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp9 (i64.add (get_global $tmp9) (get_local $carry8))) + (set_global $tmp8 (i64.sub (get_global $tmp8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 26))))) + + (set_local $carry9 (i64.shr_s (i64.add (get_global $tmp9) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_global $tmp0 (i64.add (get_global $tmp0) (i64.mul (get_local $carry9) (i64.const 19)))) + (set_global $tmp9 (i64.sub (get_global $tmp9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 25))))) + + (set_local $carry0 (i64.shr_s (i64.add (get_global $tmp0) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_global $tmp1 (i64.add (get_global $tmp1) (get_local $carry0))) + (set_global $tmp0 (i64.sub (get_global $tmp0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26)))))) + + (func $fe25519_invert (export "fe25519_invert") (param $out i32) (param $f i32) + (local $f0 i64) + (local $f1 i64) + (local $f2 i64) + (local $f3 i64) + (local $f4 i64) + (local $f5 i64) + (local $f6 i64) + (local $f7 i64) + (local $f8 i64) + (local $f9 i64) + + (local $i i32) + + (local $t0_0 i64) (local $t1_0 i64) (local $t2_0 i64) (local $t3_0 i64) + (local $t0_1 i64) (local $t1_1 i64) (local $t2_1 i64) (local $t3_1 i64) + (local $t0_2 i64) (local $t1_2 i64) (local $t2_2 i64) (local $t3_2 i64) + (local $t0_3 i64) (local $t1_3 i64) (local $t2_3 i64) (local $t3_3 i64) + (local $t0_4 i64) (local $t1_4 i64) (local $t2_4 i64) (local $t3_4 i64) + (local $t0_5 i64) (local $t1_5 i64) (local $t2_5 i64) (local $t3_5 i64) + (local $t0_6 i64) (local $t1_6 i64) (local $t2_6 i64) (local $t3_6 i64) + (local $t0_7 i64) (local $t1_7 i64) (local $t2_7 i64) (local $t3_7 i64) + (local $t0_8 i64) (local $t1_8 i64) (local $t2_8 i64) (local $t3_8 i64) + (local $t0_9 i64) (local $t1_9 i64) (local $t2_9 i64) (local $t3_9 i64) + + (set_local $f0 (i64.load32_u offset=0 (get_local $f))) + (set_local $f1 (i64.load32_u offset=4 (get_local $f))) + (set_local $f2 (i64.load32_u offset=8 (get_local $f))) + (set_local $f3 (i64.load32_u offset=12 (get_local $f))) + (set_local $f4 (i64.load32_u offset=16 (get_local $f))) + (set_local $f5 (i64.load32_u offset=20 (get_local $f))) + (set_local $f6 (i64.load32_u offset=24 (get_local $f))) + (set_local $f7 (i64.load32_u offset=28 (get_local $f))) + (set_local $f8 (i64.load32_u offset=32 (get_local $f))) + (set_local $f9 (i64.load32_u offset=36 (get_local $f))) + + (set_local $f0 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f0)))) + (set_local $f1 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f1)))) + (set_local $f2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f2)))) + (set_local $f3 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f3)))) + (set_local $f4 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f4)))) + (set_local $f5 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f5)))) + (set_local $f6 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f6)))) + (set_local $f7 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f7)))) + (set_local $f8 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f8)))) + (set_local $f9 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f9)))) + + (get_local $f0) + (get_local $f1) + (get_local $f2) + (get_local $f3) + (get_local $f4) + (get_local $f5) + (get_local $f6) + (get_local $f7) + (get_local $f8) + (get_local $f9) + (get_local $f0) + (get_local $f1) + (get_local $f2) + (get_local $f3) + (get_local $f4) + (get_local $f5) + (get_local $f6) + (get_local $f7) + (get_local $f8) + (get_local $f9) + (call $mul) + + (set_local $t0_0 (get_global $tmp0)) + (set_local $t0_1 (get_global $tmp1)) + (set_local $t0_2 (get_global $tmp2)) + (set_local $t0_3 (get_global $tmp3)) + (set_local $t0_4 (get_global $tmp4)) + (set_local $t0_5 (get_global $tmp5)) + (set_local $t0_6 (get_global $tmp6)) + (set_local $t0_7 (get_global $tmp7)) + (set_local $t0_8 (get_global $tmp8)) + (set_local $t0_9 (get_global $tmp9)) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (get_local $f0) + (get_local $f1) + (get_local $f2) + (get_local $f3) + (get_local $f4) + (get_local $f5) + (get_local $f6) + (get_local $f7) + (get_local $f8) + (get_local $f9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t1_0 (get_global $tmp0)) + (set_local $t1_1 (get_global $tmp1)) + (set_local $t1_2 (get_global $tmp2)) + (set_local $t1_3 (get_global $tmp3)) + (set_local $t1_4 (get_global $tmp4)) + (set_local $t1_5 (get_global $tmp5)) + (set_local $t1_6 (get_global $tmp6)) + (set_local $t1_7 (get_global $tmp7)) + (set_local $t1_8 (get_global $tmp8)) + (set_local $t1_9 (get_global $tmp9)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_local $t0_0) + (get_local $t0_1) + (get_local $t0_2) + (get_local $t0_3) + (get_local $t0_4) + (get_local $t0_5) + (get_local $t0_6) + (get_local $t0_7) + (get_local $t0_8) + (get_local $t0_9) + (call $mul) + + (set_local $t0_0 (get_global $tmp0)) + (set_local $t0_1 (get_global $tmp1)) + (set_local $t0_2 (get_global $tmp2)) + (set_local $t0_3 (get_global $tmp3)) + (set_local $t0_4 (get_global $tmp4)) + (set_local $t0_5 (get_global $tmp5)) + (set_local $t0_6 (get_global $tmp6)) + (set_local $t0_7 (get_global $tmp7)) + (set_local $t0_8 (get_global $tmp8)) + (set_local $t0_9 (get_global $tmp9)) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t2_0 (get_global $tmp0)) + (set_local $t2_1 (get_global $tmp1)) + (set_local $t2_2 (get_global $tmp2)) + (set_local $t2_3 (get_global $tmp3)) + (set_local $t2_4 (get_global $tmp4)) + (set_local $t2_5 (get_global $tmp5)) + (set_local $t2_6 (get_global $tmp6)) + (set_local $t2_7 (get_global $tmp7)) + (set_local $t2_8 (get_global $tmp8)) + (set_local $t2_9 (get_global $tmp9)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t1_0 (get_global $tmp0)) + (set_local $t1_1 (get_global $tmp1)) + (set_local $t1_2 (get_global $tmp2)) + (set_local $t1_3 (get_global $tmp3)) + (set_local $t1_4 (get_global $tmp4)) + (set_local $t1_5 (get_global $tmp5)) + (set_local $t1_6 (get_global $tmp6)) + (set_local $t1_7 (get_global $tmp7)) + (set_local $t1_8 (get_global $tmp8)) + (set_local $t1_9 (get_global $tmp9)) + + ;; loop(6) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 6)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (set_local $t2_0 (get_global $tmp0)) + (set_local $t2_1 (get_global $tmp1)) + (set_local $t2_2 (get_global $tmp2)) + (set_local $t2_3 (get_global $tmp3)) + (set_local $t2_4 (get_global $tmp4)) + (set_local $t2_5 (get_global $tmp5)) + (set_local $t2_6 (get_global $tmp6)) + (set_local $t2_7 (get_global $tmp7)) + (set_local $t2_8 (get_global $tmp8)) + (set_local $t2_9 (get_global $tmp9)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t1_0 (get_global $tmp0)) + (set_local $t1_1 (get_global $tmp1)) + (set_local $t1_2 (get_global $tmp2)) + (set_local $t1_3 (get_global $tmp3)) + (set_local $t1_4 (get_global $tmp4)) + (set_local $t1_5 (get_global $tmp5)) + (set_local $t1_6 (get_global $tmp6)) + (set_local $t1_7 (get_global $tmp7)) + (set_local $t1_8 (get_global $tmp8)) + (set_local $t1_9 (get_global $tmp9)) + + ;; loop(11) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 11)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t2_0 (get_global $tmp0)) + (set_local $t2_1 (get_global $tmp1)) + (set_local $t2_2 (get_global $tmp2)) + (set_local $t2_3 (get_global $tmp3)) + (set_local $t2_4 (get_global $tmp4)) + (set_local $t2_5 (get_global $tmp5)) + (set_local $t2_6 (get_global $tmp6)) + (set_local $t2_7 (get_global $tmp7)) + (set_local $t2_8 (get_global $tmp8)) + (set_local $t2_9 (get_global $tmp9)) + + ;; loop(21) : sq(t3) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 21)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (set_local $t3_0 (get_global $tmp0)) + (set_local $t3_1 (get_global $tmp1)) + (set_local $t3_2 (get_global $tmp2)) + (set_local $t3_3 (get_global $tmp3)) + (set_local $t3_4 (get_global $tmp4)) + (set_local $t3_5 (get_global $tmp5)) + (set_local $t3_6 (get_global $tmp6)) + (set_local $t3_7 (get_global $tmp7)) + (set_local $t3_8 (get_global $tmp8)) + (set_local $t3_9 (get_global $tmp9)) + + (get_local $t2_0) + (get_local $t2_1) + (get_local $t2_2) + (get_local $t2_3) + (get_local $t2_4) + (get_local $t2_5) + (get_local $t2_6) + (get_local $t2_7) + (get_local $t2_8) + (get_local $t2_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + ;; loop(11) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 11)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t1_0 (get_global $tmp0)) + (set_local $t1_1 (get_global $tmp1)) + (set_local $t1_2 (get_global $tmp2)) + (set_local $t1_3 (get_global $tmp3)) + (set_local $t1_4 (get_global $tmp4)) + (set_local $t1_5 (get_global $tmp5)) + (set_local $t1_6 (get_global $tmp6)) + (set_local $t1_7 (get_global $tmp7)) + (set_local $t1_8 (get_global $tmp8)) + (set_local $t1_9 (get_global $tmp9)) + + ;; loop(11) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 51)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (set_local $t2_0 (get_global $tmp0)) + (set_local $t2_1 (get_global $tmp1)) + (set_local $t2_2 (get_global $tmp2)) + (set_local $t2_3 (get_global $tmp3)) + (set_local $t2_4 (get_global $tmp4)) + (set_local $t2_5 (get_global $tmp5)) + (set_local $t2_6 (get_global $tmp6)) + (set_local $t2_7 (get_global $tmp7)) + (set_local $t2_8 (get_global $tmp8)) + (set_local $t2_9 (get_global $tmp9)) + + ;; loop(101) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 101)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (set_local $t3_0 (get_global $tmp0)) + (set_local $t3_1 (get_global $tmp1)) + (set_local $t3_2 (get_global $tmp2)) + (set_local $t3_3 (get_global $tmp3)) + (set_local $t3_4 (get_global $tmp4)) + (set_local $t3_5 (get_global $tmp5)) + (set_local $t3_6 (get_global $tmp6)) + (set_local $t3_7 (get_global $tmp7)) + (set_local $t3_8 (get_global $tmp8)) + (set_local $t3_9 (get_global $tmp9)) + + (get_local $t2_0) + (get_local $t2_1) + (get_local $t2_2) + (get_local $t2_3) + (get_local $t2_4) + (get_local $t2_5) + (get_local $t2_6) + (get_local $t2_7) + (get_local $t2_8) + (get_local $t2_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + ;; loop(51) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 51)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + (set_local $i (i32.const 0)) + + (get_local $t1_0) + (get_local $t1_1) + (get_local $t1_2) + (get_local $t1_3) + (get_local $t1_4) + (get_local $t1_5) + (get_local $t1_6) + (get_local $t1_7) + (get_local $t1_8) + (get_local $t1_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + ;; loop(51) : sq(t2) + (block $end + (loop $start + (br_if $end (i32.eq (get_local $i (i32.const 6)))) + + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (br $start))) + + (get_local $t0_0) + (get_local $t0_1) + (get_local $t0_2) + (get_local $t0_3) + (get_local $t0_4) + (get_local $t0_5) + (get_local $t0_6) + (get_local $t0_7) + (get_local $t0_8) + (get_local $t0_9) + (get_global $tmp0) + (get_global $tmp1) + (get_global $tmp2) + (get_global $tmp3) + (get_global $tmp4) + (get_global $tmp5) + (get_global $tmp6) + (get_global $tmp7) + (get_global $tmp8) + (get_global $tmp9) + (call $mul) + + (i64.store32 offset=0 (get_local $out) (get_global $tmp0)) + (i64.store32 offset=4 (get_local $out) (get_global $tmp1)) + (i64.store32 offset=8 (get_local $out) (get_global $tmp2)) + (i64.store32 offset=12 (get_local $out) (get_global $tmp3)) + (i64.store32 offset=16 (get_local $out) (get_global $tmp4)) + (i64.store32 offset=20 (get_local $out) (get_global $tmp5)) + (i64.store32 offset=24 (get_local $out) (get_global $tmp6)) + (i64.store32 offset=28 (get_local $out) (get_global $tmp7)) + (i64.store32 offset=32 (get_local $out) (get_global $tmp8)) + (i64.store32 offset=36 (get_local $out) (get_global $tmp9)))) diff --git a/fe25519_25/fe25519_sq.wat b/fe25519_25/fe25519_sq.wat new file mode 100644 index 0000000..867c675 --- /dev/null +++ b/fe25519_25/fe25519_sq.wat @@ -0,0 +1,287 @@ +(module + (memory $0 1) + (export "memory" (memory $0)) + + (func $sq (export "sq") (param $h i32) (param $f i32) (param $double i32) (param $repeat i32) + (local $tmp i64) + + (local $f0 i64) + (local $f1 i64) + (local $f2 i64) + (local $f3 i64) + (local $f4 i64) + (local $f5 i64) + (local $f6 i64) + (local $f7 i64) + (local $f8 i64) + (local $f9 i64) + + (local $h0 i64) + (local $h1 i64) + (local $h2 i64) + (local $h3 i64) + (local $h4 i64) + (local $h5 i64) + (local $h6 i64) + (local $h7 i64) + (local $h8 i64) + (local $h9 i64) + + (local $carry0 i64) + (local $carry1 i64) + (local $carry2 i64) + (local $carry3 i64) + (local $carry4 i64) + (local $carry5 i64) + (local $carry6 i64) + (local $carry7 i64) + (local $carry8 i64) + (local $carry9 i64) + + (local $f0_2 i64) + (local $f1_2 i64) + (local $f2_2 i64) + (local $f3_2 i64) + (local $f4_2 i64) + (local $f5_2 i64) + (local $f6_2 i64) + (local $f7_2 i64) + + (local $f5_38 i64) + (local $f6_19 i64) + (local $f7_38 i64) + (local $f8_19 i64) + (local $f9_38 i64) + + (local $f0f0 i64) + (local $f0f1_2 i64) + (local $f0f2_2 i64) + (local $f0f3_2 i64) + (local $f0f4_2 i64) + (local $f0f5_2 i64) + (local $f0f6_2 i64) + (local $f0f7_2 i64) + (local $f0f8_2 i64) + (local $f0f9_2 i64) + (local $f1f1_2 i64) + (local $f1f2_2 i64) + (local $f1f3_4 i64) + (local $f1f4_2 i64) + (local $f1f5_4 i64) + (local $f1f6_2 i64) + (local $f1f7_4 i64) + (local $f1f8_2 i64) + (local $f1f9_76 i64) + (local $f2f2 i64) + (local $f2f3_2 i64) + (local $f2f4_2 i64) + (local $f2f5_2 i64) + (local $f2f6_2 i64) + (local $f2f7_2 i64) + (local $f2f8_38 i64) + (local $f2f9_38 i64) + (local $f3f3_2 i64) + (local $f3f4_2 i64) + (local $f3f5_4 i64) + (local $f3f6_2 i64) + (local $f3f7_76 i64) + (local $f3f8_38 i64) + (local $f3f9_76 i64) + (local $f4f4 i64) + (local $f4f5_2 i64) + (local $f4f6_38 i64) + (local $f4f7_38 i64) + (local $f4f8_38 i64) + (local $f4f9_38 i64) + (local $f5f5_38 i64) + (local $f5f6_38 i64) + (local $f5f7_76 i64) + (local $f5f8_38 i64) + (local $f5f9_76 i64) + (local $f6f6_19 i64) + (local $f6f7_38 i64) + (local $f6f8_38 i64) + (local $f6f9_38 i64) + (local $f7f7_38 i64) + (local $f7f8_38 i64) + (local $f7f9_76 i64) + (local $f8f8_19 i64) + (local $f8f9_38 i64) + (local $f9f9_38 i64) + + (set_local $f0 (i64.load32_u offset=0 (get_local $f))) + (set_local $f1 (i64.load32_u offset=4 (get_local $f))) + (set_local $f2 (i64.load32_u offset=8 (get_local $f))) + (set_local $f3 (i64.load32_u offset=12 (get_local $f))) + (set_local $f4 (i64.load32_u offset=16 (get_local $f))) + (set_local $f5 (i64.load32_u offset=20 (get_local $f))) + (set_local $f6 (i64.load32_u offset=24 (get_local $f))) + (set_local $f7 (i64.load32_u offset=28 (get_local $f))) + (set_local $f8 (i64.load32_u offset=32 (get_local $f))) + (set_local $f9 (i64.load32_u offset=36 (get_local $f))) + + (block $end + (loop $again + (set_local $f0 (i64.extend32_s (get_local $f0))) + (set_local $f1 (i64.extend32_s (get_local $f1))) + (set_local $f2 (i64.extend32_s (get_local $f2))) + (set_local $f3 (i64.extend32_s (get_local $f3))) + (set_local $f4 (i64.extend32_s (get_local $f4))) + (set_local $f5 (i64.extend32_s (get_local $f5))) + (set_local $f6 (i64.extend32_s (get_local $f6))) + (set_local $f7 (i64.extend32_s (get_local $f7))) + (set_local $f8 (i64.extend32_s (get_local $f8))) + (set_local $f9 (i64.extend32_s (get_local $f9))) + + (set_local $f0_2 (i64.mul (i64.const 2 (get_local $f0)))) + (set_local $f1_2 (i64.mul (i64.const 2 (get_local $f1)))) + (set_local $f2_2 (i64.mul (i64.const 2 (get_local $f2)))) + (set_local $f3_2 (i64.mul (i64.const 2 (get_local $f3)))) + (set_local $f4_2 (i64.mul (i64.const 2 (get_local $f4)))) + (set_local $f5_2 (i64.mul (i64.const 2 (get_local $f5)))) + (set_local $f6_2 (i64.mul (i64.const 2 (get_local $f6)))) + (set_local $f7_2 (i64.mul (i64.const 2 (get_local $f7)))) + + (set_local $f5_38 (i64.mul (i64.const 38 (get_local $f5)))) + (set_local $f6_19 (i64.mul (i64.const 19 (get_local $f6)))) + (set_local $f7_38 (i64.mul (i64.const 38 (get_local $f7)))) + (set_local $f8_19 (i64.mul (i64.const 19 (get_local $f8)))) + (set_local $f9_38 (i64.mul (i64.const 38 (get_local $f9)))) + + (set_local $f0f0 (i64.mul (get_local $f0) (get_local $f0))) + (set_local $f0f1_2 (i64.mul (get_local $f0_2) (get_local $f1))) + (set_local $f0f2_2 (i64.mul (get_local $f0_2) (get_local $f2))) + (set_local $f0f3_2 (i64.mul (get_local $f0_2) (get_local $f3))) + (set_local $f0f4_2 (i64.mul (get_local $f0_2) (get_local $f4))) + (set_local $f0f5_2 (i64.mul (get_local $f0_2) (get_local $f5))) + (set_local $f0f6_2 (i64.mul (get_local $f0_2) (get_local $f6))) + (set_local $f0f7_2 (i64.mul (get_local $f0_2) (get_local $f7))) + (set_local $f0f8_2 (i64.mul (get_local $f0_2) (get_local $f8))) + (set_local $f0f9_2 (i64.mul (get_local $f0_2) (get_local $f9))) + (set_local $f1f1_2 (i64.mul (get_local $f1_2) (get_local $f1))) + (set_local $f1f2_2 (i64.mul (get_local $f1_2) (get_local $f2))) + (set_local $f1f3_4 (i64.mul (get_local $f1_2) (get_local $f3_2))) + (set_local $f1f4_2 (i64.mul (get_local $f1_2) (get_local $f4))) + (set_local $f1f5_4 (i64.mul (get_local $f1_2) (get_local $f5_2))) + (set_local $f1f6_2 (i64.mul (get_local $f1_2) (get_local $f6))) + (set_local $f1f7_4 (i64.mul (get_local $f1_2) (get_local $f7_2))) + (set_local $f1f8_2 (i64.mul (get_local $f1_2) (get_local $f8))) + (set_local $f1f9_76 (i64.mul (get_local $f1_2) (get_local $f9_38))) + (set_local $f2f2 (i64.mul (get_local $f2) (get_local $f2))) + (set_local $f2f3_2 (i64.mul (get_local $f2_2) (get_local $f3))) + (set_local $f2f4_2 (i64.mul (get_local $f2_2) (get_local $f4))) + (set_local $f2f5_2 (i64.mul (get_local $f2_2) (get_local $f5))) + (set_local $f2f6_2 (i64.mul (get_local $f2_2) (get_local $f6))) + (set_local $f2f7_2 (i64.mul (get_local $f2_2) (get_local $f7))) + (set_local $f2f8_38 (i64.mul (get_local $f2_2) (get_local $f8_19))) + (set_local $f2f9_38 (i64.mul (get_local $f2) (get_local $f9_38))) + (set_local $f3f3_2 (i64.mul (get_local $f3_2) (get_local $f3))) + (set_local $f3f4_2 (i64.mul (get_local $f3_2) (get_local $f4))) + (set_local $f3f5_4 (i64.mul (get_local $f3_2) (get_local $f5_2))) + (set_local $f3f6_2 (i64.mul (get_local $f3_2) (get_local $f6))) + (set_local $f3f7_76 (i64.mul (get_local $f3_2) (get_local $f7_38))) + (set_local $f3f8_38 (i64.mul (get_local $f3_2) (get_local $f8_19))) + (set_local $f3f9_76 (i64.mul (get_local $f3_2) (get_local $f9_38))) + (set_local $f4f4 (i64.mul (get_local $f4) (get_local $f4))) + (set_local $f4f5_2 (i64.mul (get_local $f4_2) (get_local $f5))) + (set_local $f4f6_38 (i64.mul (get_local $f4_2) (get_local $f6_19))) + (set_local $f4f7_38 (i64.mul (get_local $f4) (get_local $f7_38))) + (set_local $f4f8_38 (i64.mul (get_local $f4_2) (get_local $f8_19))) + (set_local $f4f9_38 (i64.mul (get_local $f4) (get_local $f9_38))) + (set_local $f5f5_38 (i64.mul (get_local $f5) (get_local $f5_38))) + (set_local $f5f6_38 (i64.mul (get_local $f5_2) (get_local $f6_19))) + (set_local $f5f7_76 (i64.mul (get_local $f5_2) (get_local $f7_38))) + (set_local $f5f8_38 (i64.mul (get_local $f5_2) (get_local $f8_19))) + (set_local $f5f9_76 (i64.mul (get_local $f5_2) (get_local $f9_38))) + (set_local $f6f6_19 (i64.mul (get_local $f6) (get_local $f6_19))) + (set_local $f6f7_38 (i64.mul (get_local $f6) (get_local $f7_38))) + (set_local $f6f8_38 (i64.mul (get_local $f6_2) (get_local $f8_19))) + (set_local $f6f9_38 (i64.mul (get_local $f6) (get_local $f9_38))) + (set_local $f7f7_38 (i64.mul (get_local $f7) (get_local $f7_38))) + (set_local $f7f8_38 (i64.mul (get_local $f7_2) (get_local $f8_19))) + (set_local $f7f9_76 (i64.mul (get_local $f7_2) (get_local $f9_38))) + (set_local $f8f8_19 (i64.mul (get_local $f8) (get_local $f8_19))) + (set_local $f8f9_38 (i64.mul (get_local $f8) (get_local $f9_38))) + (set_local $f9f9_38 (i64.mul (get_local $f9) (get_local $f9_38))) + + (set_local $h0 (i64.add (get_local $f0f0) (i64.add (get_local $f1f9_76) (i64.add (get_local $f2f8_38) (i64.add (get_local $f3f7_76) (i64.add (get_local $f4f6_38) (get_local $f5f5_38))))))) + (set_local $h1 (i64.add (get_local $f0f1_2) (i64.add (get_local $f2f9_38) (i64.add (get_local $f3f8_38) (i64.add (get_local $f4f7_38) (get_local $f5f6_38)))))) + (set_local $h2 (i64.add (get_local $f0f2_2) (i64.add (get_local $f1f1_2) (i64.add (get_local $f3f9_76) (i64.add (get_local $f4f8_38) (i64.add (get_local $f5f7_76) (get_local $f6f6_19))))))) + (set_local $h3 (i64.add (get_local $f0f3_2) (i64.add (get_local $f1f2_2) (i64.add (get_local $f4f9_38) (i64.add (get_local $f5f8_38) (get_local $f6f7_38)))))) + (set_local $h4 (i64.add (get_local $f0f4_2) (i64.add (get_local $f1f3_4) (i64.add (get_local $f2f2) (i64.add (get_local $f5f9_76) (i64.add (get_local $f6f8_38) (get_local $f7f7_38))))))) + (set_local $h5 (i64.add (get_local $f0f5_2) (i64.add (get_local $f1f4_2) (i64.add (get_local $f2f3_2) (i64.add (get_local $f6f9_38) (get_local $f7f8_38)))))) + (set_local $h6 (i64.add (get_local $f0f6_2) (i64.add (get_local $f1f5_4) (i64.add (get_local $f2f4_2) (i64.add (get_local $f3f3_2) (i64.add (get_local $f7f9_76) (get_local $f8f8_19))))))) + (set_local $h7 (i64.add (get_local $f0f7_2) (i64.add (get_local $f1f6_2) (i64.add (get_local $f2f5_2) (i64.add (get_local $f3f4_2) (get_local $f8f9_38)))))) + (set_local $h8 (i64.add (get_local $f0f8_2) (i64.add (get_local $f1f7_4) (i64.add (get_local $f2f6_2) (i64.add (get_local $f3f5_4) (i64.add (get_local $f4f4) (get_local $f9f9_38))))))) + (set_local $h9 (i64.add (get_local $f0f9_2) (i64.add (get_local $f1f8_2) (i64.add (get_local $f2f7_2) (i64.add (get_local $f3f6_2) (get_local $f4f5_2 )))))) + + (br_if $end (i32.eq (get_local $count) (get_local $repeat))) + (set_local $count (i32.add (get_local $count) (i32.const 1))) + (br $again))) + + (if (i32.eq (get_local $double) (i32.const 1)) + (then + (set_local $h0 (i64.add (get_local $h0) (get_local $h0))) + (set_local $h1 (i64.add (get_local $h1) (get_local $h1))) + (set_local $h2 (i64.add (get_local $h2) (get_local $h2))) + (set_local $h3 (i64.add (get_local $h3) (get_local $h3))) + (set_local $h4 (i64.add (get_local $h4) (get_local $h4))) + (set_local $h5 (i64.add (get_local $h5) (get_local $h5))) + (set_local $h6 (i64.add (get_local $h6) (get_local $h6))) + (set_local $h7 (i64.add (get_local $h7) (get_local $h7))) + (set_local $h8 (i64.add (get_local $h8) (get_local $h8))) + (set_local $h9 (i64.add (get_local $h9) (get_local $h9))))) + + (set_local $carry0 (i64.shr_s (i64.add (get_local $h0) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h1 (i64.add (get_local $h1) (get_local $carry0))) + (set_local $h0 (i64.sub (get_local $h0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26))))) + (set_local $carry4 (i64.shr_s (i64.add (get_local $h4) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h5 (i64.add (get_local $h5) (get_local $carry4))) + (set_local $h4 (i64.sub (get_local $h4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 26))))) + + (set_local $carry1 (i64.shr_s (i64.add (get_local $h1) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_local $h2 (i64.add (get_local $h2) (get_local $carry1))) + (set_local $h1 (i64.sub (get_local $h1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 25))))) + (set_local $carry5 (i64.shr_s (i64.add (get_local $h5) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_local $h6 (i64.add (get_local $h6) (get_local $carry5))) + (set_local $h5 (i64.sub (get_local $h5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 25))))) + + (set_local $carry2 (i64.shr_s (i64.add (get_local $h2) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h3 (i64.add (get_local $h3) (get_local $carry2))) + (set_local $h2 (i64.sub (get_local $h2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 26))))) + (set_local $carry6 (i64.shr_s (i64.add (get_local $h6) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h7 (i64.add (get_local $h7) (get_local $carry6))) + (set_local $h6 (i64.sub (get_local $h6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 26))))) + + (set_local $carry3 (i64.shr_s (i64.add (get_local $h3) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_local $h4 (i64.add (get_local $h4) (get_local $carry3))) + (set_local $h3 (i64.sub (get_local $h3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 25))))) + (set_local $carry7 (i64.shr_s (i64.add (get_local $h7) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_local $h8 (i64.add (get_local $h8) (get_local $carry7))) + (set_local $h7 (i64.sub (get_local $h7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 25))))) + + (set_local $carry4 (i64.shr_s (i64.add (get_local $h4) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h5 (i64.add (get_local $h5) (get_local $carry4))) + (set_local $h4 (i64.sub (get_local $h4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 26))))) + (set_local $carry8 (i64.shr_s (i64.add (get_local $h8) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h9 (i64.add (get_local $h9) (get_local $carry8))) + (set_local $h8 (i64.sub (get_local $h8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 26))))) + + (set_local $carry9 (i64.shr_s (i64.add (get_local $h9) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) + (set_local $h0 (i64.add (get_local $h0) (i64.mul (get_local $carry9) (i64.const 19)))) + (set_local $h9 (i64.sub (get_local $h9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 25))))) + + (set_local $carry0 (i64.shr_s (i64.add (get_local $h0) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) + (set_local $h1 (i64.add (get_local $h1) (get_local $carry0))) + (set_local $h0 (i64.sub (get_local $h0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26))))) + + (i64.store32 offset=0 (get_local $h) (get_local $h0)) + (i64.store32 offset=4 (get_local $h) (get_local $h1)) + (i64.store32 offset=8 (get_local $h) (get_local $h2)) + (i64.store32 offset=12 (get_local $h) (get_local $h3)) + (i64.store32 offset=16 (get_local $h) (get_local $h4)) + (i64.store32 offset=20 (get_local $h) (get_local $h5)) + (i64.store32 offset=24 (get_local $h) (get_local $h6)) + (i64.store32 offset=28 (get_local $h) (get_local $h7)) + (i64.store32 offset=32 (get_local $h) (get_local $h8)) + (i64.store32 offset=36 (get_local $h) (get_local $h9)))) diff --git a/fe25519_25/mult.wat b/fe25519_25/mult.wat index e057982..b5860e1 100644 --- a/fe25519_25/mult.wat +++ b/fe25519_25/mult.wat @@ -30,50 +30,7 @@ (call $i64.log (get_local $0)) (return (get_local $0))) - (func $extend_sign (param $f i64) - (result i64) - - (local $tmp i64) - - (i64.shr_u (get_local $f) (i64.const 31)) - (i64.const 32) - (i64.shl) - (tee_local $tmp) - (i64.shl (get_local $tmp) (i64.const 1)) - (i64.or) - (tee_local $tmp) - (i64.shl (get_local $tmp) (i64.const 2)) - (i64.or) - (tee_local $tmp) - (i64.shl (get_local $tmp) (i64.const 4)) - (i64.or) - (tee_local $tmp) - (i64.shl (get_local $tmp) (i64.const 8)) - (i64.or) - (tee_local $tmp) - (i64.shl (get_local $tmp) (i64.const 16)) - (i64.or) - (get_local $f) - (i64.or)) - - (func $store_fe (export "store") (param $ptr i32) - (param $0 i64) (param $1 i64) (param $2 i64) (param $3 i64) (param $4 i64) - (param $5 i64) (param $6 i64) (param $7 i64) (param $8 i64) (param $9 i64) - - (i64.store32 offset=0 (get_local $ptr) (get_local $0)) - (i64.store32 offset=4 (get_local $ptr) (get_local $1)) - (i64.store32 offset=8 (get_local $ptr) (get_local $2)) - (i64.store32 offset=12 (get_local $ptr) (get_local $3)) - (i64.store32 offset=16 (get_local $ptr) (get_local $4)) - (i64.store32 offset=20 (get_local $ptr) (get_local $5)) - (i64.store32 offset=24 (get_local $ptr) (get_local $6)) - (i64.store32 offset=28 (get_local $ptr) (get_local $7)) - (i64.store32 offset=32 (get_local $ptr) (get_local $8)) - (i64.store32 offset=36 (get_local $ptr) (get_local $9))) - - (func $mul (param $f i32) (param $g i32) - (result i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) - + (func $mul (param $h i32) (param $f i32) (param $g i32) (local $f0 i64) (local $f1 i64) (local $f2 i64) @@ -106,8 +63,6 @@ (local $h7 i64) (local $h8 i64) (local $h9 i64) - - (local $tmp i64) (local $carry0 i64) (local $carry1 i64) @@ -258,47 +213,27 @@ (set_local $g8 (i64.load32_u offset=32 (get_local $g))) (set_local $g9 (i64.load32_u offset=36 (get_local $g))) - (call $extend_sign (get_local $f0)) - (set_local $f0) - (call $extend_sign (get_local $f1)) - (set_local $f1) - (call $extend_sign (get_local $f2)) - (set_local $f2) - (call $extend_sign (get_local $f3)) - (set_local $f3) - (call $extend_sign (get_local $f4)) - (set_local $f4) - (call $extend_sign (get_local $f5)) - (set_local $f5) - (call $extend_sign (get_local $f6)) - (set_local $f6) - (call $extend_sign (get_local $f7)) - (set_local $f7) - (call $extend_sign (get_local $f8)) - (set_local $f8) - (call $extend_sign (get_local $f9)) - (set_local $f9) + (set_local $f0 (i64.extend32_s (get_local $f0))) + (set_local $f1 (i64.extend32_s (get_local $f1))) + (set_local $f2 (i64.extend32_s (get_local $f2))) + (set_local $f3 (i64.extend32_s (get_local $f3))) + (set_local $f4 (i64.extend32_s (get_local $f4))) + (set_local $f5 (i64.extend32_s (get_local $f5))) + (set_local $f6 (i64.extend32_s (get_local $f6))) + (set_local $f7 (i64.extend32_s (get_local $f7))) + (set_local $f8 (i64.extend32_s (get_local $f8))) + (set_local $f9 (i64.extend32_s (get_local $f9))) - (call $extend_sign (get_local $g0)) - (set_local $g0) - (call $extend_sign (get_local $g1)) - (set_local $g1) - (call $extend_sign (get_local $g2)) - (set_local $g2) - (call $extend_sign (get_local $g3)) - (set_local $g3) - (call $extend_sign (get_local $g4)) - (set_local $g4) - (call $extend_sign (get_local $g5)) - (set_local $g5) - (call $extend_sign (get_local $g6)) - (set_local $g6) - (call $extend_sign (get_local $g7)) - (set_local $g7) - (call $extend_sign (get_local $g8)) - (set_local $g8) - (call $extend_sign (get_local $g9)) - (set_local $g9) + (set_local $g0 (i64.extend32_s (get_local $g0))) + (set_local $g1 (i64.extend32_s (get_local $g1))) + (set_local $g2 (i64.extend32_s (get_local $g2))) + (set_local $g3 (i64.extend32_s (get_local $g3))) + (set_local $g4 (i64.extend32_s (get_local $g4))) + (set_local $g5 (i64.extend32_s (get_local $g5))) + (set_local $g6 (i64.extend32_s (get_local $g6))) + (set_local $g7 (i64.extend32_s (get_local $g7))) + (set_local $g8 (i64.extend32_s (get_local $g8))) + (set_local $g9 (i64.extend32_s (get_local $g9))) (set_local $g1_19 (i64.sub (i64.mul (i64.const 19) (get_local $g1)) (i64.mul (i64.shl (i64.and (get_local $g1) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) (set_local $g2_19 (i64.sub (i64.mul (i64.const 19) (get_local $g2)) (i64.mul (i64.shl (i64.and (get_local $g2) (i64.const 0x80000000)) (i64.const 1)) (i64.const 19)))) @@ -316,35 +251,21 @@ (set_local $f7_2 (i64.sub (i64.mul (i64.const 2) (get_local $f7)) (i64.mul (i64.shl (i64.and (get_local $f7) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) (set_local $f9_2 (i64.sub (i64.mul (i64.const 2) (get_local $f9)) (i64.mul (i64.shl (i64.and (get_local $f9) (i64.const 0x80000000)) (i64.const 1)) (i64.const 2)))) - (call $extend_sign (get_local $g1_19)) - (set_local $g1_19) - (call $extend_sign (get_local $g2_19)) - (set_local $g2_19) - (call $extend_sign (get_local $g3_19)) - (set_local $g3_19) - (call $extend_sign (get_local $g4_19)) - (set_local $g4_19) - (call $extend_sign (get_local $g5_19)) - (set_local $g5_19) - (call $extend_sign (get_local $g6_19)) - (set_local $g6_19) - (call $extend_sign (get_local $g7_19)) - (set_local $g7_19) - (call $extend_sign (get_local $g8_19)) - (set_local $g8_19) - (call $extend_sign (get_local $g9_19)) - (set_local $g9_19) + (set_local $g1_19 (i64.extend32_s (get_local $g1_19))) + (set_local $g2_19 (i64.extend32_s (get_local $g2_19))) + (set_local $g3_19 (i64.extend32_s (get_local $g3_19))) + (set_local $g4_19 (i64.extend32_s (get_local $g4_19))) + (set_local $g5_19 (i64.extend32_s (get_local $g5_19))) + (set_local $g6_19 (i64.extend32_s (get_local $g6_19))) + (set_local $g7_19 (i64.extend32_s (get_local $g7_19))) + (set_local $g8_19 (i64.extend32_s (get_local $g8_19))) + (set_local $g9_19 (i64.extend32_s (get_local $g9_19))) - (call $extend_sign (get_local $f1_2)) - (set_local $f1_2) - (call $extend_sign (get_local $f3_2)) - (set_local $f3_2) - (call $extend_sign (get_local $f5_2)) - (set_local $f5_2) - (call $extend_sign (get_local $f7_2)) - (set_local $f7_2) - (call $extend_sign (get_local $f9_2)) - (set_local $f9_2) + (set_local $f1_2 (i64.extend32_s (get_local $f1_2))) + (set_local $f3_2 (i64.extend32_s (get_local $f3_2))) + (set_local $f5_2 (i64.extend32_s (get_local $f5_2))) + (set_local $f7_2 (i64.extend32_s (get_local $f7_2))) + (set_local $f9_2 (i64.extend32_s (get_local $f9_2))) (set_local $f0g0 (i64.mul (get_local $f0 ) (get_local $g0))) (set_local $f0g1 (i64.mul (get_local $f0 ) (get_local $g1))) @@ -501,294 +422,6 @@ (set_local $h1 (i64.add (get_local $h1) (get_local $carry0))) (set_local $h0 (i64.sub (get_local $h0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26))))) - (get_local $h0) - (get_local $h1) - (get_local $h2) - (get_local $h3) - (get_local $h4) - (get_local $h5) - (get_local $h6) - (get_local $h7) - (get_local $h8) - (get_local $h9)) - - (func $sq (export "sq") (param $h i32) (param $f i32) (param $double i32) - (local $tmp i64) - - (local $f0 i64) - (local $f1 i64) - (local $f2 i64) - (local $f3 i64) - (local $f4 i64) - (local $f5 i64) - (local $f6 i64) - (local $f7 i64) - (local $f8 i64) - (local $f9 i64) - - (local $h0 i64) - (local $h1 i64) - (local $h2 i64) - (local $h3 i64) - (local $h4 i64) - (local $h5 i64) - (local $h6 i64) - (local $h7 i64) - (local $h8 i64) - (local $h9 i64) - - (local $carry0 i64) - (local $carry1 i64) - (local $carry2 i64) - (local $carry3 i64) - (local $carry4 i64) - (local $carry5 i64) - (local $carry6 i64) - (local $carry7 i64) - (local $carry8 i64) - (local $carry9 i64) - - (local $f0_2 i64) - (local $f1_2 i64) - (local $f2_2 i64) - (local $f3_2 i64) - (local $f4_2 i64) - (local $f5_2 i64) - (local $f6_2 i64) - (local $f7_2 i64) - - (local $f5_38 i64) - (local $f6_19 i64) - (local $f7_38 i64) - (local $f8_19 i64) - (local $f9_38 i64) - - (local $f0f0 i64) - (local $f0f1_2 i64) - (local $f0f2_2 i64) - (local $f0f3_2 i64) - (local $f0f4_2 i64) - (local $f0f5_2 i64) - (local $f0f6_2 i64) - (local $f0f7_2 i64) - (local $f0f8_2 i64) - (local $f0f9_2 i64) - (local $f1f1_2 i64) - (local $f1f2_2 i64) - (local $f1f3_4 i64) - (local $f1f4_2 i64) - (local $f1f5_4 i64) - (local $f1f6_2 i64) - (local $f1f7_4 i64) - (local $f1f8_2 i64) - (local $f1f9_76 i64) - (local $f2f2 i64) - (local $f2f3_2 i64) - (local $f2f4_2 i64) - (local $f2f5_2 i64) - (local $f2f6_2 i64) - (local $f2f7_2 i64) - (local $f2f8_38 i64) - (local $f2f9_38 i64) - (local $f3f3_2 i64) - (local $f3f4_2 i64) - (local $f3f5_4 i64) - (local $f3f6_2 i64) - (local $f3f7_76 i64) - (local $f3f8_38 i64) - (local $f3f9_76 i64) - (local $f4f4 i64) - (local $f4f5_2 i64) - (local $f4f6_38 i64) - (local $f4f7_38 i64) - (local $f4f8_38 i64) - (local $f4f9_38 i64) - (local $f5f5_38 i64) - (local $f5f6_38 i64) - (local $f5f7_76 i64) - (local $f5f8_38 i64) - (local $f5f9_76 i64) - (local $f6f6_19 i64) - (local $f6f7_38 i64) - (local $f6f8_38 i64) - (local $f6f9_38 i64) - (local $f7f7_38 i64) - (local $f7f8_38 i64) - (local $f7f9_76 i64) - (local $f8f8_19 i64) - (local $f8f9_38 i64) - (local $f9f9_38 i64) - - (set_local $f0 (i64.load32_u offset=0 (get_local $f))) - (set_local $f1 (i64.load32_u offset=4 (get_local $f))) - (set_local $f2 (i64.load32_u offset=8 (get_local $f))) - (set_local $f3 (i64.load32_u offset=12 (get_local $f))) - (set_local $f4 (i64.load32_u offset=16 (get_local $f))) - (set_local $f5 (i64.load32_u offset=20 (get_local $f))) - (set_local $f6 (i64.load32_u offset=24 (get_local $f))) - (set_local $f7 (i64.load32_u offset=28 (get_local $f))) - (set_local $f8 (i64.load32_u offset=32 (get_local $f))) - (set_local $f9 (i64.load32_u offset=36 (get_local $f))) - - (call $extend_sign (get_local $f0)) - (set_local $f0) - (call $extend_sign (get_local $f1)) - (set_local $f1) - (call $extend_sign (get_local $f2)) - (set_local $f2) - (call $extend_sign (get_local $f3)) - (set_local $f3) - (call $extend_sign (get_local $f4)) - (set_local $f4) - (call $extend_sign (get_local $f5)) - (set_local $f5) - (call $extend_sign (get_local $f6)) - (set_local $f6) - (call $extend_sign (get_local $f7)) - (set_local $f7) - (call $extend_sign (get_local $f8)) - (set_local $f8) - (call $extend_sign (get_local $f9)) - (set_local $f9) - - (set_local $f0_2 (i64.mul (i64.const 2 (get_local $f0)))) - (set_local $f1_2 (i64.mul (i64.const 2 (get_local $f1)))) - (set_local $f2_2 (i64.mul (i64.const 2 (get_local $f2)))) - (set_local $f3_2 (i64.mul (i64.const 2 (get_local $f3)))) - (set_local $f4_2 (i64.mul (i64.const 2 (get_local $f4)))) - (set_local $f5_2 (i64.mul (i64.const 2 (get_local $f5)))) - (set_local $f6_2 (i64.mul (i64.const 2 (get_local $f6)))) - (set_local $f7_2 (i64.mul (i64.const 2 (get_local $f7)))) - - (set_local $f5_38 (i64.mul (i64.const 38 (get_local $f5)))) - (set_local $f6_19 (i64.mul (i64.const 19 (get_local $f6)))) - (set_local $f7_38 (i64.mul (i64.const 38 (get_local $f7)))) - (set_local $f8_19 (i64.mul (i64.const 19 (get_local $f8)))) - (set_local $f9_38 (i64.mul (i64.const 38 (get_local $f9)))) - - (set_local $f0f0 (i64.mul (get_local $f0) (get_local $f0))) - (set_local $f0f1_2 (i64.mul (get_local $f0_2) (get_local $f1))) - (set_local $f0f2_2 (i64.mul (get_local $f0_2) (get_local $f2))) - (set_local $f0f3_2 (i64.mul (get_local $f0_2) (get_local $f3))) - (set_local $f0f4_2 (i64.mul (get_local $f0_2) (get_local $f4))) - (set_local $f0f5_2 (i64.mul (get_local $f0_2) (get_local $f5))) - (set_local $f0f6_2 (i64.mul (get_local $f0_2) (get_local $f6))) - (set_local $f0f7_2 (i64.mul (get_local $f0_2) (get_local $f7))) - (set_local $f0f8_2 (i64.mul (get_local $f0_2) (get_local $f8))) - (set_local $f0f9_2 (i64.mul (get_local $f0_2) (get_local $f9))) - (set_local $f1f1_2 (i64.mul (get_local $f1_2) (get_local $f1))) - (set_local $f1f2_2 (i64.mul (get_local $f1_2) (get_local $f2))) - (set_local $f1f3_4 (i64.mul (get_local $f1_2) (get_local $f3_2))) - (set_local $f1f4_2 (i64.mul (get_local $f1_2) (get_local $f4))) - (set_local $f1f5_4 (i64.mul (get_local $f1_2) (get_local $f5_2))) - (set_local $f1f6_2 (i64.mul (get_local $f1_2) (get_local $f6))) - (set_local $f1f7_4 (i64.mul (get_local $f1_2) (get_local $f7_2))) - (set_local $f1f8_2 (i64.mul (get_local $f1_2) (get_local $f8))) - (set_local $f1f9_76 (i64.mul (get_local $f1_2) (get_local $f9_38))) - (set_local $f2f2 (i64.mul (get_local $f2) (get_local $f2))) - (set_local $f2f3_2 (i64.mul (get_local $f2_2) (get_local $f3))) - (set_local $f2f4_2 (i64.mul (get_local $f2_2) (get_local $f4))) - (set_local $f2f5_2 (i64.mul (get_local $f2_2) (get_local $f5))) - (set_local $f2f6_2 (i64.mul (get_local $f2_2) (get_local $f6))) - (set_local $f2f7_2 (i64.mul (get_local $f2_2) (get_local $f7))) - (set_local $f2f8_38 (i64.mul (get_local $f2_2) (get_local $f8_19))) - (set_local $f2f9_38 (i64.mul (get_local $f2) (get_local $f9_38))) - (set_local $f3f3_2 (i64.mul (get_local $f3_2) (get_local $f3))) - (set_local $f3f4_2 (i64.mul (get_local $f3_2) (get_local $f4))) - (set_local $f3f5_4 (i64.mul (get_local $f3_2) (get_local $f5_2))) - (set_local $f3f6_2 (i64.mul (get_local $f3_2) (get_local $f6))) - (set_local $f3f7_76 (i64.mul (get_local $f3_2) (get_local $f7_38))) - (set_local $f3f8_38 (i64.mul (get_local $f3_2) (get_local $f8_19))) - (set_local $f3f9_76 (i64.mul (get_local $f3_2) (get_local $f9_38))) - (set_local $f4f4 (i64.mul (get_local $f4) (get_local $f4))) - (set_local $f4f5_2 (i64.mul (get_local $f4_2) (get_local $f5))) - (set_local $f4f6_38 (i64.mul (get_local $f4_2) (get_local $f6_19))) - (set_local $f4f7_38 (i64.mul (get_local $f4) (get_local $f7_38))) - (set_local $f4f8_38 (i64.mul (get_local $f4_2) (get_local $f8_19))) - (set_local $f4f9_38 (i64.mul (get_local $f4) (get_local $f9_38))) - (set_local $f5f5_38 (i64.mul (get_local $f5) (get_local $f5_38))) - (set_local $f5f6_38 (i64.mul (get_local $f5_2) (get_local $f6_19))) - (set_local $f5f7_76 (i64.mul (get_local $f5_2) (get_local $f7_38))) - (set_local $f5f8_38 (i64.mul (get_local $f5_2) (get_local $f8_19))) - (set_local $f5f9_76 (i64.mul (get_local $f5_2) (get_local $f9_38))) - (set_local $f6f6_19 (i64.mul (get_local $f6) (get_local $f6_19))) - (set_local $f6f7_38 (i64.mul (get_local $f6) (get_local $f7_38))) - (set_local $f6f8_38 (i64.mul (get_local $f6_2) (get_local $f8_19))) - (set_local $f6f9_38 (i64.mul (get_local $f6) (get_local $f9_38))) - (set_local $f7f7_38 (i64.mul (get_local $f7) (get_local $f7_38))) - (set_local $f7f8_38 (i64.mul (get_local $f7_2) (get_local $f8_19))) - (set_local $f7f9_76 (i64.mul (get_local $f7_2) (get_local $f9_38))) - (set_local $f8f8_19 (i64.mul (get_local $f8) (get_local $f8_19))) - (set_local $f8f9_38 (i64.mul (get_local $f8) (get_local $f9_38))) - (set_local $f9f9_38 (i64.mul (get_local $f9) (get_local $f9_38))) - - (set_local $h0 (i64.add (get_local $f0f0) (i64.add (get_local $f1f9_76) (i64.add (get_local $f2f8_38) (i64.add (get_local $f3f7_76) (i64.add (get_local $f4f6_38) (get_local $f5f5_38))))))) - (set_local $h1 (i64.add (get_local $f0f1_2) (i64.add (get_local $f2f9_38) (i64.add (get_local $f3f8_38) (i64.add (get_local $f4f7_38) (get_local $f5f6_38)))))) - (set_local $h2 (i64.add (get_local $f0f2_2) (i64.add (get_local $f1f1_2) (i64.add (get_local $f3f9_76) (i64.add (get_local $f4f8_38) (i64.add (get_local $f5f7_76) (get_local $f6f6_19))))))) - (set_local $h3 (i64.add (get_local $f0f3_2) (i64.add (get_local $f1f2_2) (i64.add (get_local $f4f9_38) (i64.add (get_local $f5f8_38) (get_local $f6f7_38)))))) - (set_local $h4 (i64.add (get_local $f0f4_2) (i64.add (get_local $f1f3_4) (i64.add (get_local $f2f2) (i64.add (get_local $f5f9_76) (i64.add (get_local $f6f8_38) (get_local $f7f7_38))))))) - (set_local $h5 (i64.add (get_local $f0f5_2) (i64.add (get_local $f1f4_2) (i64.add (get_local $f2f3_2) (i64.add (get_local $f6f9_38) (get_local $f7f8_38)))))) - (set_local $h6 (i64.add (get_local $f0f6_2) (i64.add (get_local $f1f5_4) (i64.add (get_local $f2f4_2) (i64.add (get_local $f3f3_2) (i64.add (get_local $f7f9_76) (get_local $f8f8_19))))))) - (set_local $h7 (i64.add (get_local $f0f7_2) (i64.add (get_local $f1f6_2) (i64.add (get_local $f2f5_2) (i64.add (get_local $f3f4_2) (get_local $f8f9_38)))))) - (set_local $h8 (i64.add (get_local $f0f8_2) (i64.add (get_local $f1f7_4) (i64.add (get_local $f2f6_2) (i64.add (get_local $f3f5_4) (i64.add (get_local $f4f4) (get_local $f9f9_38))))))) - (set_local $h9 (i64.add (get_local $f0f9_2) (i64.add (get_local $f1f8_2) (i64.add (get_local $f2f7_2) (i64.add (get_local $f3f6_2) (get_local $f4f5_2 )))))) - - (if (i32.eq (get_local $double) (i32.const 1)) - (then - (set_local $h0 (i64.add (get_local $h0) (get_local $h0))) - (set_local $h1 (i64.add (get_local $h1) (get_local $h1))) - (set_local $h2 (i64.add (get_local $h2) (get_local $h2))) - (set_local $h3 (i64.add (get_local $h3) (get_local $h3))) - (set_local $h4 (i64.add (get_local $h4) (get_local $h4))) - (set_local $h5 (i64.add (get_local $h5) (get_local $h5))) - (set_local $h6 (i64.add (get_local $h6) (get_local $h6))) - (set_local $h7 (i64.add (get_local $h7) (get_local $h7))) - (set_local $h8 (i64.add (get_local $h8) (get_local $h8))) - (set_local $h9 (i64.add (get_local $h9) (get_local $h9))))) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $h0) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h1 (i64.add (get_local $h1) (get_local $carry0))) - (set_local $h0 (i64.sub (get_local $h0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26))))) - (set_local $carry4 (i64.shr_s (i64.add (get_local $h4) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h5 (i64.add (get_local $h5) (get_local $carry4))) - (set_local $h4 (i64.sub (get_local $h4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 26))))) - - (set_local $carry1 (i64.shr_s (i64.add (get_local $h1) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) - (set_local $h2 (i64.add (get_local $h2) (get_local $carry1))) - (set_local $h1 (i64.sub (get_local $h1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 25))))) - (set_local $carry5 (i64.shr_s (i64.add (get_local $h5) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) - (set_local $h6 (i64.add (get_local $h6) (get_local $carry5))) - (set_local $h5 (i64.sub (get_local $h5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 25))))) - - (set_local $carry2 (i64.shr_s (i64.add (get_local $h2) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h3 (i64.add (get_local $h3) (get_local $carry2))) - (set_local $h2 (i64.sub (get_local $h2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 26))))) - (set_local $carry6 (i64.shr_s (i64.add (get_local $h6) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h7 (i64.add (get_local $h7) (get_local $carry6))) - (set_local $h6 (i64.sub (get_local $h6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 26))))) - - (set_local $carry3 (i64.shr_s (i64.add (get_local $h3) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) - (set_local $h4 (i64.add (get_local $h4) (get_local $carry3))) - (set_local $h3 (i64.sub (get_local $h3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 25))))) - (set_local $carry7 (i64.shr_s (i64.add (get_local $h7) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) - (set_local $h8 (i64.add (get_local $h8) (get_local $carry7))) - (set_local $h7 (i64.sub (get_local $h7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 25))))) - - (set_local $carry4 (i64.shr_s (i64.add (get_local $h4) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h5 (i64.add (get_local $h5) (get_local $carry4))) - (set_local $h4 (i64.sub (get_local $h4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 26))))) - (set_local $carry8 (i64.shr_s (i64.add (get_local $h8) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h9 (i64.add (get_local $h9) (get_local $carry8))) - (set_local $h8 (i64.sub (get_local $h8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 26))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $h9) (i64.shl (i64.const 1) (i64.const 24))) (i64.const 25))) - (set_local $h0 (i64.add (get_local $h0) (i64.mul (get_local $carry9) (i64.const 19)))) - (set_local $h9 (i64.sub (get_local $h9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 25))))) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $h0) (i64.shl (i64.const 1) (i64.const 25))) (i64.const 26))) - (set_local $h1 (i64.add (get_local $h1) (get_local $carry0))) - (set_local $h0 (i64.sub (get_local $h0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 26))))) - (i64.store32 offset=0 (get_local $h) (get_local $h0)) (i64.store32 offset=4 (get_local $h) (get_local $h1)) (i64.store32 offset=8 (get_local $h) (get_local $h2)) @@ -798,1972 +431,4 @@ (i64.store32 offset=24 (get_local $h) (get_local $h6)) (i64.store32 offset=28 (get_local $h) (get_local $h7)) (i64.store32 offset=32 (get_local $h) (get_local $h8)) - (i64.store32 offset=36 (get_local $h) (get_local $h9))) - - - (func $sc25519_mul (export "sc25519_mul") (param $s i32) (param $a i32) (param $b i32) - (local $tmp i64) - - (local $a0 i64) - (local $a1 i64) - (local $a2 i64) - (local $a3 i64) - (local $a4 i64) - (local $a5 i64) - (local $a6 i64) - (local $a7 i64) - (local $a8 i64) - (local $a9 i64) - (local $a10 i64) - (local $a11 i64) - - (local $b0 i64) - (local $b1 i64) - (local $b2 i64) - (local $b3 i64) - (local $b4 i64) - (local $b5 i64) - (local $b6 i64) - (local $b7 i64) - (local $b8 i64) - (local $b9 i64) - (local $b10 i64) - (local $b11 i64) - - (local $s0 i64) - (local $s1 i64) - (local $s2 i64) - (local $s3 i64) - (local $s4 i64) - (local $s5 i64) - (local $s6 i64) - (local $s7 i64) - (local $s8 i64) - (local $s9 i64) - (local $s10 i64) - (local $s11 i64) - (local $s12 i64) - (local $s13 i64) - (local $s14 i64) - (local $s15 i64) - (local $s16 i64) - (local $s17 i64) - (local $s18 i64) - (local $s19 i64) - (local $s20 i64) - (local $s21 i64) - (local $s22 i64) - (local $s23 i64) - - (local $carry0 i64) - (local $carry1 i64) - (local $carry2 i64) - (local $carry3 i64) - (local $carry4 i64) - (local $carry5 i64) - (local $carry6 i64) - (local $carry7 i64) - (local $carry8 i64) - (local $carry9 i64) - (local $carry10 i64) - (local $carry11 i64) - (local $carry12 i64) - (local $carry13 i64) - (local $carry14 i64) - (local $carry15 i64) - (local $carry16 i64) - (local $carry17 i64) - (local $carry18 i64) - (local $carry19 i64) - (local $carry20 i64) - (local $carry21 i64) - (local $carry22 i64) - - (set_local $a0 (i64.load32_u offset=0 (get_local $a))) - (set_local $a1 (i64.load32_u offset=4 (get_local $a))) - (set_local $a2 (i64.load32_u offset=8 (get_local $a))) - (set_local $a3 (i64.load32_u offset=12 (get_local $a))) - (set_local $a4 (i64.load32_u offset=16 (get_local $a))) - (set_local $a5 (i64.load32_u offset=20 (get_local $a))) - (set_local $a6 (i64.load32_u offset=24 (get_local $a))) - (set_local $a7 (i64.load32_u offset=28 (get_local $a))) - (set_local $a8 (i64.load32_u offset=32 (get_local $a))) - (set_local $a9 (i64.load32_u offset=36 (get_local $a))) - (set_local $a10 (i64.load32_u offset=40 (get_local $a))) - (set_local $a11 (i64.load32_u offset=44 (get_local $a))) - - (set_local $b0 (i64.load32_u offset=0 (get_local $b))) - (set_local $b1 (i64.load32_u offset=4 (get_local $b))) - (set_local $b2 (i64.load32_u offset=8 (get_local $b))) - (set_local $b3 (i64.load32_u offset=12 (get_local $b))) - (set_local $b4 (i64.load32_u offset=16 (get_local $b))) - (set_local $b5 (i64.load32_u offset=20 (get_local $b))) - (set_local $b6 (i64.load32_u offset=24 (get_local $b))) - (set_local $b7 (i64.load32_u offset=28 (get_local $b))) - (set_local $b8 (i64.load32_u offset=32 (get_local $b))) - (set_local $b9 (i64.load32_u offset=36 (get_local $b))) - (set_local $b10 (i64.load32_u offset=40 (get_local $b))) - (set_local $b11 (i64.load32_u offset=44 (get_local $b))) - - (call $extend_sign (get_local $a0)) - (set_local $a0) - (call $extend_sign (get_local $a1)) - (set_local $a1) - (call $extend_sign (get_local $a2)) - (set_local $a2) - (call $extend_sign (get_local $a3)) - (set_local $a3) - (call $extend_sign (get_local $a4)) - (set_local $a4) - (call $extend_sign (get_local $a5)) - (set_local $a5) - (call $extend_sign (get_local $a6)) - (set_local $a6) - (call $extend_sign (get_local $a7)) - (set_local $a7) - (call $extend_sign (get_local $a8)) - (set_local $a8) - (call $extend_sign (get_local $a9)) - (set_local $a9) - (call $extend_sign (get_local $a10)) - (set_local $a10) - (call $extend_sign (get_local $a11)) - (set_local $a11) - - (call $extend_sign (get_local $b0)) - (set_local $b0) - (call $extend_sign (get_local $b1)) - (set_local $b1) - (call $extend_sign (get_local $b2)) - (set_local $b2) - (call $extend_sign (get_local $b3)) - (set_local $b3) - (call $extend_sign (get_local $b4)) - (set_local $b4) - (call $extend_sign (get_local $b5)) - (set_local $b5) - (call $extend_sign (get_local $b6)) - (set_local $b6) - (call $extend_sign (get_local $b7)) - (set_local $b7) - (call $extend_sign (get_local $b8)) - (set_local $b8) - (call $extend_sign (get_local $b9)) - (set_local $b9) - (call $extend_sign (get_local $b10)) - (set_local $b10) - (call $extend_sign (get_local $b11)) - (set_local $b11) - - (set_local $s0 (i64.mul (get_local $a0) (get_local $b0))) - (set_local $s1 (i64.add (i64.mul (get_local $a0) (get_local $b1 )) (i64.mul (get_local $a1) (get_local $b0)))) - (set_local $s2 (i64.add (i64.mul (get_local $a0) (get_local $b2 )) (i64.add (i64.mul (get_local $a1) (get_local $b1 )) (i64.mul (get_local $a2) (get_local $b0))))) - (set_local $s3 (i64.add (i64.mul (get_local $a0) (get_local $b3 )) (i64.add (i64.mul (get_local $a1) (get_local $b2 )) (i64.add (i64.mul (get_local $a2) (get_local $b1)) (i64.mul (get_local $a3) (get_local $b0)))))) - (set_local $s4 (i64.add (i64.mul (get_local $a0) (get_local $b4 )) (i64.add (i64.mul (get_local $a1) (get_local $b3 )) (i64.add (i64.mul (get_local $a2) (get_local $b2)) (i64.add (i64.mul (get_local $a3) (get_local $b1)) (i64.mul (get_local $a4) (get_local $b0))))))) - (set_local $s5 (i64.add (i64.mul (get_local $a0) (get_local $b5 )) (i64.add (i64.mul (get_local $a1) (get_local $b4 )) (i64.add (i64.mul (get_local $a2) (get_local $b3)) (i64.add (i64.mul (get_local $a3) (get_local $b2)) (i64.add (i64.mul (get_local $a4) (get_local $b1)) (i64.mul (get_local $a5) (get_local $b0)))))))) - (set_local $s6 (i64.add (i64.mul (get_local $a0) (get_local $b6 )) (i64.add (i64.mul (get_local $a1) (get_local $b5 )) (i64.add (i64.mul (get_local $a2) (get_local $b4)) (i64.add (i64.mul (get_local $a3) (get_local $b3)) (i64.add (i64.mul (get_local $a4) (get_local $b2)) (i64.add (i64.mul (get_local $a5) (get_local $b1)) (i64.mul (get_local $a6) (get_local $b0))))))))) - (set_local $s7 (i64.add (i64.mul (get_local $a0) (get_local $b7 )) (i64.add (i64.mul (get_local $a1) (get_local $b6 )) (i64.add (i64.mul (get_local $a2) (get_local $b5)) (i64.add (i64.mul (get_local $a3) (get_local $b4)) (i64.add (i64.mul (get_local $a4) (get_local $b3)) (i64.add (i64.mul (get_local $a5) (get_local $b2)) (i64.add (i64.mul (get_local $a6) (get_local $b1)) (i64.mul (get_local $a7) (get_local $b0)))))))))) - (set_local $s8 (i64.add (i64.mul (get_local $a0) (get_local $b8 )) (i64.add (i64.mul (get_local $a1) (get_local $b7 )) (i64.add (i64.mul (get_local $a2) (get_local $b6)) (i64.add (i64.mul (get_local $a3) (get_local $b5)) (i64.add (i64.mul (get_local $a4) (get_local $b4)) (i64.add (i64.mul (get_local $a5) (get_local $b3)) (i64.add (i64.mul (get_local $a6) (get_local $b2)) (i64.add (i64.mul (get_local $a7) (get_local $b1)) (i64.mul (get_local $a8) (get_local $b0))))))))))) - (set_local $s9 (i64.add (i64.mul (get_local $a0) (get_local $b9 )) (i64.add (i64.mul (get_local $a1) (get_local $b8 )) (i64.add (i64.mul (get_local $a2) (get_local $b7)) (i64.add (i64.mul (get_local $a3) (get_local $b6)) (i64.add (i64.mul (get_local $a4) (get_local $b5)) (i64.add (i64.mul (get_local $a5) (get_local $b4)) (i64.add (i64.mul (get_local $a6) (get_local $b3)) (i64.add (i64.mul (get_local $a7) (get_local $b2)) (i64.add (i64.mul (get_local $a8) (get_local $b1)) (i64.mul (get_local $a9) (get_local $b0)))))))))))) - (set_local $s10 (i64.add (i64.mul (get_local $a0) (get_local $b10)) (i64.add (i64.mul (get_local $a1) (get_local $b9 )) (i64.add (i64.mul (get_local $a2) (get_local $b8)) (i64.add (i64.mul (get_local $a3) (get_local $b7)) (i64.add (i64.mul (get_local $a4) (get_local $b6)) (i64.add (i64.mul (get_local $a5) (get_local $b5)) (i64.add (i64.mul (get_local $a6) (get_local $b4)) (i64.add (i64.mul (get_local $a7) (get_local $b3)) (i64.add (i64.mul (get_local $a8) (get_local $b2)) (i64.add (i64.mul (get_local $a9) (get_local $b1)) (i64.mul (get_local $a10) (get_local $b0))))))))))))) - (set_local $s11 (i64.add (i64.mul (get_local $a0) (get_local $b11)) (i64.add (i64.mul (get_local $a1) (get_local $b10)) (i64.add (i64.mul (get_local $a2) (get_local $b9)) (i64.add (i64.mul (get_local $a3) (get_local $b8)) (i64.add (i64.mul (get_local $a4) (get_local $b7)) (i64.add (i64.mul (get_local $a5) (get_local $b6)) (i64.add (i64.mul (get_local $a6) (get_local $b5)) (i64.add (i64.mul (get_local $a7) (get_local $b4)) (i64.add (i64.mul (get_local $a8) (get_local $b3)) (i64.add (i64.mul (get_local $a9) (get_local $b2)) (i64.add (i64.mul (get_local $a10) (get_local $b1)) (i64.mul (get_local $a11) (get_local $b0)))))))))))))) - (set_local $s12 (i64.add (i64.mul (get_local $a1) (get_local $b11)) (i64.add (i64.mul (get_local $a2) (get_local $b10)) (i64.add (i64.mul (get_local $a3) (get_local $b9)) (i64.add (i64.mul (get_local $a4) (get_local $b8)) (i64.add (i64.mul (get_local $a5) (get_local $b7)) (i64.add (i64.mul (get_local $a6) (get_local $b6)) (i64.add (i64.mul (get_local $a7) (get_local $b5)) (i64.add (i64.mul (get_local $a8) (get_local $b4)) (i64.add (i64.mul (get_local $a9) (get_local $b3)) (i64.add (i64.mul (get_local $a10) (get_local $b2)) (i64.mul (get_local $a11) (get_local $b1))))))))))))) - (set_local $s13 (i64.add (i64.mul (get_local $a2) (get_local $b11)) (i64.add (i64.mul (get_local $a3) (get_local $b10)) (i64.add (i64.mul (get_local $a4) (get_local $b9)) (i64.add (i64.mul (get_local $a5) (get_local $b8)) (i64.add (i64.mul (get_local $a6) (get_local $b7)) (i64.add (i64.mul (get_local $a7) (get_local $b6)) (i64.add (i64.mul (get_local $a8) (get_local $b5)) (i64.add (i64.mul (get_local $a9) (get_local $b4)) (i64.add (i64.mul (get_local $a10) (get_local $b3)) (i64.mul (get_local $a11) (get_local $b2)))))))))))) - (set_local $s14 (i64.add (i64.mul (get_local $a3) (get_local $b11)) (i64.add (i64.mul (get_local $a4) (get_local $b10)) (i64.add (i64.mul (get_local $a5) (get_local $b9)) (i64.add (i64.mul (get_local $a6) (get_local $b8)) (i64.add (i64.mul (get_local $a7) (get_local $b7)) (i64.add (i64.mul (get_local $a8) (get_local $b6)) (i64.add (i64.mul (get_local $a9) (get_local $b5)) (i64.add (i64.mul (get_local $a10) (get_local $b4)) (i64.mul (get_local $a11) (get_local $b3))))))))))) - (set_local $s15 (i64.add (i64.mul (get_local $a4) (get_local $b11)) (i64.add (i64.mul (get_local $a5) (get_local $b10)) (i64.add (i64.mul (get_local $a6) (get_local $b9)) (i64.add (i64.mul (get_local $a7) (get_local $b8)) (i64.add (i64.mul (get_local $a8) (get_local $b7)) (i64.add (i64.mul (get_local $a9) (get_local $b6)) (i64.add (i64.mul (get_local $a10) (get_local $b5)) (i64.mul (get_local $a11) (get_local $b4)))))))))) - (set_local $s16 (i64.add (i64.mul (get_local $a5) (get_local $b11)) (i64.add (i64.mul (get_local $a6) (get_local $b10)) (i64.add (i64.mul (get_local $a7) (get_local $b9)) (i64.add (i64.mul (get_local $a8) (get_local $b8)) (i64.add (i64.mul (get_local $a9) (get_local $b7)) (i64.add (i64.mul (get_local $a10) (get_local $b6)) (i64.mul (get_local $a11) (get_local $b5))))))))) - (set_local $s17 (i64.add (i64.mul (get_local $a6) (get_local $b11)) (i64.add (i64.mul (get_local $a7) (get_local $b10)) (i64.add (i64.mul (get_local $a8) (get_local $b9)) (i64.add (i64.mul (get_local $a9) (get_local $b8)) (i64.add (i64.mul (get_local $a10) (get_local $b7)) (i64.mul (get_local $a11) (get_local $b6)))))))) - (set_local $s18 (i64.add (i64.mul (get_local $a7) (get_local $b11)) (i64.add (i64.mul (get_local $a8) (get_local $b10)) (i64.add (i64.mul (get_local $a9) (get_local $b9)) (i64.add (i64.mul (get_local $a10) (get_local $b8)) (i64.mul (get_local $a11) (get_local $b7))))))) - (set_local $s19 (i64.add (i64.mul (get_local $a8) (get_local $b11)) (i64.add (i64.mul (get_local $a9) (get_local $b10)) (i64.add (i64.mul (get_local $a10) (get_local $b9)) (i64.mul (get_local $a11) (get_local $b8)))))) - (set_local $s20 (i64.add (i64.mul (get_local $a9) (get_local $b11)) (i64.add (i64.mul (get_local $a10) (get_local $b10)) (i64.mul (get_local $a11) (get_local $b9))))) - (set_local $s21 (i64.add (i64.mul (get_local $a10) (get_local $b11)) (i64.mul (get_local $a11) (get_local $b10)))) - (set_local $s22 (i64.mul (get_local $a11) (get_local $b11))) - (set_local $s23 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry18 (i64.shr_s (i64.add (get_local $s18) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s19 (i64.add (get_local $s19) (get_local $carry18))) - (set_local $s18 (i64.sub (get_local $s18) (i64.mul (get_local $carry18) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry20 (i64.shr_s (i64.add (get_local $s20) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s21 (i64.add (get_local $s21) (get_local $carry20))) - (set_local $s20 (i64.sub (get_local $s20) (i64.mul (get_local $carry20) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry22 (i64.shr_s (i64.add (get_local $s22) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s23 (i64.add (get_local $s23) (get_local $carry22))) - (set_local $s22 (i64.sub (get_local $s22) (i64.mul (get_local $carry22) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry17 (i64.shr_s (i64.add (get_local $s17) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s18 (i64.add (get_local $s18) (get_local $carry17))) - (set_local $s17 (i64.sub (get_local $s17) (i64.mul (get_local $carry17) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry19 (i64.shr_s (i64.add (get_local $s19) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s20 (i64.add (get_local $s20) (get_local $carry19))) - (set_local $s19 (i64.sub (get_local $s19) (i64.mul (get_local $carry19) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry21 (i64.shr_s (i64.add (get_local $s21) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s22 (i64.add (get_local $s22) (get_local $carry21))) - (set_local $s21 (i64.sub (get_local $s21) (i64.mul (get_local $carry21) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s23) (i64.const 666643)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s23) (i64.const 470296)))) - (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s23) (i64.const 654183)))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s23) (i64.const 997805)))) - (set_local $s15 (i64.add (get_local $s15) (i64.mul (get_local $s23) (i64.const 136657)))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $s23) (i64.const 683901)))) - - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s22) (i64.const 666643)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s22) (i64.const 470296)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s22) (i64.const 654183)))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s22) (i64.const 997805)))) - (set_local $s14 (i64.add (get_local $s14) (i64.mul (get_local $s22) (i64.const 136657)))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $s22) (i64.const 683901)))) - - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s21) (i64.const 666643)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s21) (i64.const 470296)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s21) (i64.const 654183)))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s21) (i64.const 997805)))) - (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s21) (i64.const 136657)))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s21) (i64.const 683901)))) - - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s20) (i64.const 666643)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s20) (i64.const 470296)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s20) (i64.const 654183)))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s20) (i64.const 997805)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s20) (i64.const 136657)))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s20) (i64.const 683901)))) - - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s19) (i64.const 666643)))) - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s19) (i64.const 470296)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s19) (i64.const 654183)))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s19) (i64.const 997805)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s19) (i64.const 136657)))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s19) (i64.const 683901)))) - - (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s18) (i64.const 666643)))) - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s18) (i64.const 470296)))) - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s18) (i64.const 654183)))) - (set_local $s9 (i64.sub (get_local $s9 ) (i64.mul (get_local $s18) (i64.const 997805)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s18) (i64.const 136657)))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s18) (i64.const 683901)))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s5 (i64.add (get_local $s5 ) (i64.mul (get_local $s17) (i64.const 666643)))) - (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s17) (i64.const 470296)))) - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s17) (i64.const 654183)))) - (set_local $s8 (i64.sub (get_local $s8 ) (i64.mul (get_local $s17) (i64.const 997805)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s17) (i64.const 136657)))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s17) (i64.const 683901)))) - - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s16) (i64.const 666643)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s16) (i64.const 470296)))) - (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s16) (i64.const 654183)))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s16) (i64.const 997805)))) - (set_local $s8 (i64.add (get_local $s8) (i64.mul (get_local $s16) (i64.const 136657)))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $s16) (i64.const 683901)))) - - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s15) (i64.const 666643)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s15) (i64.const 470296)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s15) (i64.const 654183)))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s15) (i64.const 997805)))) - (set_local $s7 (i64.add (get_local $s7) (i64.mul (get_local $s15) (i64.const 136657)))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $s15) (i64.const 683901)))) - - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s14) (i64.const 666643)))) - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s14) (i64.const 470296)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s14) (i64.const 654183)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s14) (i64.const 997805)))) - (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s14) (i64.const 136657)))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s14) (i64.const 683901)))) - - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s13) (i64.const 666643)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s13) (i64.const 470296)))) - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s13) (i64.const 654183)))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $s13) (i64.const 997805)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s13) (i64.const 136657)))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s13) (i64.const 683901)))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - (set_local $s12 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - (set_local $s12 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (get_local $s11) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - - (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (get_local $s) - - (i64.and (get_local $s0) (i64.const 0xff)) - (i64.and (get_local $s0) (i64.const 0xff00)) - (i64.or) - (get_local $s0) - (i64.shl (i64.mul (get_local $s1) (i64.const 32)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.shl (i64.mul (get_local $s2) (i64.const 4)) (i64.const 40)) - (i64.or) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s2) (i64.const 42)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s2) (i64.const 42)) - (i64.shl (i64.mul (get_local $s3) (i64.const 128)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=0) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s3) (i64.const 1)) - (i64.shl (i64.mul (get_local $s4) (i64.const 16)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.shl (i64.mul (get_local $s5) (i64.const 2)) (i64.const 40)) - (i64.or) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s5) (i64.const 41)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s5) (i64.const 41)) - (i64.shl (i64.mul (get_local $s6) (i64.const 64)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=8) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s6) (i64.const 2)) - (i64.shl (i64.mul (get_local $s7) (i64.const 8)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s7) (i64.const 19)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s7) (i64.const 19)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.shl (i64.mul (get_local $s9) (i64.const 32)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=16) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s9) (i64.const 3)) - (i64.shl (i64.mul (get_local $s10) (i64.const 4)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s10) (i64.const 18)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s10) (i64.const 18)) - (i64.shl (i64.mul (get_local $s11) (i64.const 128)) (i64.const 32)) - (i64.or) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=24)) - - (func $sc25519_muladd (export "sc25519_muladd") (param $s i32) (param $a i32) (param $b i32) (param $c i32) - (local $tmp i64) - - (local $a0 i64) - (local $a1 i64) - (local $a2 i64) - (local $a3 i64) - (local $a4 i64) - (local $a5 i64) - (local $a6 i64) - (local $a7 i64) - (local $a8 i64) - (local $a9 i64) - (local $a10 i64) - (local $a11 i64) - - (local $b0 i64) - (local $b1 i64) - (local $b2 i64) - (local $b3 i64) - (local $b4 i64) - (local $b5 i64) - (local $b6 i64) - (local $b7 i64) - (local $b8 i64) - (local $b9 i64) - (local $b10 i64) - (local $b11 i64) - - (local $c0 i64) - (local $c1 i64) - (local $c2 i64) - (local $c3 i64) - (local $c4 i64) - (local $c5 i64) - (local $c6 i64) - (local $c7 i64) - (local $c8 i64) - (local $c9 i64) - (local $c10 i64) - (local $c11 i64) - - (local $s0 i64) - (local $s1 i64) - (local $s2 i64) - (local $s3 i64) - (local $s4 i64) - (local $s5 i64) - (local $s6 i64) - (local $s7 i64) - (local $s8 i64) - (local $s9 i64) - (local $s10 i64) - (local $s11 i64) - (local $s12 i64) - (local $s13 i64) - (local $s14 i64) - (local $s15 i64) - (local $s16 i64) - (local $s17 i64) - (local $s18 i64) - (local $s19 i64) - (local $s20 i64) - (local $s21 i64) - (local $s22 i64) - (local $s23 i64) - - (local $carry0 i64) - (local $carry1 i64) - (local $carry2 i64) - (local $carry3 i64) - (local $carry4 i64) - (local $carry5 i64) - (local $carry6 i64) - (local $carry7 i64) - (local $carry8 i64) - (local $carry9 i64) - (local $carry10 i64) - (local $carry11 i64) - (local $carry12 i64) - (local $carry13 i64) - (local $carry14 i64) - (local $carry15 i64) - (local $carry16 i64) - (local $carry17 i64) - (local $carry18 i64) - (local $carry19 i64) - (local $carry20 i64) - (local $carry21 i64) - (local $carry22 i64) - - (set_local $a0 (i64.load32_u offset=0 (get_local $a))) - (set_local $a1 (i64.load32_u offset=4 (get_local $a))) - (set_local $a2 (i64.load32_u offset=8 (get_local $a))) - (set_local $a3 (i64.load32_u offset=12 (get_local $a))) - (set_local $a4 (i64.load32_u offset=16 (get_local $a))) - (set_local $a5 (i64.load32_u offset=20 (get_local $a))) - (set_local $a6 (i64.load32_u offset=24 (get_local $a))) - (set_local $a7 (i64.load32_u offset=28 (get_local $a))) - (set_local $a8 (i64.load32_u offset=32 (get_local $a))) - (set_local $a9 (i64.load32_u offset=36 (get_local $a))) - (set_local $a10 (i64.load32_u offset=40 (get_local $a))) - (set_local $a11 (i64.load32_u offset=44 (get_local $a))) - - (set_local $b0 (i64.load32_u offset=0 (get_local $b))) - (set_local $b1 (i64.load32_u offset=4 (get_local $b))) - (set_local $b2 (i64.load32_u offset=8 (get_local $b))) - (set_local $b3 (i64.load32_u offset=12 (get_local $b))) - (set_local $b4 (i64.load32_u offset=16 (get_local $b))) - (set_local $b5 (i64.load32_u offset=20 (get_local $b))) - (set_local $b6 (i64.load32_u offset=24 (get_local $b))) - (set_local $b7 (i64.load32_u offset=28 (get_local $b))) - (set_local $b8 (i64.load32_u offset=32 (get_local $b))) - (set_local $b9 (i64.load32_u offset=36 (get_local $b))) - (set_local $b10 (i64.load32_u offset=40 (get_local $b))) - (set_local $b11 (i64.load32_u offset=44 (get_local $b))) - - (set_local $c0 (i64.load32_u offset=0 (get_local $c))) - (set_local $c1 (i64.load32_u offset=4 (get_local $c))) - (set_local $c2 (i64.load32_u offset=8 (get_local $c))) - (set_local $c3 (i64.load32_u offset=12 (get_local $c))) - (set_local $c4 (i64.load32_u offset=16 (get_local $c))) - (set_local $c5 (i64.load32_u offset=20 (get_local $c))) - (set_local $c6 (i64.load32_u offset=24 (get_local $c))) - (set_local $c7 (i64.load32_u offset=28 (get_local $c))) - (set_local $c8 (i64.load32_u offset=32 (get_local $c))) - (set_local $c9 (i64.load32_u offset=36 (get_local $c))) - (set_local $c10 (i64.load32_u offset=40 (get_local $c))) - (set_local $c11 (i64.load32_u offset=44 (get_local $c))) - - (call $extend_sign (get_local $a0)) - (set_local $a0) - (call $extend_sign (get_local $a1)) - (set_local $a1) - (call $extend_sign (get_local $a2)) - (set_local $a2) - (call $extend_sign (get_local $a3)) - (set_local $a3) - (call $extend_sign (get_local $a4)) - (set_local $a4) - (call $extend_sign (get_local $a5)) - (set_local $a5) - (call $extend_sign (get_local $a6)) - (set_local $a6) - (call $extend_sign (get_local $a7)) - (set_local $a7) - (call $extend_sign (get_local $a8)) - (set_local $a8) - (call $extend_sign (get_local $a9)) - (set_local $a9) - (call $extend_sign (get_local $a10)) - (set_local $a10) - (call $extend_sign (get_local $a11)) - (set_local $a11) - - (call $extend_sign (get_local $b0)) - (set_local $b0) - (call $extend_sign (get_local $b1)) - (set_local $b1) - (call $extend_sign (get_local $b2)) - (set_local $b2) - (call $extend_sign (get_local $b3)) - (set_local $b3) - (call $extend_sign (get_local $b4)) - (set_local $b4) - (call $extend_sign (get_local $b5)) - (set_local $b5) - (call $extend_sign (get_local $b6)) - (set_local $b6) - (call $extend_sign (get_local $b7)) - (set_local $b7) - (call $extend_sign (get_local $b8)) - (set_local $b8) - (call $extend_sign (get_local $b9)) - (set_local $b9) - (call $extend_sign (get_local $b10)) - (set_local $b10) - (call $extend_sign (get_local $b11)) - (set_local $b11) - - (call $extend_sign (get_local $c0)) - (set_local $c0) - (call $extend_sign (get_local $c1)) - (set_local $c1) - (call $extend_sign (get_local $c2)) - (set_local $c2) - (call $extend_sign (get_local $c3)) - (set_local $c3) - (call $extend_sign (get_local $c4)) - (set_local $c4) - (call $extend_sign (get_local $c5)) - (set_local $c5) - (call $extend_sign (get_local $c6)) - (set_local $c6) - (call $extend_sign (get_local $c7)) - (set_local $c7) - (call $extend_sign (get_local $c8)) - (set_local $c8) - (call $extend_sign (get_local $c9)) - (set_local $c9) - (call $extend_sign (get_local $c10)) - (set_local $c10) - (call $extend_sign (get_local $c11)) - (set_local $c11) - - (set_local $s0 (i64.add (get_local $c0 ) (i64.mul (get_local $a0) (get_local $b0)))) - (set_local $s1 (i64.add (get_local $c1 ) (i64.add (i64.mul (get_local $a0) (get_local $b1 )) (i64.mul (get_local $a1) (get_local $b0))))) - (set_local $s2 (i64.add (get_local $c2 ) (i64.add (i64.mul (get_local $a0) (get_local $b2 )) (i64.add (i64.mul (get_local $a1) (get_local $b1 )) (i64.mul (get_local $a2) (get_local $b0)))))) - (set_local $s3 (i64.add (get_local $c3 ) (i64.add (i64.mul (get_local $a0) (get_local $b3 )) (i64.add (i64.mul (get_local $a1) (get_local $b2 )) (i64.add (i64.mul (get_local $a2) (get_local $b1)) (i64.mul (get_local $a3) (get_local $b0))))))) - (set_local $s4 (i64.add (get_local $c4 ) (i64.add (i64.mul (get_local $a0) (get_local $b4 )) (i64.add (i64.mul (get_local $a1) (get_local $b3 )) (i64.add (i64.mul (get_local $a2) (get_local $b2)) (i64.add (i64.mul (get_local $a3) (get_local $b1)) (i64.mul (get_local $a4) (get_local $b0)))))))) - (set_local $s5 (i64.add (get_local $c5 ) (i64.add (i64.mul (get_local $a0) (get_local $b5 )) (i64.add (i64.mul (get_local $a1) (get_local $b4 )) (i64.add (i64.mul (get_local $a2) (get_local $b3)) (i64.add (i64.mul (get_local $a3) (get_local $b2)) (i64.add (i64.mul (get_local $a4) (get_local $b1)) (i64.mul (get_local $a5) (get_local $b0))))))))) - (set_local $s6 (i64.add (get_local $c6 ) (i64.add (i64.mul (get_local $a0) (get_local $b6 )) (i64.add (i64.mul (get_local $a1) (get_local $b5 )) (i64.add (i64.mul (get_local $a2) (get_local $b4)) (i64.add (i64.mul (get_local $a3) (get_local $b3)) (i64.add (i64.mul (get_local $a4) (get_local $b2)) (i64.add (i64.mul (get_local $a5) (get_local $b1)) (i64.mul (get_local $a6) (get_local $b0)))))))))) - (set_local $s7 (i64.add (get_local $c7 ) (i64.add (i64.mul (get_local $a0) (get_local $b7 )) (i64.add (i64.mul (get_local $a1) (get_local $b6 )) (i64.add (i64.mul (get_local $a2) (get_local $b5)) (i64.add (i64.mul (get_local $a3) (get_local $b4)) (i64.add (i64.mul (get_local $a4) (get_local $b3)) (i64.add (i64.mul (get_local $a5) (get_local $b2)) (i64.add (i64.mul (get_local $a6) (get_local $b1)) (i64.mul (get_local $a7) (get_local $b0))))))))))) - (set_local $s8 (i64.add (get_local $c8 ) (i64.add (i64.mul (get_local $a0) (get_local $b8 )) (i64.add (i64.mul (get_local $a1) (get_local $b7 )) (i64.add (i64.mul (get_local $a2) (get_local $b6)) (i64.add (i64.mul (get_local $a3) (get_local $b5)) (i64.add (i64.mul (get_local $a4) (get_local $b4)) (i64.add (i64.mul (get_local $a5) (get_local $b3)) (i64.add (i64.mul (get_local $a6) (get_local $b2)) (i64.add (i64.mul (get_local $a7) (get_local $b1)) (i64.mul (get_local $a8) (get_local $b0)))))))))))) - (set_local $s9 (i64.add (get_local $c9 ) (i64.add (i64.mul (get_local $a0) (get_local $b9 )) (i64.add (i64.mul (get_local $a1) (get_local $b8 )) (i64.add (i64.mul (get_local $a2) (get_local $b7)) (i64.add (i64.mul (get_local $a3) (get_local $b6)) (i64.add (i64.mul (get_local $a4) (get_local $b5)) (i64.add (i64.mul (get_local $a5) (get_local $b4)) (i64.add (i64.mul (get_local $a6) (get_local $b3)) (i64.add (i64.mul (get_local $a7) (get_local $b2)) (i64.add (i64.mul (get_local $a8) (get_local $b1)) (i64.mul (get_local $a9) (get_local $b0))))))))))))) - (set_local $s10 (i64.add (get_local $c10) (i64.add (i64.mul (get_local $a0) (get_local $b10)) (i64.add (i64.mul (get_local $a1) (get_local $b9 )) (i64.add (i64.mul (get_local $a2) (get_local $b8)) (i64.add (i64.mul (get_local $a3) (get_local $b7)) (i64.add (i64.mul (get_local $a4) (get_local $b6)) (i64.add (i64.mul (get_local $a5) (get_local $b5)) (i64.add (i64.mul (get_local $a6) (get_local $b4)) (i64.add (i64.mul (get_local $a7) (get_local $b3)) (i64.add (i64.mul (get_local $a8) (get_local $b2)) (i64.add (i64.mul (get_local $a9) (get_local $b1)) (i64.mul (get_local $a10) (get_local $b0)))))))))))))) - (set_local $s11 (i64.add (get_local $c11) (i64.add (i64.mul (get_local $a0) (get_local $b11)) (i64.add (i64.mul (get_local $a1) (get_local $b10)) (i64.add (i64.mul (get_local $a2) (get_local $b9)) (i64.add (i64.mul (get_local $a3) (get_local $b8)) (i64.add (i64.mul (get_local $a4) (get_local $b7)) (i64.add (i64.mul (get_local $a5) (get_local $b6)) (i64.add (i64.mul (get_local $a6) (get_local $b5)) (i64.add (i64.mul (get_local $a7) (get_local $b4)) (i64.add (i64.mul (get_local $a8) (get_local $b3)) (i64.add (i64.mul (get_local $a9) (get_local $b2)) (i64.add (i64.mul (get_local $a10) (get_local $b1)) (i64.mul (get_local $a11) (get_local $b0))))))))))))))) - (set_local $s12 (i64.add (i64.mul (get_local $a1) (get_local $b11)) (i64.add (i64.mul (get_local $a2) (get_local $b10)) (i64.add (i64.mul (get_local $a3) (get_local $b9)) (i64.add (i64.mul (get_local $a4) (get_local $b8)) (i64.add (i64.mul (get_local $a5) (get_local $b7)) (i64.add (i64.mul (get_local $a6) (get_local $b6)) (i64.add (i64.mul (get_local $a7) (get_local $b5)) (i64.add (i64.mul (get_local $a8) (get_local $b4)) (i64.add (i64.mul (get_local $a9) (get_local $b3)) (i64.add (i64.mul (get_local $a10) (get_local $b2)) (i64.mul (get_local $a11) (get_local $b1))))))))))))) - (set_local $s13 (i64.add (i64.mul (get_local $a2) (get_local $b11)) (i64.add (i64.mul (get_local $a3) (get_local $b10)) (i64.add (i64.mul (get_local $a4) (get_local $b9)) (i64.add (i64.mul (get_local $a5) (get_local $b8)) (i64.add (i64.mul (get_local $a6) (get_local $b7)) (i64.add (i64.mul (get_local $a7) (get_local $b6)) (i64.add (i64.mul (get_local $a8) (get_local $b5)) (i64.add (i64.mul (get_local $a9) (get_local $b4)) (i64.add (i64.mul (get_local $a10) (get_local $b3)) (i64.mul (get_local $a11) (get_local $b2)))))))))))) - (set_local $s14 (i64.add (i64.mul (get_local $a3) (get_local $b11)) (i64.add (i64.mul (get_local $a4) (get_local $b10)) (i64.add (i64.mul (get_local $a5) (get_local $b9)) (i64.add (i64.mul (get_local $a6) (get_local $b8)) (i64.add (i64.mul (get_local $a7) (get_local $b7)) (i64.add (i64.mul (get_local $a8) (get_local $b6)) (i64.add (i64.mul (get_local $a9) (get_local $b5)) (i64.add (i64.mul (get_local $a10) (get_local $b4)) (i64.mul (get_local $a11) (get_local $b3))))))))))) - (set_local $s15 (i64.add (i64.mul (get_local $a4) (get_local $b11)) (i64.add (i64.mul (get_local $a5) (get_local $b10)) (i64.add (i64.mul (get_local $a6) (get_local $b9)) (i64.add (i64.mul (get_local $a7) (get_local $b8)) (i64.add (i64.mul (get_local $a8) (get_local $b7)) (i64.add (i64.mul (get_local $a9) (get_local $b6)) (i64.add (i64.mul (get_local $a10) (get_local $b5)) (i64.mul (get_local $a11) (get_local $b4)))))))))) - (set_local $s16 (i64.add (i64.mul (get_local $a5) (get_local $b11)) (i64.add (i64.mul (get_local $a6) (get_local $b10)) (i64.add (i64.mul (get_local $a7) (get_local $b9)) (i64.add (i64.mul (get_local $a8) (get_local $b8)) (i64.add (i64.mul (get_local $a9) (get_local $b7)) (i64.add (i64.mul (get_local $a10) (get_local $b6)) (i64.mul (get_local $a11) (get_local $b5))))))))) - (set_local $s17 (i64.add (i64.mul (get_local $a6) (get_local $b11)) (i64.add (i64.mul (get_local $a7) (get_local $b10)) (i64.add (i64.mul (get_local $a8) (get_local $b9)) (i64.add (i64.mul (get_local $a9) (get_local $b8)) (i64.add (i64.mul (get_local $a10) (get_local $b7)) (i64.mul (get_local $a11) (get_local $b6)))))))) - (set_local $s18 (i64.add (i64.mul (get_local $a7) (get_local $b11)) (i64.add (i64.mul (get_local $a8) (get_local $b10)) (i64.add (i64.mul (get_local $a9) (get_local $b9)) (i64.add (i64.mul (get_local $a10) (get_local $b8)) (i64.mul (get_local $a11) (get_local $b7))))))) - (set_local $s19 (i64.add (i64.mul (get_local $a8) (get_local $b11)) (i64.add (i64.mul (get_local $a9) (get_local $b10)) (i64.add (i64.mul (get_local $a10) (get_local $b9)) (i64.mul (get_local $a11) (get_local $b8)))))) - (set_local $s20 (i64.add (i64.mul (get_local $a9) (get_local $b11)) (i64.add (i64.mul (get_local $a10) (get_local $b10)) (i64.mul (get_local $a11) (get_local $b9))))) - (set_local $s21 (i64.add (i64.mul (get_local $a10) (get_local $b11)) (i64.mul (get_local $a11) (get_local $b10)))) - (set_local $s22 (i64.mul (get_local $a11) (get_local $b11))) - (set_local $s23 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry18 (i64.shr_s (i64.add (get_local $s18) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s19 (i64.add (get_local $s19) (get_local $carry18))) - (set_local $s18 (i64.sub (get_local $s18) (i64.mul (get_local $carry18) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry20 (i64.shr_s (i64.add (get_local $s20) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s21 (i64.add (get_local $s21) (get_local $carry20))) - (set_local $s20 (i64.sub (get_local $s20) (i64.mul (get_local $carry20) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry22 (i64.shr_s (i64.add (get_local $s22) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s23 (i64.add (get_local $s23) (get_local $carry22))) - (set_local $s22 (i64.sub (get_local $s22) (i64.mul (get_local $carry22) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry17 (i64.shr_s (i64.add (get_local $s17) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s18 (i64.add (get_local $s18) (get_local $carry17))) - (set_local $s17 (i64.sub (get_local $s17) (i64.mul (get_local $carry17) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry19 (i64.shr_s (i64.add (get_local $s19) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s20 (i64.add (get_local $s20) (get_local $carry19))) - (set_local $s19 (i64.sub (get_local $s19) (i64.mul (get_local $carry19) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry21 (i64.shr_s (i64.add (get_local $s21) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s22 (i64.add (get_local $s22) (get_local $carry21))) - (set_local $s21 (i64.sub (get_local $s21) (i64.mul (get_local $carry21) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s23) (i64.const 666643)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s23) (i64.const 470296)))) - (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s23) (i64.const 654183)))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s23) (i64.const 997805)))) - (set_local $s15 (i64.add (get_local $s15) (i64.mul (get_local $s23) (i64.const 136657)))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $s23) (i64.const 683901)))) - - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s22) (i64.const 666643)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s22) (i64.const 470296)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s22) (i64.const 654183)))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s22) (i64.const 997805)))) - (set_local $s14 (i64.add (get_local $s14) (i64.mul (get_local $s22) (i64.const 136657)))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $s22) (i64.const 683901)))) - - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s21) (i64.const 666643)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s21) (i64.const 470296)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s21) (i64.const 654183)))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s21) (i64.const 997805)))) - (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s21) (i64.const 136657)))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s21) (i64.const 683901)))) - - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s20) (i64.const 666643)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s20) (i64.const 470296)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s20) (i64.const 654183)))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s20) (i64.const 997805)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s20) (i64.const 136657)))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s20) (i64.const 683901)))) - - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s19) (i64.const 666643)))) - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s19) (i64.const 470296)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s19) (i64.const 654183)))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s19) (i64.const 997805)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s19) (i64.const 136657)))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s19) (i64.const 683901)))) - - (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s18) (i64.const 666643)))) - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s18) (i64.const 470296)))) - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s18) (i64.const 654183)))) - (set_local $s9 (i64.sub (get_local $s9 ) (i64.mul (get_local $s18) (i64.const 997805)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s18) (i64.const 136657)))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s18) (i64.const 683901)))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s5 (i64.add (get_local $s5 ) (i64.mul (get_local $s17) (i64.const 666643)))) - (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s17) (i64.const 470296)))) - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s17) (i64.const 654183)))) - (set_local $s8 (i64.sub (get_local $s8 ) (i64.mul (get_local $s17) (i64.const 997805)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s17) (i64.const 136657)))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s17) (i64.const 683901)))) - - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s16) (i64.const 666643)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s16) (i64.const 470296)))) - (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s16) (i64.const 654183)))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s16) (i64.const 997805)))) - (set_local $s8 (i64.add (get_local $s8) (i64.mul (get_local $s16) (i64.const 136657)))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $s16) (i64.const 683901)))) - - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s15) (i64.const 666643)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s15) (i64.const 470296)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s15) (i64.const 654183)))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s15) (i64.const 997805)))) - (set_local $s7 (i64.add (get_local $s7) (i64.mul (get_local $s15) (i64.const 136657)))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $s15) (i64.const 683901)))) - - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s14) (i64.const 666643)))) - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s14) (i64.const 470296)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s14) (i64.const 654183)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s14) (i64.const 997805)))) - (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s14) (i64.const 136657)))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s14) (i64.const 683901)))) - - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s13) (i64.const 666643)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s13) (i64.const 470296)))) - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s13) (i64.const 654183)))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $s13) (i64.const 997805)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s13) (i64.const 136657)))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s13) (i64.const 683901)))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - (set_local $s12 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - (set_local $s12 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (get_local $s11) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - - (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (get_local $s) - - (i64.and (get_local $s0) (i64.const 0xff)) - (i64.and (get_local $s0) (i64.const 0xff00)) - (i64.or) - (get_local $s0) - (i64.shl (i64.mul (get_local $s1) (i64.const 32)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.shl (i64.mul (get_local $s2) (i64.const 4)) (i64.const 40)) - (i64.or) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s2) (i64.const 42)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s2) (i64.const 42)) - (i64.shl (i64.mul (get_local $s3) (i64.const 128)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=0) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s3) (i64.const 1)) - (i64.shl (i64.mul (get_local $s4) (i64.const 16)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.shl (i64.mul (get_local $s5) (i64.const 2)) (i64.const 40)) - (i64.or) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s5) (i64.const 41)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s5) (i64.const 41)) - (i64.shl (i64.mul (get_local $s6) (i64.const 64)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=8) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s6) (i64.const 2)) - (i64.shl (i64.mul (get_local $s7) (i64.const 8)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s7) (i64.const 19)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s7) (i64.const 19)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.shl (i64.mul (get_local $s9) (i64.const 32)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=16) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s9) (i64.const 3)) - (i64.shl (i64.mul (get_local $s10) (i64.const 4)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s10) (i64.const 18)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s10) (i64.const 18)) - (i64.shl (i64.mul (get_local $s11) (i64.const 128)) (i64.const 32)) - (i64.or) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=24)) - - (func $sc25519_reduce (export "sc25519_reduce") (param $s i32) - (local $s0 i64) - (local $s1 i64) - (local $s2 i64) - (local $s3 i64) - (local $s4 i64) - (local $s5 i64) - (local $s6 i64) - (local $s7 i64) - (local $s8 i64) - (local $s9 i64) - (local $s10 i64) - (local $s11 i64) - (local $s12 i64) - (local $s13 i64) - (local $s14 i64) - (local $s15 i64) - (local $s16 i64) - (local $s17 i64) - (local $s18 i64) - (local $s19 i64) - (local $s20 i64) - (local $s21 i64) - (local $s22 i64) - (local $s23 i64) - - (local $carry0 i64) - (local $carry1 i64) - (local $carry2 i64) - (local $carry3 i64) - (local $carry4 i64) - (local $carry5 i64) - (local $carry6 i64) - (local $carry7 i64) - (local $carry8 i64) - (local $carry9 i64) - (local $carry10 i64) - (local $carry11 i64) - (local $carry12 i64) - (local $carry13 i64) - (local $carry14 i64) - (local $carry15 i64) - (local $carry16 i64) - - (set_local $s0 (i64.load32_u offset=0 (get_local $s))) - (set_local $s1 (i64.load32_u offset=4 (get_local $s))) - (set_local $s2 (i64.load32_u offset=8 (get_local $s))) - (set_local $s3 (i64.load32_u offset=12 (get_local $s))) - (set_local $s4 (i64.load32_u offset=16 (get_local $s))) - (set_local $s5 (i64.load32_u offset=20 (get_local $s))) - (set_local $s6 (i64.load32_u offset=24 (get_local $s))) - (set_local $s7 (i64.load32_u offset=28 (get_local $s))) - (set_local $s8 (i64.load32_u offset=32 (get_local $s))) - (set_local $s9 (i64.load32_u offset=36 (get_local $s))) - (set_local $s10 (i64.load32_u offset=40 (get_local $s))) - (set_local $s11 (i64.load32_u offset=44 (get_local $s))) - (set_local $s12 (i64.load32_u offset=48 (get_local $s))) - (set_local $s13 (i64.load32_u offset=52 (get_local $s))) - (set_local $s14 (i64.load32_u offset=56 (get_local $s))) - (set_local $s15 (i64.load32_u offset=60 (get_local $s))) - (set_local $s16 (i64.load32_u offset=64 (get_local $s))) - (set_local $s17 (i64.load32_u offset=68 (get_local $s))) - (set_local $s18 (i64.load32_u offset=72 (get_local $s))) - (set_local $s19 (i64.load32_u offset=76 (get_local $s))) - (set_local $s20 (i64.load32_u offset=80 (get_local $s))) - (set_local $s21 (i64.load32_u offset=84 (get_local $s))) - (set_local $s22 (i64.load32_u offset=88 (get_local $s))) - (set_local $s23 (i64.load32_u offset=92 (get_local $s))) - - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s23) (i64.const 666643)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s23) (i64.const 470296)))) - (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s23) (i64.const 654183)))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s23) (i64.const 997805)))) - (set_local $s15 (i64.add (get_local $s15) (i64.mul (get_local $s23) (i64.const 136657)))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $s23) (i64.const 683901)))) - - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s22) (i64.const 666643)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s22) (i64.const 470296)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s22) (i64.const 654183)))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s22) (i64.const 997805)))) - (set_local $s14 (i64.add (get_local $s14) (i64.mul (get_local $s22) (i64.const 136657)))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $s22) (i64.const 683901)))) - - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s21) (i64.const 666643)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s21) (i64.const 470296)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s21) (i64.const 654183)))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s21) (i64.const 997805)))) - (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s21) (i64.const 136657)))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s21) (i64.const 683901)))) - - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s20) (i64.const 666643)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s20) (i64.const 470296)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s20) (i64.const 654183)))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s20) (i64.const 997805)))) - (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s20) (i64.const 136657)))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s20) (i64.const 683901)))) - - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s19) (i64.const 666643)))) - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s19) (i64.const 470296)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s19) (i64.const 654183)))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s19) (i64.const 997805)))) - (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s19) (i64.const 136657)))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s19) (i64.const 683901)))) - - (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s18) (i64.const 666643)))) - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s18) (i64.const 470296)))) - (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s18) (i64.const 654183)))) - (set_local $s9 (i64.sub (get_local $s9 ) (i64.mul (get_local $s18) (i64.const 997805)))) - (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s18) (i64.const 136657)))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s18) (i64.const 683901)))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) - (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) - (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) - (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) - (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) - (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s5 (i64.add (get_local $s5 ) (i64.mul (get_local $s17) (i64.const 666643)))) - (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s17) (i64.const 470296)))) - (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s17) (i64.const 654183)))) - (set_local $s8 (i64.sub (get_local $s8 ) (i64.mul (get_local $s17) (i64.const 997805)))) - (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s17) (i64.const 136657)))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s17) (i64.const 683901)))) - - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s16) (i64.const 666643)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s16) (i64.const 470296)))) - (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s16) (i64.const 654183)))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s16) (i64.const 997805)))) - (set_local $s8 (i64.add (get_local $s8) (i64.mul (get_local $s16) (i64.const 136657)))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $s16) (i64.const 683901)))) - - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s15) (i64.const 666643)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s15) (i64.const 470296)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s15) (i64.const 654183)))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s15) (i64.const 997805)))) - (set_local $s7 (i64.add (get_local $s7) (i64.mul (get_local $s15) (i64.const 136657)))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $s15) (i64.const 683901)))) - - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s14) (i64.const 666643)))) - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s14) (i64.const 470296)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s14) (i64.const 654183)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s14) (i64.const 997805)))) - (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s14) (i64.const 136657)))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s14) (i64.const 683901)))) - - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s13) (i64.const 666643)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s13) (i64.const 470296)))) - (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s13) (i64.const 654183)))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $s13) (i64.const 997805)))) - (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s13) (i64.const 136657)))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s13) (i64.const 683901)))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - (set_local $s12 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - (set_local $s12 (i64.const 0)) - - (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry11 (i64.shr_s (get_local $s11) (i64.const 21))) - (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) - (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) - (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) - (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) - (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) - - (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) - (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) - (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) - (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) - (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) - (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) - (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) - (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) - (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) - (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) - (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) - (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) - (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) - (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) - (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) - (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) - (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) - (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) - (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) - (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) - (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) - - (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) - (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) - (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) - - (get_local $s) - - (i64.and (get_local $s0) (i64.const 0xff)) - (i64.and (get_local $s0) (i64.const 0xff00)) - (i64.or) - (get_local $s0) - (i64.shl (i64.mul (get_local $s1) (i64.const 32)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s1) (i64.const 21)) - (i64.shl (i64.mul (get_local $s2) (i64.const 4)) (i64.const 40)) - (i64.or) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s2) (i64.const 42)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s2) (i64.const 42)) - (i64.shl (i64.mul (get_local $s3) (i64.const 128)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=0) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s3) (i64.const 1)) - (i64.shl (i64.mul (get_local $s4) (i64.const 16)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s4) (i64.const 20)) - (i64.shl (i64.mul (get_local $s5) (i64.const 2)) (i64.const 40)) - (i64.or) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s5) (i64.const 41)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s5) (i64.const 41)) - (i64.shl (i64.mul (get_local $s6) (i64.const 64)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=8) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s6) (i64.const 2)) - (i64.shl (i64.mul (get_local $s7) (i64.const 8)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s7) (i64.const 19)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s7) (i64.const 19)) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s8) (i64.const 40)) - (i64.shl (i64.mul (get_local $s9) (i64.const 32)) (i64.const 56)) - (i64.or) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=16) - - (get_local $s) - - (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff)) - (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff00)) - (i64.or) - (i64.shr_s (get_local $s9) (i64.const 3)) - (i64.shl (i64.mul (get_local $s10) (i64.const 4)) (i64.const 16)) - (i64.or) - (i64.const 0xff0000) - (i64.and) - (i64.or) - (i64.shl (get_local $s10) (i64.const 18)) - (i64.const 0xff000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s10) (i64.const 18)) - (i64.shl (i64.mul (get_local $s11) (i64.const 128)) (i64.const 32)) - (i64.or) - (i64.const 0xff00000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff0000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff000000000000) - (i64.and) - (i64.or) - (i64.shl (get_local $s11) (i64.const 39)) - (i64.const 0xff00000000000000) - (i64.and) - (i64.or) - - (i64.store offset=24)) - - (func $fe25519_mul (export "fe25519_mul") (param $h i32) (param $f i32) (param $g i32) - (get_local $h) - (call $mul (get_local $f) (get_local $g)) - (call $store_fe)) - - ;; (func $pow22325 (export "pow22325") (param $out i32) (param $z i32) - -) + (i64.store32 offset=36 (get_local $h) (get_local $h9)))) diff --git a/fe25519_25/sc25519_mul.wat b/fe25519_25/sc25519_mul.wat new file mode 100644 index 0000000..7a9f2c7 --- /dev/null +++ b/fe25519_25/sc25519_mul.wat @@ -0,0 +1,277 @@ +(module + (memory $0 1) + (export "memory" (memory $0)) + + (func $sc25519_mul (export "sc25519_mul") (param $s i32) (param $a i32) (param $b i32) + (local $tmp i64) + + (local $a0 i64) + (local $a1 i64) + (local $a2 i64) + (local $a3 i64) + (local $a4 i64) + (local $a5 i64) + (local $a6 i64) + (local $a7 i64) + (local $a8 i64) + (local $a9 i64) + (local $a10 i64) + (local $a11 i64) + + (local $b0 i64) + (local $b1 i64) + (local $b2 i64) + (local $b3 i64) + (local $b4 i64) + (local $b5 i64) + (local $b6 i64) + (local $b7 i64) + (local $b8 i64) + (local $b9 i64) + (local $b10 i64) + (local $b11 i64) + + (local $s0 i64) + (local $s1 i64) + (local $s2 i64) + (local $s3 i64) + (local $s4 i64) + (local $s5 i64) + (local $s6 i64) + (local $s7 i64) + (local $s8 i64) + (local $s9 i64) + (local $s10 i64) + (local $s11 i64) + (local $s12 i64) + (local $s13 i64) + (local $s14 i64) + (local $s15 i64) + (local $s16 i64) + (local $s17 i64) + (local $s18 i64) + (local $s19 i64) + (local $s20 i64) + (local $s21 i64) + (local $s22 i64) + (local $s23 i64) + + (local $carry0 i64) + (local $carry1 i64) + (local $carry2 i64) + (local $carry3 i64) + (local $carry4 i64) + (local $carry5 i64) + (local $carry6 i64) + (local $carry7 i64) + (local $carry8 i64) + (local $carry9 i64) + (local $carry10 i64) + (local $carry11 i64) + (local $carry12 i64) + (local $carry13 i64) + (local $carry14 i64) + (local $carry15 i64) + (local $carry16 i64) + (local $carry17 i64) + (local $carry18 i64) + (local $carry19 i64) + (local $carry20 i64) + (local $carry21 i64) + (local $carry22 i64) + + (set_local $a0 (i64.load32_u offset=0 (get_local $a))) + (set_local $a1 (i64.load32_u offset=4 (get_local $a))) + (set_local $a2 (i64.load32_u offset=8 (get_local $a))) + (set_local $a3 (i64.load32_u offset=12 (get_local $a))) + (set_local $a4 (i64.load32_u offset=16 (get_local $a))) + (set_local $a5 (i64.load32_u offset=20 (get_local $a))) + (set_local $a6 (i64.load32_u offset=24 (get_local $a))) + (set_local $a7 (i64.load32_u offset=28 (get_local $a))) + (set_local $a8 (i64.load32_u offset=32 (get_local $a))) + (set_local $a9 (i64.load32_u offset=36 (get_local $a))) + (set_local $a10 (i64.load32_u offset=40 (get_local $a))) + (set_local $a11 (i64.load32_u offset=44 (get_local $a))) + + (set_local $b0 (i64.load32_u offset=0 (get_local $b))) + (set_local $b1 (i64.load32_u offset=4 (get_local $b))) + (set_local $b2 (i64.load32_u offset=8 (get_local $b))) + (set_local $b3 (i64.load32_u offset=12 (get_local $b))) + (set_local $b4 (i64.load32_u offset=16 (get_local $b))) + (set_local $b5 (i64.load32_u offset=20 (get_local $b))) + (set_local $b6 (i64.load32_u offset=24 (get_local $b))) + (set_local $b7 (i64.load32_u offset=28 (get_local $b))) + (set_local $b8 (i64.load32_u offset=32 (get_local $b))) + (set_local $b9 (i64.load32_u offset=36 (get_local $b))) + (set_local $b10 (i64.load32_u offset=40 (get_local $b))) + (set_local $b11 (i64.load32_u offset=44 (get_local $b))) + + (set_local $a0 (i64.extend_s/i32 (get_local $a0))) + (set_local $a1 (i64.extend_s/i32 (get_local $a1))) + (set_local $a2 (i64.extend_s/i32 (get_local $a2))) + (set_local $a3 (i64.extend_s/i32 (get_local $a3))) + (set_local $a4 (i64.extend_s/i32 (get_local $a4))) + (set_local $a5 (i64.extend_s/i32 (get_local $a5))) + (set_local $a6 (i64.extend_s/i32 (get_local $a6))) + (set_local $a7 (i64.extend_s/i32 (get_local $a7))) + (set_local $a8 (i64.extend_s/i32 (get_local $a8))) + (set_local $a9 (i64.extend_s/i32 (get_local $a9))) + (set_local $a10 (i64.extend_s/i32 (get_local $a10))) + (set_local $a11 (i64.extend_s/i32 (get_local $a11))) + + (set_local $b0 (i64.extend_s/i32 (get_local $b0))) + (set_local $b1 (i64.extend_s/i32 (get_local $b1))) + (set_local $b2 (i64.extend_s/i32 (get_local $b2))) + (set_local $b3 (i64.extend_s/i32 (get_local $b3))) + (set_local $b4 (i64.extend_s/i32 (get_local $b4))) + (set_local $b5 (i64.extend_s/i32 (get_local $b5))) + (set_local $b6 (i64.extend_s/i32 (get_local $b6))) + (set_local $b7 (i64.extend_s/i32 (get_local $b7))) + (set_local $b8 (i64.extend_s/i32 (get_local $b8))) + (set_local $b9 (i64.extend_s/i32 (get_local $b9))) + (set_local $b10 (i64.extend_s/i32 (get_local $b10))) + (set_local $b11 (i64.extend_s/i32 (get_local $b11))) + + (set_local $s0 (i64.mul (get_local $a0) (get_local $b0))) + (set_local $s1 (i64.add (i64.mul (get_local $a0) (get_local $b1 )) (i64.mul (get_local $a1) (get_local $b0)))) + (set_local $s2 (i64.add (i64.mul (get_local $a0) (get_local $b2 )) (i64.add (i64.mul (get_local $a1) (get_local $b1 )) (i64.mul (get_local $a2) (get_local $b0))))) + (set_local $s3 (i64.add (i64.mul (get_local $a0) (get_local $b3 )) (i64.add (i64.mul (get_local $a1) (get_local $b2 )) (i64.add (i64.mul (get_local $a2) (get_local $b1)) (i64.mul (get_local $a3) (get_local $b0)))))) + (set_local $s4 (i64.add (i64.mul (get_local $a0) (get_local $b4 )) (i64.add (i64.mul (get_local $a1) (get_local $b3 )) (i64.add (i64.mul (get_local $a2) (get_local $b2)) (i64.add (i64.mul (get_local $a3) (get_local $b1)) (i64.mul (get_local $a4) (get_local $b0))))))) + (set_local $s5 (i64.add (i64.mul (get_local $a0) (get_local $b5 )) (i64.add (i64.mul (get_local $a1) (get_local $b4 )) (i64.add (i64.mul (get_local $a2) (get_local $b3)) (i64.add (i64.mul (get_local $a3) (get_local $b2)) (i64.add (i64.mul (get_local $a4) (get_local $b1)) (i64.mul (get_local $a5) (get_local $b0)))))))) + (set_local $s6 (i64.add (i64.mul (get_local $a0) (get_local $b6 )) (i64.add (i64.mul (get_local $a1) (get_local $b5 )) (i64.add (i64.mul (get_local $a2) (get_local $b4)) (i64.add (i64.mul (get_local $a3) (get_local $b3)) (i64.add (i64.mul (get_local $a4) (get_local $b2)) (i64.add (i64.mul (get_local $a5) (get_local $b1)) (i64.mul (get_local $a6) (get_local $b0))))))))) + (set_local $s7 (i64.add (i64.mul (get_local $a0) (get_local $b7 )) (i64.add (i64.mul (get_local $a1) (get_local $b6 )) (i64.add (i64.mul (get_local $a2) (get_local $b5)) (i64.add (i64.mul (get_local $a3) (get_local $b4)) (i64.add (i64.mul (get_local $a4) (get_local $b3)) (i64.add (i64.mul (get_local $a5) (get_local $b2)) (i64.add (i64.mul (get_local $a6) (get_local $b1)) (i64.mul (get_local $a7) (get_local $b0)))))))))) + (set_local $s8 (i64.add (i64.mul (get_local $a0) (get_local $b8 )) (i64.add (i64.mul (get_local $a1) (get_local $b7 )) (i64.add (i64.mul (get_local $a2) (get_local $b6)) (i64.add (i64.mul (get_local $a3) (get_local $b5)) (i64.add (i64.mul (get_local $a4) (get_local $b4)) (i64.add (i64.mul (get_local $a5) (get_local $b3)) (i64.add (i64.mul (get_local $a6) (get_local $b2)) (i64.add (i64.mul (get_local $a7) (get_local $b1)) (i64.mul (get_local $a8) (get_local $b0))))))))))) + (set_local $s9 (i64.add (i64.mul (get_local $a0) (get_local $b9 )) (i64.add (i64.mul (get_local $a1) (get_local $b8 )) (i64.add (i64.mul (get_local $a2) (get_local $b7)) (i64.add (i64.mul (get_local $a3) (get_local $b6)) (i64.add (i64.mul (get_local $a4) (get_local $b5)) (i64.add (i64.mul (get_local $a5) (get_local $b4)) (i64.add (i64.mul (get_local $a6) (get_local $b3)) (i64.add (i64.mul (get_local $a7) (get_local $b2)) (i64.add (i64.mul (get_local $a8) (get_local $b1)) (i64.mul (get_local $a9) (get_local $b0)))))))))))) + (set_local $s10 (i64.add (i64.mul (get_local $a0) (get_local $b10)) (i64.add (i64.mul (get_local $a1) (get_local $b9 )) (i64.add (i64.mul (get_local $a2) (get_local $b8)) (i64.add (i64.mul (get_local $a3) (get_local $b7)) (i64.add (i64.mul (get_local $a4) (get_local $b6)) (i64.add (i64.mul (get_local $a5) (get_local $b5)) (i64.add (i64.mul (get_local $a6) (get_local $b4)) (i64.add (i64.mul (get_local $a7) (get_local $b3)) (i64.add (i64.mul (get_local $a8) (get_local $b2)) (i64.add (i64.mul (get_local $a9) (get_local $b1)) (i64.mul (get_local $a10) (get_local $b0))))))))))))) + (set_local $s11 (i64.add (i64.mul (get_local $a0) (get_local $b11)) (i64.add (i64.mul (get_local $a1) (get_local $b10)) (i64.add (i64.mul (get_local $a2) (get_local $b9)) (i64.add (i64.mul (get_local $a3) (get_local $b8)) (i64.add (i64.mul (get_local $a4) (get_local $b7)) (i64.add (i64.mul (get_local $a5) (get_local $b6)) (i64.add (i64.mul (get_local $a6) (get_local $b5)) (i64.add (i64.mul (get_local $a7) (get_local $b4)) (i64.add (i64.mul (get_local $a8) (get_local $b3)) (i64.add (i64.mul (get_local $a9) (get_local $b2)) (i64.add (i64.mul (get_local $a10) (get_local $b1)) (i64.mul (get_local $a11) (get_local $b0)))))))))))))) + (set_local $s12 (i64.add (i64.mul (get_local $a1) (get_local $b11)) (i64.add (i64.mul (get_local $a2) (get_local $b10)) (i64.add (i64.mul (get_local $a3) (get_local $b9)) (i64.add (i64.mul (get_local $a4) (get_local $b8)) (i64.add (i64.mul (get_local $a5) (get_local $b7)) (i64.add (i64.mul (get_local $a6) (get_local $b6)) (i64.add (i64.mul (get_local $a7) (get_local $b5)) (i64.add (i64.mul (get_local $a8) (get_local $b4)) (i64.add (i64.mul (get_local $a9) (get_local $b3)) (i64.add (i64.mul (get_local $a10) (get_local $b2)) (i64.mul (get_local $a11) (get_local $b1))))))))))))) + (set_local $s13 (i64.add (i64.mul (get_local $a2) (get_local $b11)) (i64.add (i64.mul (get_local $a3) (get_local $b10)) (i64.add (i64.mul (get_local $a4) (get_local $b9)) (i64.add (i64.mul (get_local $a5) (get_local $b8)) (i64.add (i64.mul (get_local $a6) (get_local $b7)) (i64.add (i64.mul (get_local $a7) (get_local $b6)) (i64.add (i64.mul (get_local $a8) (get_local $b5)) (i64.add (i64.mul (get_local $a9) (get_local $b4)) (i64.add (i64.mul (get_local $a10) (get_local $b3)) (i64.mul (get_local $a11) (get_local $b2)))))))))))) + (set_local $s14 (i64.add (i64.mul (get_local $a3) (get_local $b11)) (i64.add (i64.mul (get_local $a4) (get_local $b10)) (i64.add (i64.mul (get_local $a5) (get_local $b9)) (i64.add (i64.mul (get_local $a6) (get_local $b8)) (i64.add (i64.mul (get_local $a7) (get_local $b7)) (i64.add (i64.mul (get_local $a8) (get_local $b6)) (i64.add (i64.mul (get_local $a9) (get_local $b5)) (i64.add (i64.mul (get_local $a10) (get_local $b4)) (i64.mul (get_local $a11) (get_local $b3))))))))))) + (set_local $s15 (i64.add (i64.mul (get_local $a4) (get_local $b11)) (i64.add (i64.mul (get_local $a5) (get_local $b10)) (i64.add (i64.mul (get_local $a6) (get_local $b9)) (i64.add (i64.mul (get_local $a7) (get_local $b8)) (i64.add (i64.mul (get_local $a8) (get_local $b7)) (i64.add (i64.mul (get_local $a9) (get_local $b6)) (i64.add (i64.mul (get_local $a10) (get_local $b5)) (i64.mul (get_local $a11) (get_local $b4)))))))))) + (set_local $s16 (i64.add (i64.mul (get_local $a5) (get_local $b11)) (i64.add (i64.mul (get_local $a6) (get_local $b10)) (i64.add (i64.mul (get_local $a7) (get_local $b9)) (i64.add (i64.mul (get_local $a8) (get_local $b8)) (i64.add (i64.mul (get_local $a9) (get_local $b7)) (i64.add (i64.mul (get_local $a10) (get_local $b6)) (i64.mul (get_local $a11) (get_local $b5))))))))) + (set_local $s17 (i64.add (i64.mul (get_local $a6) (get_local $b11)) (i64.add (i64.mul (get_local $a7) (get_local $b10)) (i64.add (i64.mul (get_local $a8) (get_local $b9)) (i64.add (i64.mul (get_local $a9) (get_local $b8)) (i64.add (i64.mul (get_local $a10) (get_local $b7)) (i64.mul (get_local $a11) (get_local $b6)))))))) + (set_local $s18 (i64.add (i64.mul (get_local $a7) (get_local $b11)) (i64.add (i64.mul (get_local $a8) (get_local $b10)) (i64.add (i64.mul (get_local $a9) (get_local $b9)) (i64.add (i64.mul (get_local $a10) (get_local $b8)) (i64.mul (get_local $a11) (get_local $b7))))))) + (set_local $s19 (i64.add (i64.mul (get_local $a8) (get_local $b11)) (i64.add (i64.mul (get_local $a9) (get_local $b10)) (i64.add (i64.mul (get_local $a10) (get_local $b9)) (i64.mul (get_local $a11) (get_local $b8)))))) + (set_local $s20 (i64.add (i64.mul (get_local $a9) (get_local $b11)) (i64.add (i64.mul (get_local $a10) (get_local $b10)) (i64.mul (get_local $a11) (get_local $b9))))) + (set_local $s21 (i64.add (i64.mul (get_local $a10) (get_local $b11)) (i64.mul (get_local $a11) (get_local $b10)))) + (set_local $s22 (i64.mul (get_local $a11) (get_local $b11))) + (set_local $s23 (i64.const 0)) + + (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) + (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) + (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) + (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) + (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) + (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) + (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry18 (i64.shr_s (i64.add (get_local $s18) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s19 (i64.add (get_local $s19) (get_local $carry18))) + (set_local $s18 (i64.sub (get_local $s18) (i64.mul (get_local $carry18) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry20 (i64.shr_s (i64.add (get_local $s20) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s21 (i64.add (get_local $s21) (get_local $carry20))) + (set_local $s20 (i64.sub (get_local $s20) (i64.mul (get_local $carry20) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry22 (i64.shr_s (i64.add (get_local $s22) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s23 (i64.add (get_local $s23) (get_local $carry22))) + (set_local $s22 (i64.sub (get_local $s22) (i64.mul (get_local $carry22) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) + (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) + (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) + (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry17 (i64.shr_s (i64.add (get_local $s17) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s18 (i64.add (get_local $s18) (get_local $carry17))) + (set_local $s17 (i64.sub (get_local $s17) (i64.mul (get_local $carry17) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry19 (i64.shr_s (i64.add (get_local $s19) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s20 (i64.add (get_local $s20) (get_local $carry19))) + (set_local $s19 (i64.sub (get_local $s19) (i64.mul (get_local $carry19) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry21 (i64.shr_s (i64.add (get_local $s21) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s22 (i64.add (get_local $s22) (get_local $carry21))) + (set_local $s21 (i64.sub (get_local $s21) (i64.mul (get_local $carry21) (i64.shl (i64.const 1) (i64.const 21))))) + + (get_local $s) + (get_local $s0) + (get_local $s1) + (get_local $s2) + (get_local $s3) + (get_local $s4) + (get_local $s5) + (get_local $s6) + (get_local $s7) + (get_local $s8) + (get_local $s9) + (get_local $s10) + (get_local $s11) + (get_local $s12) + (get_local $s13) + (get_local $s14) + (get_local $s15) + (get_local $s16) + (get_local $s17) + (get_local $s18) + (get_local $s19) + (get_local $s20) + (get_local $s21) + (get_local $s22) + (get_local $s23) + (call $sc_reduce))) diff --git a/fe25519_25/sc25519_muladd.wat b/fe25519_25/sc25519_muladd.wat new file mode 100644 index 0000000..47e4ece --- /dev/null +++ b/fe25519_25/sc25519_muladd.wat @@ -0,0 +1,316 @@ +(module + (memory $0 1) + (export "memory" (memory $0)) + + (func $sc25519_muladd (export "sc25519_muladd") (param $s i32) (param $a i32) (param $b i32) (param $c i32) + (local $tmp i64) + + (local $a0 i64) + (local $a1 i64) + (local $a2 i64) + (local $a3 i64) + (local $a4 i64) + (local $a5 i64) + (local $a6 i64) + (local $a7 i64) + (local $a8 i64) + (local $a9 i64) + (local $a10 i64) + (local $a11 i64) + + (local $b0 i64) + (local $b1 i64) + (local $b2 i64) + (local $b3 i64) + (local $b4 i64) + (local $b5 i64) + (local $b6 i64) + (local $b7 i64) + (local $b8 i64) + (local $b9 i64) + (local $b10 i64) + (local $b11 i64) + + (local $c0 i64) + (local $c1 i64) + (local $c2 i64) + (local $c3 i64) + (local $c4 i64) + (local $c5 i64) + (local $c6 i64) + (local $c7 i64) + (local $c8 i64) + (local $c9 i64) + (local $c10 i64) + (local $c11 i64) + + (local $s0 i64) + (local $s1 i64) + (local $s2 i64) + (local $s3 i64) + (local $s4 i64) + (local $s5 i64) + (local $s6 i64) + (local $s7 i64) + (local $s8 i64) + (local $s9 i64) + (local $s10 i64) + (local $s11 i64) + (local $s12 i64) + (local $s13 i64) + (local $s14 i64) + (local $s15 i64) + (local $s16 i64) + (local $s17 i64) + (local $s18 i64) + (local $s19 i64) + (local $s20 i64) + (local $s21 i64) + (local $s22 i64) + (local $s23 i64) + + (local $carry0 i64) + (local $carry1 i64) + (local $carry2 i64) + (local $carry3 i64) + (local $carry4 i64) + (local $carry5 i64) + (local $carry6 i64) + (local $carry7 i64) + (local $carry8 i64) + (local $carry9 i64) + (local $carry10 i64) + (local $carry11 i64) + (local $carry12 i64) + (local $carry13 i64) + (local $carry14 i64) + (local $carry15 i64) + (local $carry16 i64) + (local $carry17 i64) + (local $carry18 i64) + (local $carry19 i64) + (local $carry20 i64) + (local $carry21 i64) + (local $carry22 i64) + + (set_local $a0 (i64.load32_u offset=0 (get_local $a))) + (set_local $a1 (i64.load32_u offset=4 (get_local $a))) + (set_local $a2 (i64.load32_u offset=8 (get_local $a))) + (set_local $a3 (i64.load32_u offset=12 (get_local $a))) + (set_local $a4 (i64.load32_u offset=16 (get_local $a))) + (set_local $a5 (i64.load32_u offset=20 (get_local $a))) + (set_local $a6 (i64.load32_u offset=24 (get_local $a))) + (set_local $a7 (i64.load32_u offset=28 (get_local $a))) + (set_local $a8 (i64.load32_u offset=32 (get_local $a))) + (set_local $a9 (i64.load32_u offset=36 (get_local $a))) + (set_local $a10 (i64.load32_u offset=40 (get_local $a))) + (set_local $a11 (i64.load32_u offset=44 (get_local $a))) + + (set_local $b0 (i64.load32_u offset=0 (get_local $b))) + (set_local $b1 (i64.load32_u offset=4 (get_local $b))) + (set_local $b2 (i64.load32_u offset=8 (get_local $b))) + (set_local $b3 (i64.load32_u offset=12 (get_local $b))) + (set_local $b4 (i64.load32_u offset=16 (get_local $b))) + (set_local $b5 (i64.load32_u offset=20 (get_local $b))) + (set_local $b6 (i64.load32_u offset=24 (get_local $b))) + (set_local $b7 (i64.load32_u offset=28 (get_local $b))) + (set_local $b8 (i64.load32_u offset=32 (get_local $b))) + (set_local $b9 (i64.load32_u offset=36 (get_local $b))) + (set_local $b10 (i64.load32_u offset=40 (get_local $b))) + (set_local $b11 (i64.load32_u offset=44 (get_local $b))) + + (set_local $c0 (i64.load32_u offset=0 (get_local $c))) + (set_local $c1 (i64.load32_u offset=4 (get_local $c))) + (set_local $c2 (i64.load32_u offset=8 (get_local $c))) + (set_local $c3 (i64.load32_u offset=12 (get_local $c))) + (set_local $c4 (i64.load32_u offset=16 (get_local $c))) + (set_local $c5 (i64.load32_u offset=20 (get_local $c))) + (set_local $c6 (i64.load32_u offset=24 (get_local $c))) + (set_local $c7 (i64.load32_u offset=28 (get_local $c))) + (set_local $c8 (i64.load32_u offset=32 (get_local $c))) + (set_local $c9 (i64.load32_u offset=36 (get_local $c))) + (set_local $c10 (i64.load32_u offset=40 (get_local $c))) + (set_local $c11 (i64.load32_u offset=44 (get_local $c))) + + (set_local $a0 (i64.extend32_s (get_local $a0))) + (set_local $a1 (i64.extend32_s (get_local $a1))) + (set_local $a2 (i64.extend32_s (get_local $a2))) + (set_local $a3 (i64.extend32_s (get_local $a3))) + (set_local $a4 (i64.extend32_s (get_local $a4))) + (set_local $a5 (i64.extend32_s (get_local $a5))) + (set_local $a6 (i64.extend32_s (get_local $a6))) + (set_local $a7 (i64.extend32_s (get_local $a7))) + (set_local $a8 (i64.extend32_s (get_local $a8))) + (set_local $a9 (i64.extend32_s (get_local $a9))) + (set_local $a10 (i64.extend32_s (get_local $a10))) + (set_local $a11 (i64.extend32_s (get_local $a11))) + + (set_local $b0 (i64.extend32_s (get_local $b0))) + (set_local $b1 (i64.extend32_s (get_local $b1))) + (set_local $b2 (i64.extend32_s (get_local $b2))) + (set_local $b3 (i64.extend32_s (get_local $b3))) + (set_local $b4 (i64.extend32_s (get_local $b4))) + (set_local $b5 (i64.extend32_s (get_local $b5))) + (set_local $b6 (i64.extend32_s (get_local $b6))) + (set_local $b7 (i64.extend32_s (get_local $b7))) + (set_local $b8 (i64.extend32_s (get_local $b8))) + (set_local $b9 (i64.extend32_s (get_local $b9))) + (set_local $b10 (i64.extend32_s (get_local $b10))) + (set_local $b11 (i64.extend32_s (get_local $b11))) + + (set_local $c0 (i64.extend32_s (get_local $c0))) + (set_local $c1 (i64.extend32_s (get_local $c1))) + (set_local $c2 (i64.extend32_s (get_local $c2))) + (set_local $c3 (i64.extend32_s (get_local $c3))) + (set_local $c4 (i64.extend32_s (get_local $c4))) + (set_local $c5 (i64.extend32_s (get_local $c5))) + (set_local $c6 (i64.extend32_s (get_local $c6))) + (set_local $c7 (i64.extend32_s (get_local $c7))) + (set_local $c8 (i64.extend32_s (get_local $c8))) + (set_local $c9 (i64.extend32_s (get_local $c9))) + (set_local $c10 (i64.extend32_s (get_local $c10))) + (set_local $c11 (i64.extend32_s (get_local $c11))) + + (set_local $s0 (i64.add (get_local $c0 ) (i64.mul (get_local $a0) (get_local $b0)))) + (set_local $s1 (i64.add (get_local $c1 ) (i64.add (i64.mul (get_local $a0) (get_local $b1 )) (i64.mul (get_local $a1) (get_local $b0))))) + (set_local $s2 (i64.add (get_local $c2 ) (i64.add (i64.mul (get_local $a0) (get_local $b2 )) (i64.add (i64.mul (get_local $a1) (get_local $b1 )) (i64.mul (get_local $a2) (get_local $b0)))))) + (set_local $s3 (i64.add (get_local $c3 ) (i64.add (i64.mul (get_local $a0) (get_local $b3 )) (i64.add (i64.mul (get_local $a1) (get_local $b2 )) (i64.add (i64.mul (get_local $a2) (get_local $b1)) (i64.mul (get_local $a3) (get_local $b0))))))) + (set_local $s4 (i64.add (get_local $c4 ) (i64.add (i64.mul (get_local $a0) (get_local $b4 )) (i64.add (i64.mul (get_local $a1) (get_local $b3 )) (i64.add (i64.mul (get_local $a2) (get_local $b2)) (i64.add (i64.mul (get_local $a3) (get_local $b1)) (i64.mul (get_local $a4) (get_local $b0)))))))) + (set_local $s5 (i64.add (get_local $c5 ) (i64.add (i64.mul (get_local $a0) (get_local $b5 )) (i64.add (i64.mul (get_local $a1) (get_local $b4 )) (i64.add (i64.mul (get_local $a2) (get_local $b3)) (i64.add (i64.mul (get_local $a3) (get_local $b2)) (i64.add (i64.mul (get_local $a4) (get_local $b1)) (i64.mul (get_local $a5) (get_local $b0))))))))) + (set_local $s6 (i64.add (get_local $c6 ) (i64.add (i64.mul (get_local $a0) (get_local $b6 )) (i64.add (i64.mul (get_local $a1) (get_local $b5 )) (i64.add (i64.mul (get_local $a2) (get_local $b4)) (i64.add (i64.mul (get_local $a3) (get_local $b3)) (i64.add (i64.mul (get_local $a4) (get_local $b2)) (i64.add (i64.mul (get_local $a5) (get_local $b1)) (i64.mul (get_local $a6) (get_local $b0)))))))))) + (set_local $s7 (i64.add (get_local $c7 ) (i64.add (i64.mul (get_local $a0) (get_local $b7 )) (i64.add (i64.mul (get_local $a1) (get_local $b6 )) (i64.add (i64.mul (get_local $a2) (get_local $b5)) (i64.add (i64.mul (get_local $a3) (get_local $b4)) (i64.add (i64.mul (get_local $a4) (get_local $b3)) (i64.add (i64.mul (get_local $a5) (get_local $b2)) (i64.add (i64.mul (get_local $a6) (get_local $b1)) (i64.mul (get_local $a7) (get_local $b0))))))))))) + (set_local $s8 (i64.add (get_local $c8 ) (i64.add (i64.mul (get_local $a0) (get_local $b8 )) (i64.add (i64.mul (get_local $a1) (get_local $b7 )) (i64.add (i64.mul (get_local $a2) (get_local $b6)) (i64.add (i64.mul (get_local $a3) (get_local $b5)) (i64.add (i64.mul (get_local $a4) (get_local $b4)) (i64.add (i64.mul (get_local $a5) (get_local $b3)) (i64.add (i64.mul (get_local $a6) (get_local $b2)) (i64.add (i64.mul (get_local $a7) (get_local $b1)) (i64.mul (get_local $a8) (get_local $b0)))))))))))) + (set_local $s9 (i64.add (get_local $c9 ) (i64.add (i64.mul (get_local $a0) (get_local $b9 )) (i64.add (i64.mul (get_local $a1) (get_local $b8 )) (i64.add (i64.mul (get_local $a2) (get_local $b7)) (i64.add (i64.mul (get_local $a3) (get_local $b6)) (i64.add (i64.mul (get_local $a4) (get_local $b5)) (i64.add (i64.mul (get_local $a5) (get_local $b4)) (i64.add (i64.mul (get_local $a6) (get_local $b3)) (i64.add (i64.mul (get_local $a7) (get_local $b2)) (i64.add (i64.mul (get_local $a8) (get_local $b1)) (i64.mul (get_local $a9) (get_local $b0))))))))))))) + (set_local $s10 (i64.add (get_local $c10) (i64.add (i64.mul (get_local $a0) (get_local $b10)) (i64.add (i64.mul (get_local $a1) (get_local $b9 )) (i64.add (i64.mul (get_local $a2) (get_local $b8)) (i64.add (i64.mul (get_local $a3) (get_local $b7)) (i64.add (i64.mul (get_local $a4) (get_local $b6)) (i64.add (i64.mul (get_local $a5) (get_local $b5)) (i64.add (i64.mul (get_local $a6) (get_local $b4)) (i64.add (i64.mul (get_local $a7) (get_local $b3)) (i64.add (i64.mul (get_local $a8) (get_local $b2)) (i64.add (i64.mul (get_local $a9) (get_local $b1)) (i64.mul (get_local $a10) (get_local $b0)))))))))))))) + (set_local $s11 (i64.add (get_local $c11) (i64.add (i64.mul (get_local $a0) (get_local $b11)) (i64.add (i64.mul (get_local $a1) (get_local $b10)) (i64.add (i64.mul (get_local $a2) (get_local $b9)) (i64.add (i64.mul (get_local $a3) (get_local $b8)) (i64.add (i64.mul (get_local $a4) (get_local $b7)) (i64.add (i64.mul (get_local $a5) (get_local $b6)) (i64.add (i64.mul (get_local $a6) (get_local $b5)) (i64.add (i64.mul (get_local $a7) (get_local $b4)) (i64.add (i64.mul (get_local $a8) (get_local $b3)) (i64.add (i64.mul (get_local $a9) (get_local $b2)) (i64.add (i64.mul (get_local $a10) (get_local $b1)) (i64.mul (get_local $a11) (get_local $b0))))))))))))))) + (set_local $s12 (i64.add (i64.mul (get_local $a1) (get_local $b11)) (i64.add (i64.mul (get_local $a2) (get_local $b10)) (i64.add (i64.mul (get_local $a3) (get_local $b9)) (i64.add (i64.mul (get_local $a4) (get_local $b8)) (i64.add (i64.mul (get_local $a5) (get_local $b7)) (i64.add (i64.mul (get_local $a6) (get_local $b6)) (i64.add (i64.mul (get_local $a7) (get_local $b5)) (i64.add (i64.mul (get_local $a8) (get_local $b4)) (i64.add (i64.mul (get_local $a9) (get_local $b3)) (i64.add (i64.mul (get_local $a10) (get_local $b2)) (i64.mul (get_local $a11) (get_local $b1))))))))))))) + (set_local $s13 (i64.add (i64.mul (get_local $a2) (get_local $b11)) (i64.add (i64.mul (get_local $a3) (get_local $b10)) (i64.add (i64.mul (get_local $a4) (get_local $b9)) (i64.add (i64.mul (get_local $a5) (get_local $b8)) (i64.add (i64.mul (get_local $a6) (get_local $b7)) (i64.add (i64.mul (get_local $a7) (get_local $b6)) (i64.add (i64.mul (get_local $a8) (get_local $b5)) (i64.add (i64.mul (get_local $a9) (get_local $b4)) (i64.add (i64.mul (get_local $a10) (get_local $b3)) (i64.mul (get_local $a11) (get_local $b2)))))))))))) + (set_local $s14 (i64.add (i64.mul (get_local $a3) (get_local $b11)) (i64.add (i64.mul (get_local $a4) (get_local $b10)) (i64.add (i64.mul (get_local $a5) (get_local $b9)) (i64.add (i64.mul (get_local $a6) (get_local $b8)) (i64.add (i64.mul (get_local $a7) (get_local $b7)) (i64.add (i64.mul (get_local $a8) (get_local $b6)) (i64.add (i64.mul (get_local $a9) (get_local $b5)) (i64.add (i64.mul (get_local $a10) (get_local $b4)) (i64.mul (get_local $a11) (get_local $b3))))))))))) + (set_local $s15 (i64.add (i64.mul (get_local $a4) (get_local $b11)) (i64.add (i64.mul (get_local $a5) (get_local $b10)) (i64.add (i64.mul (get_local $a6) (get_local $b9)) (i64.add (i64.mul (get_local $a7) (get_local $b8)) (i64.add (i64.mul (get_local $a8) (get_local $b7)) (i64.add (i64.mul (get_local $a9) (get_local $b6)) (i64.add (i64.mul (get_local $a10) (get_local $b5)) (i64.mul (get_local $a11) (get_local $b4)))))))))) + (set_local $s16 (i64.add (i64.mul (get_local $a5) (get_local $b11)) (i64.add (i64.mul (get_local $a6) (get_local $b10)) (i64.add (i64.mul (get_local $a7) (get_local $b9)) (i64.add (i64.mul (get_local $a8) (get_local $b8)) (i64.add (i64.mul (get_local $a9) (get_local $b7)) (i64.add (i64.mul (get_local $a10) (get_local $b6)) (i64.mul (get_local $a11) (get_local $b5))))))))) + (set_local $s17 (i64.add (i64.mul (get_local $a6) (get_local $b11)) (i64.add (i64.mul (get_local $a7) (get_local $b10)) (i64.add (i64.mul (get_local $a8) (get_local $b9)) (i64.add (i64.mul (get_local $a9) (get_local $b8)) (i64.add (i64.mul (get_local $a10) (get_local $b7)) (i64.mul (get_local $a11) (get_local $b6)))))))) + (set_local $s18 (i64.add (i64.mul (get_local $a7) (get_local $b11)) (i64.add (i64.mul (get_local $a8) (get_local $b10)) (i64.add (i64.mul (get_local $a9) (get_local $b9)) (i64.add (i64.mul (get_local $a10) (get_local $b8)) (i64.mul (get_local $a11) (get_local $b7))))))) + (set_local $s19 (i64.add (i64.mul (get_local $a8) (get_local $b11)) (i64.add (i64.mul (get_local $a9) (get_local $b10)) (i64.add (i64.mul (get_local $a10) (get_local $b9)) (i64.mul (get_local $a11) (get_local $b8)))))) + (set_local $s20 (i64.add (i64.mul (get_local $a9) (get_local $b11)) (i64.add (i64.mul (get_local $a10) (get_local $b10)) (i64.mul (get_local $a11) (get_local $b9))))) + (set_local $s21 (i64.add (i64.mul (get_local $a10) (get_local $b11)) (i64.mul (get_local $a11) (get_local $b10)))) + (set_local $s22 (i64.mul (get_local $a11) (get_local $b11))) + (set_local $s23 (i64.const 0)) + + (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) + (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) + (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) + (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) + (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) + (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) + (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry18 (i64.shr_s (i64.add (get_local $s18) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s19 (i64.add (get_local $s19) (get_local $carry18))) + (set_local $s18 (i64.sub (get_local $s18) (i64.mul (get_local $carry18) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry20 (i64.shr_s (i64.add (get_local $s20) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s21 (i64.add (get_local $s21) (get_local $carry20))) + (set_local $s20 (i64.sub (get_local $s20) (i64.mul (get_local $carry20) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry22 (i64.shr_s (i64.add (get_local $s22) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s23 (i64.add (get_local $s23) (get_local $carry22))) + (set_local $s22 (i64.sub (get_local $s22) (i64.mul (get_local $carry22) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) + (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) + (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) + (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry17 (i64.shr_s (i64.add (get_local $s17) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s18 (i64.add (get_local $s18) (get_local $carry17))) + (set_local $s17 (i64.sub (get_local $s17) (i64.mul (get_local $carry17) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry19 (i64.shr_s (i64.add (get_local $s19) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s20 (i64.add (get_local $s20) (get_local $carry19))) + (set_local $s19 (i64.sub (get_local $s19) (i64.mul (get_local $carry19) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry21 (i64.shr_s (i64.add (get_local $s21) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s22 (i64.add (get_local $s22) (get_local $carry21))) + (set_local $s21 (i64.sub (get_local $s21) (i64.mul (get_local $carry21) (i64.shl (i64.const 1) (i64.const 21))))) + + (get_local $s) + (get_local $s0) + (get_local $s1) + (get_local $s2) + (get_local $s3) + (get_local $s4) + (get_local $s5) + (get_local $s6) + (get_local $s7) + (get_local $s8) + (get_local $s9) + (get_local $s10) + (get_local $s11) + (get_local $s12) + (get_local $s13) + (get_local $s14) + (get_local $s15) + (get_local $s16) + (get_local $s17) + (get_local $s18) + (get_local $s19) + (get_local $s20) + (get_local $s21) + (get_local $s22) + (get_local $s23) + (call $sc_reduce))) diff --git a/fe25519_25/sc_reduce.wat b/fe25519_25/sc_reduce.wat new file mode 100644 index 0000000..188e8fc --- /dev/null +++ b/fe25519_25/sc_reduce.wat @@ -0,0 +1,493 @@ +(module + (memory $0 1) + (export "memory" (memory $0)) + + (func $sc_reduce (export "sc_reduce") + (param $ptr i32) + + (param $s0 i64) + (param $s1 i64) + (param $s2 i64) + (param $s3 i64) + (param $s4 i64) + (param $s5 i64) + (param $s6 i64) + (param $s7 i64) + (param $s8 i64) + (param $s9 i64) + (param $s10 i64) + (param $s11 i64) + (param $s12 i64) + (param $s13 i64) + (param $s14 i64) + (param $s15 i64) + (param $s16 i64) + (param $s17 i64) + (param $s18 i64) + (param $s19 i64) + (param $s20 i64) + (param $s21 i64) + (param $s22 i64) + (param $s23 i64) + + (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s23) (i64.const 666643)))) + (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s23) (i64.const 470296)))) + (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s23) (i64.const 654183)))) + (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s23) (i64.const 997805)))) + (set_local $s15 (i64.add (get_local $s15) (i64.mul (get_local $s23) (i64.const 136657)))) + (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $s23) (i64.const 683901)))) + + (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s22) (i64.const 666643)))) + (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s22) (i64.const 470296)))) + (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s22) (i64.const 654183)))) + (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s22) (i64.const 997805)))) + (set_local $s14 (i64.add (get_local $s14) (i64.mul (get_local $s22) (i64.const 136657)))) + (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $s22) (i64.const 683901)))) + + (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s21) (i64.const 666643)))) + (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s21) (i64.const 470296)))) + (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s21) (i64.const 654183)))) + (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s21) (i64.const 997805)))) + (set_local $s13 (i64.add (get_local $s13) (i64.mul (get_local $s21) (i64.const 136657)))) + (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $s21) (i64.const 683901)))) + + (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s20) (i64.const 666643)))) + (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s20) (i64.const 470296)))) + (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s20) (i64.const 654183)))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s20) (i64.const 997805)))) + (set_local $s12 (i64.add (get_local $s12) (i64.mul (get_local $s20) (i64.const 136657)))) + (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $s20) (i64.const 683901)))) + + (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s19) (i64.const 666643)))) + (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s19) (i64.const 470296)))) + (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s19) (i64.const 654183)))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s19) (i64.const 997805)))) + (set_local $s11 (i64.add (get_local $s11) (i64.mul (get_local $s19) (i64.const 136657)))) + (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $s19) (i64.const 683901)))) + + (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s18) (i64.const 666643)))) + (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s18) (i64.const 470296)))) + (set_local $s8 (i64.add (get_local $s8 ) (i64.mul (get_local $s18) (i64.const 654183)))) + (set_local $s9 (i64.sub (get_local $s9 ) (i64.mul (get_local $s18) (i64.const 997805)))) + (set_local $s10 (i64.add (get_local $s10) (i64.mul (get_local $s18) (i64.const 136657)))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $s18) (i64.const 683901)))) + + (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry12 (i64.shr_s (i64.add (get_local $s12) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s13 (i64.add (get_local $s13) (get_local $carry12))) + (set_local $s12 (i64.sub (get_local $s12) (i64.mul (get_local $carry12) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry14 (i64.shr_s (i64.add (get_local $s14) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s15 (i64.add (get_local $s15) (get_local $carry14))) + (set_local $s14 (i64.sub (get_local $s14) (i64.mul (get_local $carry14) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry16 (i64.shr_s (i64.add (get_local $s16) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s17 (i64.add (get_local $s17) (get_local $carry16))) + (set_local $s16 (i64.sub (get_local $s16) (i64.mul (get_local $carry16) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry13 (i64.shr_s (i64.add (get_local $s13) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s14 (i64.add (get_local $s14) (get_local $carry13))) + (set_local $s13 (i64.sub (get_local $s13) (i64.mul (get_local $carry13) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry15 (i64.shr_s (i64.add (get_local $s15) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s16 (i64.add (get_local $s16) (get_local $carry15))) + (set_local $s15 (i64.sub (get_local $s15) (i64.mul (get_local $carry15) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $s5 (i64.add (get_local $s5 ) (i64.mul (get_local $s17) (i64.const 666643)))) + (set_local $s6 (i64.add (get_local $s6 ) (i64.mul (get_local $s17) (i64.const 470296)))) + (set_local $s7 (i64.add (get_local $s7 ) (i64.mul (get_local $s17) (i64.const 654183)))) + (set_local $s8 (i64.sub (get_local $s8 ) (i64.mul (get_local $s17) (i64.const 997805)))) + (set_local $s9 (i64.add (get_local $s9 ) (i64.mul (get_local $s17) (i64.const 136657)))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $s17) (i64.const 683901)))) + + (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s16) (i64.const 666643)))) + (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s16) (i64.const 470296)))) + (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s16) (i64.const 654183)))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s16) (i64.const 997805)))) + (set_local $s8 (i64.add (get_local $s8) (i64.mul (get_local $s16) (i64.const 136657)))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $s16) (i64.const 683901)))) + + (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s15) (i64.const 666643)))) + (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s15) (i64.const 470296)))) + (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s15) (i64.const 654183)))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s15) (i64.const 997805)))) + (set_local $s7 (i64.add (get_local $s7) (i64.mul (get_local $s15) (i64.const 136657)))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $s15) (i64.const 683901)))) + + (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s14) (i64.const 666643)))) + (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s14) (i64.const 470296)))) + (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s14) (i64.const 654183)))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s14) (i64.const 997805)))) + (set_local $s6 (i64.add (get_local $s6) (i64.mul (get_local $s14) (i64.const 136657)))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $s14) (i64.const 683901)))) + + (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s13) (i64.const 666643)))) + (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s13) (i64.const 470296)))) + (set_local $s3 (i64.add (get_local $s3) (i64.mul (get_local $s13) (i64.const 654183)))) + (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $s13) (i64.const 997805)))) + (set_local $s5 (i64.add (get_local $s5) (i64.mul (get_local $s13) (i64.const 136657)))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $s13) (i64.const 683901)))) + + (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) + (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) + (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) + (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) + (set_local $s12 (i64.const 0)) + + (set_local $carry0 (i64.shr_s (i64.add (get_local $s0) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) + (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry2 (i64.shr_s (i64.add (get_local $s2) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) + (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry4 (i64.shr_s (i64.add (get_local $s4) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) + (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry6 (i64.shr_s (i64.add (get_local $s6) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry8 (i64.shr_s (i64.add (get_local $s8) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry10 (i64.shr_s (i64.add (get_local $s10) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry1 (i64.shr_s (i64.add (get_local $s1) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) + (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry3 (i64.shr_s (i64.add (get_local $s3) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry5 (i64.shr_s (i64.add (get_local $s5) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry7 (i64.shr_s (i64.add (get_local $s7) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry9 (i64.shr_s (i64.add (get_local $s9) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry11 (i64.shr_s (i64.add (get_local $s11) (i64.shl (i64.const 1) (i64.const 20))) (i64.const 21))) + (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) + (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) + (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) + (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) + (set_local $s12 (i64.const 0)) + + (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) + (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) + (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) + (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) + (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) + (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) + (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) + (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) + (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) + (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) + (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) + (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) + (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) + (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) + (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) + (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry11 (i64.shr_s (get_local $s11) (i64.const 21))) + (set_local $s12 (i64.add (get_local $s12) (get_local $carry11))) + (set_local $s11 (i64.sub (get_local $s11) (i64.mul (get_local $carry11) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $s0 (i64.add (get_local $s0) (i64.mul (get_local $s12) (i64.const 666643)))) + (set_local $s1 (i64.add (get_local $s1) (i64.mul (get_local $s12) (i64.const 470296)))) + (set_local $s2 (i64.add (get_local $s2) (i64.mul (get_local $s12) (i64.const 654183)))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $s12) (i64.const 997805)))) + (set_local $s4 (i64.add (get_local $s4) (i64.mul (get_local $s12) (i64.const 136657)))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $s12) (i64.const 683901)))) + + (set_local $carry0 (i64.shr_s (get_local $s0) (i64.const 21))) + (set_local $s1 (i64.add (get_local $s1) (get_local $carry0))) + (set_local $s0 (i64.sub (get_local $s0) (i64.mul (get_local $carry0) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry1 (i64.shr_s (get_local $s1) (i64.const 21))) + (set_local $s2 (i64.add (get_local $s2) (get_local $carry1))) + (set_local $s1 (i64.sub (get_local $s1) (i64.mul (get_local $carry1) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry2 (i64.shr_s (get_local $s2) (i64.const 21))) + (set_local $s3 (i64.add (get_local $s3) (get_local $carry2))) + (set_local $s2 (i64.sub (get_local $s2) (i64.mul (get_local $carry2) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry3 (i64.shr_s (get_local $s3) (i64.const 21))) + (set_local $s4 (i64.add (get_local $s4) (get_local $carry3))) + (set_local $s3 (i64.sub (get_local $s3) (i64.mul (get_local $carry3) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry4 (i64.shr_s (get_local $s4) (i64.const 21))) + (set_local $s5 (i64.add (get_local $s5) (get_local $carry4))) + (set_local $s4 (i64.sub (get_local $s4) (i64.mul (get_local $carry4) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry5 (i64.shr_s (get_local $s5) (i64.const 21))) + (set_local $s6 (i64.add (get_local $s6) (get_local $carry5))) + (set_local $s5 (i64.sub (get_local $s5) (i64.mul (get_local $carry5) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry6 (i64.shr_s (get_local $s6) (i64.const 21))) + (set_local $s7 (i64.add (get_local $s7) (get_local $carry6))) + (set_local $s6 (i64.sub (get_local $s6) (i64.mul (get_local $carry6) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry7 (i64.shr_s (get_local $s7) (i64.const 21))) + (set_local $s8 (i64.add (get_local $s8) (get_local $carry7))) + (set_local $s7 (i64.sub (get_local $s7) (i64.mul (get_local $carry7) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry8 (i64.shr_s (get_local $s8) (i64.const 21))) + (set_local $s9 (i64.add (get_local $s9) (get_local $carry8))) + (set_local $s8 (i64.sub (get_local $s8) (i64.mul (get_local $carry8) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry9 (i64.shr_s (get_local $s9) (i64.const 21))) + (set_local $s10 (i64.add (get_local $s10) (get_local $carry9))) + (set_local $s9 (i64.sub (get_local $s9) (i64.mul (get_local $carry9) (i64.shl (i64.const 1) (i64.const 21))))) + + (set_local $carry10 (i64.shr_s (get_local $s10) (i64.const 21))) + (set_local $s11 (i64.add (get_local $s11) (get_local $carry10))) + (set_local $s10 (i64.sub (get_local $s10) (i64.mul (get_local $carry10) (i64.shl (i64.const 1) (i64.const 21))))) + + (get_local $s) + + (i64.and (get_local $s0) (i64.const 0xff)) + (i64.and (get_local $s0) (i64.const 0xff00)) + (i64.or) + (get_local $s0) + (i64.shl (i64.mul (get_local $s1) (i64.const 32)) (i64.const 16)) + (i64.or) + (i64.const 0xff0000) + (i64.and) + (i64.or) + (i64.shl (get_local $s1) (i64.const 21)) + (i64.const 0xff000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s1) (i64.const 21)) + (i64.const 0xff00000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s1) (i64.const 21)) + (i64.shl (i64.mul (get_local $s2) (i64.const 4)) (i64.const 40)) + (i64.or) + (i64.const 0xff0000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s2) (i64.const 42)) + (i64.const 0xff000000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s2) (i64.const 42)) + (i64.shl (i64.mul (get_local $s3) (i64.const 128)) (i64.const 56)) + (i64.or) + (i64.const 0xff00000000000000) + (i64.and) + (i64.or) + + (i64.store offset=0) + + (get_local $s) + + (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff)) + (i64.and (i64.shr_s (get_local $s3) (i64.const 1)) (i64.const 0xff00)) + (i64.or) + (i64.shr_s (get_local $s3) (i64.const 1)) + (i64.shl (i64.mul (get_local $s4) (i64.const 16)) (i64.const 16)) + (i64.or) + (i64.const 0xff0000) + (i64.and) + (i64.or) + (i64.shl (get_local $s4) (i64.const 20)) + (i64.const 0xff000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s4) (i64.const 20)) + (i64.const 0xff00000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s4) (i64.const 20)) + (i64.shl (i64.mul (get_local $s5) (i64.const 2)) (i64.const 40)) + (i64.or) + (i64.const 0xff0000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s5) (i64.const 41)) + (i64.const 0xff000000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s5) (i64.const 41)) + (i64.shl (i64.mul (get_local $s6) (i64.const 64)) (i64.const 56)) + (i64.or) + (i64.const 0xff00000000000000) + (i64.and) + (i64.or) + + (i64.store offset=8) + + (get_local $s) + + (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff)) + (i64.and (i64.shr_s (get_local $s6) (i64.const 2)) (i64.const 0xff00)) + (i64.or) + (i64.shr_s (get_local $s6) (i64.const 2)) + (i64.shl (i64.mul (get_local $s7) (i64.const 8)) (i64.const 16)) + (i64.or) + (i64.const 0xff0000) + (i64.and) + (i64.or) + (i64.shl (get_local $s7) (i64.const 19)) + (i64.const 0xff000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s7) (i64.const 19)) + (i64.const 0xff00000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s8) (i64.const 40)) + (i64.const 0xff0000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s8) (i64.const 40)) + (i64.const 0xff000000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s8) (i64.const 40)) + (i64.shl (i64.mul (get_local $s9) (i64.const 32)) (i64.const 56)) + (i64.or) + (i64.const 0xff00000000000000) + (i64.and) + (i64.or) + + (i64.store offset=16) + + (get_local $s) + + (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff)) + (i64.and (i64.shr_s (get_local $s9) (i64.const 3)) (i64.const 0xff00)) + (i64.or) + (i64.shr_s (get_local $s9) (i64.const 3)) + (i64.shl (i64.mul (get_local $s10) (i64.const 4)) (i64.const 16)) + (i64.or) + (i64.const 0xff0000) + (i64.and) + (i64.or) + (i64.shl (get_local $s10) (i64.const 18)) + (i64.const 0xff000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s10) (i64.const 18)) + (i64.shl (i64.mul (get_local $s11) (i64.const 128)) (i64.const 32)) + (i64.or) + (i64.const 0xff00000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s11) (i64.const 39)) + (i64.const 0xff0000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s11) (i64.const 39)) + (i64.const 0xff000000000000) + (i64.and) + (i64.or) + (i64.shl (get_local $s11) (i64.const 39)) + (i64.const 0xff00000000000000) + (i64.and) + (i64.or) + + (i64.store offset=24)) + + (func $sc25519_reduce (export "sc25519_reduce") (param $s i32) + (get_local $s) + (i64.load32_u offset=0 (get_local $s)) + (i64.load32_u offset=4 (get_local $s)) + (i64.load32_u offset=8 (get_local $s)) + (i64.load32_u offset=12 (get_local $s)) + (i64.load32_u offset=16 (get_local $s)) + (i64.load32_u offset=20 (get_local $s)) + (i64.load32_u offset=24 (get_local $s)) + (i64.load32_u offset=28 (get_local $s)) + (i64.load32_u offset=32 (get_local $s)) + (i64.load32_u offset=36 (get_local $s)) + (i64.load32_u offset=40 (get_local $s)) + (i64.load32_u offset=44 (get_local $s)) + (i64.load32_u offset=48 (get_local $s)) + (i64.load32_u offset=52 (get_local $s)) + (i64.load32_u offset=56 (get_local $s)) + (i64.load32_u offset=60 (get_local $s)) + (i64.load32_u offset=64 (get_local $s)) + (i64.load32_u offset=68 (get_local $s)) + (i64.load32_u offset=72 (get_local $s)) + (i64.load32_u offset=76 (get_local $s)) + (i64.load32_u offset=80 (get_local $s)) + (i64.load32_u offset=84 (get_local $s)) + (i64.load32_u offset=88 (get_local $s)) + (i64.load32_u offset=92 (get_local $s)) + (call $sc_reduce))) + +