Created
October 20, 2017 22:13
-
-
Save wanderer/1ba0bb71d9cf76b1c23d058819f099a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(global $cb_dest (mut i32) (i32.const 0)) | |
(global $sp (mut i32) (i32.const -32)) | |
(global $init (mut i32) (i32.const 0)) | |
(global $gasUsed (mut i64) (i64.const 0)) | |
(func $useGas (param $gas i64) | |
get_global $gasUsed | |
get_local $gas | |
i64.add | |
set_global $gasUsed | |
) | |
;; memory related global | |
(global $memstart i32 (i32.const 33832)) | |
;; the number of 256 words stored in memory | |
(global $wordCount (mut i64) (i64.const 0)) | |
;; what was charged for the last memory allocation | |
(global $prevMemCost (mut i64) (i64.const 0)) | |
;; TODO: memory should only be 1, but can't resize right now | |
(memory 500) | |
(export "memory" (memory 0)) | |
(table | |
(export "callback") | |
anyfunc | |
(elem $callback) | |
) | |
(func $PUSH | |
(param $a0 i64) | |
(param $a1 i64) | |
(param $a2 i64) | |
(param $a3 i64) | |
(local $sp i32) | |
;; increament stack pointer | |
(set_local $sp (i32.add (get_global $sp) (i32.const 32))) | |
(i64.store (get_local $sp) (get_local $a3)) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (get_local $a2)) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (get_local $a1)) | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (get_local $a0)) | |
) | |
;; stack: | |
;; 0: word | |
;; -1: offset | |
(func $MSTORE | |
(local $sp i32) | |
(local $offset i32) | |
(local $offset0 i64) | |
(local $offset1 i64) | |
(local $offset2 i64) | |
(local $offset3 i64) | |
;; load args from the stack | |
(set_local $offset0 (i64.load (get_global $sp))) | |
(set_local $offset1 (i64.load (i32.add (get_global $sp) (i32.const 8)))) | |
(set_local $offset2 (i64.load (i32.add (get_global $sp) (i32.const 16)))) | |
(set_local $offset3 (i64.load (i32.add (get_global $sp) (i32.const 24)))) | |
(set_local $offset | |
(call $check_overflow (get_local $offset0) | |
(get_local $offset1) | |
(get_local $offset2) | |
(get_local $offset3))) | |
;; subtrace gas useage | |
(call $memusegas (get_local $offset) (i32.const 32)) | |
;; pop itme from the stack | |
(set_local $sp (i32.sub (get_global $sp) (i32.const 32))) | |
;; swap top stack item | |
(call $bswap_m256 (get_local $sp)) | |
drop | |
(set_local $offset (i32.add (get_local $offset) (get_global $memstart))) | |
;; store word to memory | |
(i64.store (get_local $offset) (i64.load (get_local $sp))) | |
(i64.store (i32.add (get_local $offset) (i32.const 8)) (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(i64.store (i32.add (get_local $offset) (i32.const 16)) (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(i64.store (i32.add (get_local $offset) (i32.const 24)) (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
) | |
;; generated by ./wasm/generateInterface.js | |
(func $CALLVALUE | |
;; zero out mem | |
(i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0)) | |
(i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))(call $bswap_m128 (i32.add (i32.const 32)(get_global $sp))) drop)(func $ISZERO | |
(local $a0 i64) | |
(local $a1 i64) | |
(local $a2 i64) | |
(local $a3 i64) | |
;; load args from the stack | |
(set_local $a0 (i64.load (i32.add (get_global $sp) (i32.const 24)))) | |
(set_local $a1 (i64.load (i32.add (get_global $sp) (i32.const 16)))) | |
(set_local $a2 (i64.load (i32.add (get_global $sp) (i32.const 8)))) | |
(set_local $a3 (i64.load (get_global $sp))) | |
(i64.store (get_global $sp) | |
(i64.extend_u/i32 | |
(call $iszero_256 (get_local $a0) (get_local $a1) (get_local $a2) (get_local $a3)) | |
) | |
) | |
;; zero out the rest of memory | |
(i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.const 0)) | |
(i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.const 0)) | |
(i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.const 0)) | |
) | |
(func $check_overflow | |
(param $a i64) | |
(param $b i64) | |
(param $c i64) | |
(param $d i64) | |
(result i32) | |
(local $MAX_INT i32) | |
(set_local $MAX_INT (i32.const -1)) | |
(if | |
(i32.and | |
(i32.and | |
(i64.eqz (get_local $d)) | |
(i64.eqz (get_local $c))) | |
(i32.and | |
(i64.eqz (get_local $b)) | |
(i64.lt_u (get_local $a) (i64.extend_u/i32 (get_local $MAX_INT))))) | |
(return (i32.wrap/i64 (get_local $a)))) | |
(return (get_local $MAX_INT))) | |
(func $DUP | |
(param $a0 i32) | |
(local $sp i32) | |
(local $sp_ref i32) | |
(set_local $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $sp_ref (i32.sub (i32.sub (get_local $sp) (i32.const 8)) (i32.mul (get_local $a0) (i32.const 32)))) | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (i64.load (get_local $sp_ref))) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (i64.load (i32.sub (get_local $sp_ref) (i32.const 8)))) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (i64.load (i32.sub (get_local $sp_ref) (i32.const 16)))) | |
(i64.store (get_local $sp) (i64.load (i32.sub (get_local $sp_ref) (i32.const 24)))) | |
) | |
(func $SWAP | |
(param $a0 i32) | |
(local $sp_ref i32) | |
(local $topa i64) | |
(local $topb i64) | |
(local $topc i64) | |
(local $topd i64) | |
(set_local $sp_ref (i32.sub (i32.add (get_global $sp) (i32.const 24)) (i32.mul (i32.add (get_local $a0) (i32.const 1)) (i32.const 32)))) | |
(set_local $topa (i64.load (i32.add (get_global $sp) (i32.const 24)))) | |
(set_local $topb (i64.load (i32.add (get_global $sp) (i32.const 16)))) | |
(set_local $topc (i64.load (i32.add (get_global $sp) (i32.const 8)))) | |
(set_local $topd (i64.load (get_global $sp))) | |
;; replace the top element | |
(i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.load (get_local $sp_ref))) | |
(i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.load (i32.sub (get_local $sp_ref) (i32.const 8)))) | |
(i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.load (i32.sub (get_local $sp_ref) (i32.const 16)))) | |
(i64.store (get_global $sp) (i64.load (i32.sub (get_local $sp_ref) (i32.const 24)))) | |
;; store the old top element | |
(i64.store (get_local $sp_ref) (get_local $topa)) | |
(i64.store (i32.sub (get_local $sp_ref) (i32.const 8)) (get_local $topb)) | |
(i64.store (i32.sub (get_local $sp_ref) (i32.const 16)) (get_local $topc)) | |
(i64.store (i32.sub (get_local $sp_ref) (i32.const 24)) (get_local $topd)) | |
) | |
;; stack: | |
;; 0: offset | |
(func $MLOAD | |
(local $offset i32) | |
(local $offset0 i64) | |
(local $offset1 i64) | |
(local $offset2 i64) | |
(local $offset3 i64) | |
;; load args from the stack | |
(set_local $offset0 (i64.load (get_global $sp))) | |
(set_local $offset1 (i64.load (i32.add (get_global $sp) (i32.const 8)))) | |
(set_local $offset2 (i64.load (i32.add (get_global $sp) (i32.const 16)))) | |
(set_local $offset3 (i64.load (i32.add (get_global $sp) (i32.const 24)))) | |
(set_local $offset | |
(call $check_overflow (get_local $offset0) | |
(get_local $offset1) | |
(get_local $offset2) | |
(get_local $offset3))) | |
;; subttract gas useage | |
(call $memusegas (get_local $offset) (i32.const 32)) | |
;; FIXME: how to deal with overflow? | |
(set_local $offset (i32.add (get_local $offset) (get_global $memstart))) | |
(i64.store (i32.add (get_global $sp) (i32.const 24)) (i64.load (i32.add (get_local $offset) (i32.const 24)))) | |
(i64.store (i32.add (get_global $sp) (i32.const 16)) (i64.load (i32.add (get_local $offset) (i32.const 16)))) | |
(i64.store (i32.add (get_global $sp) (i32.const 8)) (i64.load (i32.add (get_local $offset) (i32.const 8)))) | |
(i64.store (get_global $sp) (i64.load (get_local $offset))) | |
;; swap | |
(call $bswap_m256 (get_global $sp)) | |
drop | |
) | |
(func $ADD | |
(local $sp i32) | |
(local $a i64) | |
(local $c i64) | |
(local $d i64) | |
(local $carry i64) | |
(set_local $sp (get_global $sp)) | |
;; d c b a | |
;; pop the stack | |
(set_local $a (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $c (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $d (i64.load (get_local $sp))) | |
;; decement the stack pointer | |
(set_local $sp (i32.sub (get_local $sp) (i32.const 8))) | |
;; d | |
(set_local $carry (i64.add (get_local $d) (i64.load (i32.sub (get_local $sp) (i32.const 24))))) | |
;; save d to mem | |
(i64.store (i32.sub (get_local $sp) (i32.const 24)) (get_local $carry)) | |
;; check for overflow | |
(set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $carry) (get_local $d)))) | |
;; c use $d as reg | |
(set_local $d (i64.add (i64.load (i32.sub (get_local $sp) (i32.const 16))) (get_local $carry))) | |
(set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $carry)))) | |
(set_local $d (i64.add (get_local $c) (get_local $d))) | |
;; store the result | |
(i64.store (i32.sub (get_local $sp) (i32.const 16)) (get_local $d)) | |
;; check overflow | |
(set_local $carry (i64.or (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $c))) (get_local $carry))) | |
;; b | |
;; add carry | |
(set_local $d (i64.add (i64.load (i32.sub (get_local $sp) (i32.const 8))) (get_local $carry))) | |
(set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $carry)))) | |
;; use reg c | |
(set_local $c (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $d (i64.add (get_local $c) (get_local $d))) | |
(i64.store (i32.sub (get_local $sp) (i32.const 8)) (get_local $d)) | |
;; a | |
(i64.store (get_local $sp) | |
(i64.add ;; add a | |
(get_local $a) | |
(i64.add | |
(i64.load (get_local $sp)) ;; load the operand | |
(i64.or ;; carry | |
(i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $c))) | |
(get_local $carry))))) | |
) | |
(func $LT | |
(local $sp i32) | |
(local $a0 i64) | |
(local $a1 i64) | |
(local $a2 i64) | |
(local $a3 i64) | |
(local $b0 i64) | |
(local $b1 i64) | |
(local $b2 i64) | |
(local $b3 i64) | |
(set_local $sp (get_global $sp)) | |
;; load args from the stack | |
(set_local $a0 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $a1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $a2 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $a3 (i64.load (get_local $sp))) | |
(set_local $sp (i32.sub (get_local $sp) (i32.const 32))) | |
(set_local $b0 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $b1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $b2 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $b3 (i64.load (get_local $sp))) | |
(i64.store (get_local $sp) (i64.extend_u/i32 | |
(i32.or (i64.lt_u (get_local $a0) (get_local $b0)) ;; a0 < b0 | |
(i32.and (i64.eq (get_local $a0) (get_local $b0)) ;; a0 == b0 | |
(i32.or (i64.lt_u (get_local $a1) (get_local $b1)) ;; a1 < b1 | |
(i32.and (i64.eq (get_local $a1) (get_local $b1)) ;; a1 == b1 | |
(i32.or (i64.lt_u (get_local $a2) (get_local $b2)) ;; a2 < b2 | |
(i32.and (i64.eq (get_local $a2) (get_local $b2)) ;; a2 == b2 | |
(i64.lt_u (get_local $a3) (get_local $b3)))))))))) ;; a3 < b3 | |
;; zero out the rest of the stack item | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (i64.const 0)) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (i64.const 0)) | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (i64.const 0)) | |
) | |
(func $MUL | |
(call $mul_256 | |
(i64.load (i32.add (get_global $sp) (i32.const 24))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (get_global $sp)) | |
(i64.load (i32.sub (get_global $sp) (i32.const 8))) | |
(i64.load (i32.sub (get_global $sp) (i32.const 16))) | |
(i64.load (i32.sub (get_global $sp) (i32.const 24))) | |
(i64.load (i32.sub (get_global $sp) (i32.const 32))) | |
(i32.sub (get_global $sp) (i32.const 8)) | |
) | |
) | |
(func $MOD | |
(local $sp i32) | |
;; dividend | |
(local $a i64) | |
(local $b i64) | |
(local $c i64) | |
(local $d i64) | |
;; divisor | |
(local $a1 i64) | |
(local $b1 i64) | |
(local $c1 i64) | |
(local $d1 i64) | |
;; quotient | |
(local $aq i64) | |
(local $bq i64) | |
(local $cq i64) | |
(local $dq i64) | |
;; mask | |
(local $maska i64) | |
(local $maskb i64) | |
(local $maskc i64) | |
(local $maskd i64) | |
(local $carry i32) | |
(local $temp i64) | |
(set_local $maskd (i64.const 1)) | |
;; load args from the stack | |
(set_local $a (i64.load (i32.add (get_global $sp) (i32.const 24)))) | |
(set_local $b (i64.load (i32.add (get_global $sp) (i32.const 16)))) | |
(set_local $c (i64.load (i32.add (get_global $sp) (i32.const 8)))) | |
(set_local $d (i64.load (get_global $sp))) | |
;; decement the stack pointer | |
(set_local $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(set_local $a1 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $b1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $c1 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $d1 (i64.load (get_local $sp))) | |
(block $main | |
;; check div by 0 | |
(if (call $iszero_256 (get_local $a1) (get_local $b1) (get_local $c1) (get_local $d1)) | |
(then | |
(set_local $a (i64.const 0)) | |
(set_local $b (i64.const 0)) | |
(set_local $c (i64.const 0)) | |
(set_local $d (i64.const 0)) | |
(br $main) | |
) | |
) | |
;; align bits | |
(block $done | |
(loop $loop | |
;; align bits; | |
(if (i32.or (i64.eqz (i64.clz (get_local $a1))) (call $gte_256 (get_local $a1) (get_local $b1) (get_local $c1) (get_local $d1) (get_local $a) (get_local $b) (get_local $c) (get_local $d))) | |
(br $done) | |
) | |
;; divisor = divisor << 1 | |
(set_local $a1 (i64.add (i64.shl (get_local $a1) (i64.const 1)) (i64.shr_u (get_local $b1) (i64.const 63)))) | |
(set_local $b1 (i64.add (i64.shl (get_local $b1) (i64.const 1)) (i64.shr_u (get_local $c1) (i64.const 63)))) | |
(set_local $c1 (i64.add (i64.shl (get_local $c1) (i64.const 1)) (i64.shr_u (get_local $d1) (i64.const 63)))) | |
(set_local $d1 (i64.shl (get_local $d1) (i64.const 1))) | |
;; mask = mask << 1 | |
(set_local $maska (i64.add (i64.shl (get_local $maska) (i64.const 1)) (i64.shr_u (get_local $maskb) (i64.const 63)))) | |
(set_local $maskb (i64.add (i64.shl (get_local $maskb) (i64.const 1)) (i64.shr_u (get_local $maskc) (i64.const 63)))) | |
(set_local $maskc (i64.add (i64.shl (get_local $maskc) (i64.const 1)) (i64.shr_u (get_local $maskd) (i64.const 63)))) | |
(set_local $maskd (i64.shl (get_local $maskd) (i64.const 1))) | |
(br $loop) | |
) | |
) | |
(block $done | |
(loop $loop | |
;; loop while mask != 0 | |
(if (call $iszero_256 (get_local $maska) (get_local $maskb) (get_local $maskc) (get_local $maskd)) | |
(br $done) | |
) | |
;; if dividend >= divisor | |
(if (call $gte_256 (get_local $a) (get_local $b) (get_local $c) (get_local $d) (get_local $a1) (get_local $b1) (get_local $c1) (get_local $d1)) | |
(then | |
;; dividend = dividend - divisor | |
(set_local $carry (i64.lt_u (get_local $d) (get_local $d1))) | |
(set_local $d (i64.sub (get_local $d) (get_local $d1))) | |
(set_local $temp (i64.sub (get_local $c) (i64.extend_u/i32 (get_local $carry)))) | |
(set_local $carry (i64.gt_u (get_local $temp) (get_local $c))) | |
(set_local $c (i64.sub (get_local $temp) (get_local $c1))) | |
(set_local $carry (i32.or (i64.gt_u (get_local $c) (get_local $temp)) (get_local $carry))) | |
(set_local $temp (i64.sub (get_local $b) (i64.extend_u/i32 (get_local $carry)))) | |
(set_local $carry (i64.gt_u (get_local $temp) (get_local $b))) | |
(set_local $b (i64.sub (get_local $temp) (get_local $b1))) | |
(set_local $carry (i32.or (i64.gt_u (get_local $b) (get_local $temp)) (get_local $carry))) | |
(set_local $a (i64.sub (i64.sub (get_local $a) (i64.extend_u/i32 (get_local $carry))) (get_local $a1))) | |
) | |
) | |
;; divisor = divisor >> 1 | |
(set_local $d1 (i64.add (i64.shr_u (get_local $d1) (i64.const 1)) (i64.shl (get_local $c1) (i64.const 63)))) | |
(set_local $c1 (i64.add (i64.shr_u (get_local $c1) (i64.const 1)) (i64.shl (get_local $b1) (i64.const 63)))) | |
(set_local $b1 (i64.add (i64.shr_u (get_local $b1) (i64.const 1)) (i64.shl (get_local $a1) (i64.const 63)))) | |
(set_local $a1 (i64.shr_u (get_local $a1) (i64.const 1))) | |
;; mask = mask >> 1 | |
(set_local $maskd (i64.add (i64.shr_u (get_local $maskd) (i64.const 1)) (i64.shl (get_local $maskc) (i64.const 63)))) | |
(set_local $maskc (i64.add (i64.shr_u (get_local $maskc) (i64.const 1)) (i64.shl (get_local $maskb) (i64.const 63)))) | |
(set_local $maskb (i64.add (i64.shr_u (get_local $maskb) (i64.const 1)) (i64.shl (get_local $maska) (i64.const 63)))) | |
(set_local $maska (i64.shr_u (get_local $maska) (i64.const 1))) | |
(br $loop) | |
) | |
) | |
);; end of main | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (get_local $a)) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (get_local $b)) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (get_local $c)) | |
(i64.store (get_local $sp) (get_local $d)) | |
) | |
(func $AND | |
(i64.store (i32.sub (get_global $sp) (i32.const 8)) (i64.and (i64.load (i32.sub (get_global $sp) (i32.const 8))) (i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(i64.store (i32.sub (get_global $sp) (i32.const 16)) (i64.and (i64.load (i32.sub (get_global $sp) (i32.const 16))) (i64.load (i32.add (get_global $sp) (i32.const 16))))) | |
(i64.store (i32.sub (get_global $sp) (i32.const 24)) (i64.and (i64.load (i32.sub (get_global $sp) (i32.const 24))) (i64.load (i32.add (get_global $sp) (i32.const 8))))) | |
(i64.store (i32.sub (get_global $sp) (i32.const 32)) (i64.and (i64.load (i32.sub (get_global $sp) (i32.const 32))) (i64.load (get_global $sp)))) | |
) | |
(func $EXP | |
(local $sp i32) | |
;; base | |
(local $base0 i64) | |
(local $base1 i64) | |
(local $base2 i64) | |
(local $base3 i64) | |
;; exp | |
(local $exp0 i64) | |
(local $exp1 i64) | |
(local $exp2 i64) | |
(local $exp3 i64) | |
(local $r0 i64) | |
(local $r1 i64) | |
(local $r2 i64) | |
(local $r3 i64) | |
(local $gasCounter f32) | |
(set_local $sp (get_global $sp)) | |
;; load args from the stack | |
(set_local $base0 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $base1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $base2 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $base3 (i64.load (get_local $sp))) | |
(set_local $sp (i32.sub (get_local $sp) (i32.const 32))) | |
(set_local $exp0 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $exp1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $exp2 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $exp3 (i64.load (get_local $sp))) | |
;; let result = new BN[1] | |
(set_local $r3 (i64.const 1)) | |
(block $done | |
(loop $loop | |
;; while [exp > 0] { | |
(if (call $iszero_256 (get_local $exp0) (get_local $exp1) (get_local $exp2) (get_local $exp3)) | |
(br $done) | |
) | |
;; if[exp.modn[2] === 1] | |
;; is odd? | |
(if (i64.eqz (i64.ctz (get_local $exp3))) | |
;; result = result.mul[base].mod[TWO_POW256] | |
;; r = r * a | |
(then | |
(call $mul_256 (get_local $r0) (get_local $r1) (get_local $r2) (get_local $r3) (get_local $base0) (get_local $base1) (get_local $base2) (get_local $base3) (i32.add (get_local $sp) (i32.const 24))) | |
(set_local $r0 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $r1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $r2 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $r3 (i64.load (get_local $sp))) | |
) | |
) | |
;; exp = exp.shrn 1 | |
(set_local $exp3 (i64.add (i64.shr_u (get_local $exp3) (i64.const 1)) (i64.shl (get_local $exp2) (i64.const 63)))) | |
(set_local $exp2 (i64.add (i64.shr_u (get_local $exp2) (i64.const 1)) (i64.shl (get_local $exp1) (i64.const 63)))) | |
(set_local $exp1 (i64.add (i64.shr_u (get_local $exp1) (i64.const 1)) (i64.shl (get_local $exp0) (i64.const 63)))) | |
(set_local $exp0 (i64.shr_u (get_local $exp0) (i64.const 1))) | |
;; base = base.mulr[baser].modr[TWO_POW256] | |
(call $mul_256 (get_local $base0) (get_local $base1) (get_local $base2) (get_local $base3) (get_local $base0) (get_local $base1) (get_local $base2) (get_local $base3) (i32.add (get_local $sp) (i32.const 24))) | |
(set_local $base0 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $base1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $base2 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $base3 (i64.load (get_local $sp))) | |
(set_local $gasCounter (f32.add (get_local $gasCounter) (f32.const 1))) | |
(br $loop) | |
) | |
) | |
;; use gas | |
;; Log256[Exponent] * 10 | |
(call $useGas (i64.extend_u/i32 (i32.mul (i32.const 10) (i32.trunc_s/f32 | |
(f32.ceil (f32.div (get_local $gasCounter) (f32.const 8))))))) | |
;; decement the stack pointer | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (get_local $r0)) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (get_local $r1)) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (get_local $r2)) | |
(i64.store (get_local $sp) (get_local $r3)) | |
) | |
(func $OR | |
(i64.store (i32.sub (get_global $sp) (i32.const 8)) (i64.or (i64.load (i32.sub (get_global $sp) (i32.const 8))) (i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(i64.store (i32.sub (get_global $sp) (i32.const 16)) (i64.or (i64.load (i32.sub (get_global $sp) (i32.const 16))) (i64.load (i32.add (get_global $sp) (i32.const 16))))) | |
(i64.store (i32.sub (get_global $sp) (i32.const 24)) (i64.or (i64.load (i32.sub (get_global $sp) (i32.const 24))) (i64.load (i32.add (get_global $sp) (i32.const 8))))) | |
(i64.store (i32.sub (get_global $sp) (i32.const 32)) (i64.or (i64.load (i32.sub (get_global $sp) (i32.const 32))) (i64.load (get_global $sp)))) | |
) | |
(func $SUB | |
(local $sp i32) | |
(local $a i64) | |
(local $b i64) | |
(local $c i64) | |
(local $d i64) | |
(local $a1 i64) | |
(local $b1 i64) | |
(local $c1 i64) | |
(local $d1 i64) | |
(local $carry i64) | |
(local $temp i64) | |
(set_local $a (i64.load (i32.add (get_global $sp) (i32.const 24)))) | |
(set_local $b (i64.load (i32.add (get_global $sp) (i32.const 16)))) | |
(set_local $c (i64.load (i32.add (get_global $sp) (i32.const 8)))) | |
(set_local $d (i64.load (get_global $sp))) | |
;; decement the stack pointer | |
(set_local $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(set_local $a1 (i64.load (i32.add (get_local $sp) (i32.const 24)))) | |
(set_local $b1 (i64.load (i32.add (get_local $sp) (i32.const 16)))) | |
(set_local $c1 (i64.load (i32.add (get_local $sp) (i32.const 8)))) | |
(set_local $d1 (i64.load (get_local $sp))) | |
;; a * 64^3 + b*64^2 + c*64 + d | |
;; d | |
(set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $d1)))) | |
(set_local $d (i64.sub (get_local $d) (get_local $d1))) | |
;; c | |
(set_local $temp (i64.sub (get_local $c) (get_local $carry))) | |
(set_local $carry (i64.extend_u/i32 (i64.gt_u (get_local $temp) (get_local $c)))) | |
(set_local $c (i64.sub (get_local $temp) (get_local $c1))) | |
(set_local $carry (i64.or (i64.extend_u/i32 (i64.gt_u (get_local $c) (get_local $temp))) (get_local $carry))) | |
;; b | |
(set_local $temp (i64.sub (get_local $b) (get_local $carry))) | |
(set_local $carry (i64.extend_u/i32 (i64.gt_u (get_local $temp) (get_local $b)))) | |
(set_local $b (i64.sub (get_local $temp) (get_local $b1))) | |
;; a | |
(set_local $a (i64.sub (i64.sub (get_local $a) (i64.or (i64.extend_u/i32 (i64.gt_u (get_local $b) (get_local $temp))) (get_local $carry))) (get_local $a1))) | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (get_local $a)) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (get_local $b)) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (get_local $c)) | |
(i64.store (get_local $sp) (get_local $d)) | |
) | |
;; generated by ./wasm/generateInterface.js | |
(func $CODECOPY (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 | |
(call $check_overflow | |
(i64.load (i32.add (get_global $sp) (i32.const 0))) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24)))))(set_local $length0 | |
(call $check_overflow | |
(i64.load (i32.add (get_global $sp) (i32.const -64))) | |
(i64.load (i32.add (get_global $sp) (i32.const -56))) | |
(i64.load (i32.add (get_global $sp) (i32.const -48))) | |
(i64.load (i32.add (get_global $sp) (i32.const -40))))) | |
(call $memusegas (get_local $offset0) (get_local $length0)) | |
(set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))));; generated by ./wasm/generateInterface.js | |
(func $RETURN (local $offset0 i32)(local $length0 i32) (set_local $offset0 | |
(call $check_overflow | |
(i64.load (i32.add (get_global $sp) (i32.const 0))) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24)))))(set_local $length0 | |
(call $check_overflow | |
(i64.load (i32.add (get_global $sp) (i32.const -32))) | |
(i64.load (i32.add (get_global $sp) (i32.const -24))) | |
(i64.load (i32.add (get_global $sp) (i32.const -16))) | |
(i64.load (i32.add (get_global $sp) (i32.const -8))))) | |
(call $memusegas (get_local $offset0) (get_local $length0)) | |
(set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0)))) | |
(func $memusegas | |
(param $offset i32) | |
(param $length i32) | |
(local $cost i64) | |
;; the number of new words being allocated | |
(local $newWordCount i64) | |
(if (i32.eqz (get_local $length)) | |
(then (return)) | |
) | |
;; const newMemoryWordCount = Math.ceil[[offset + length] / 32] | |
(set_local $newWordCount | |
(i64.div_u (i64.add (i64.const 31) (i64.add (i64.extend_u/i32 (get_local $offset)) (i64.extend_u/i32 (get_local $length)))) | |
(i64.const 32))) | |
;;if [runState.highestMem >= highestMem] return | |
(if (i64.le_u (get_local $newWordCount) (get_global $wordCount)) | |
(then (return)) | |
) | |
;; words * 3 + words ^2 / 512 | |
(set_local $cost | |
(i64.add | |
(i64.mul (get_local $newWordCount) (i64.const 3)) | |
(i64.div_u | |
(i64.mul (get_local $newWordCount) | |
(get_local $newWordCount)) | |
(i64.const 512)))) | |
(call $useGas (i64.sub (get_local $cost) (get_global $prevMemCost))) | |
(set_global $prevMemCost (get_local $cost)) | |
(set_global $wordCount (get_local $newWordCount)) | |
;; grow actual memory | |
;; the first 31704 bytes are guaranteed to be available | |
;; adjust for 32 bytes - the maximal size of MSTORE write | |
;; TODO it should be current_memory * page_size | |
(set_local $offset (i32.add (get_local $length) (i32.add (get_local $offset) (get_global $memstart)))) | |
(if (i32.gt_u (get_local $offset) (i32.mul (i32.const 65536) (current_memory))) | |
(then | |
(grow_memory | |
(i32.div_u (i32.add (i32.const 65535) (i32.sub (get_local $offset) (current_memory))) (i32.const 65536))) | |
drop | |
) | |
) | |
) | |
(func $bswap_m256 | |
(param $sp i32) | |
(result i32) | |
(local $temp i64) | |
(set_local $temp (call $bswap_i64 (i64.load (get_local $sp)))) | |
(i64.store (get_local $sp) (call $bswap_i64 (i64.load (i32.add (get_local $sp) (i32.const 24))))) | |
(i64.store (i32.add (get_local $sp) (i32.const 24)) (get_local $temp)) | |
(set_local $temp (call $bswap_i64 (i64.load (i32.add (get_local $sp) (i32.const 8))))) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (call $bswap_i64 (i64.load (i32.add (get_local $sp) (i32.const 16))))) | |
(i64.store (i32.add (get_local $sp) (i32.const 16)) (get_local $temp)) | |
(get_local $sp) | |
) | |
(func $bswap_m128 | |
(param $sp i32) | |
(result i32) | |
(local $temp i64) | |
(set_local $temp (call $bswap_i64 (i64.load (get_local $sp)))) | |
(i64.store (get_local $sp) (call $bswap_i64 (i64.load (i32.add (get_local $sp) (i32.const 8))))) | |
(i64.store (i32.add (get_local $sp) (i32.const 8)) (get_local $temp)) | |
(get_local $sp) | |
) | |
(func $iszero_256 | |
(param i64) | |
(param i64) | |
(param i64) | |
(param i64) | |
(result i32) | |
(i64.eqz (i64.or (i64.or (i64.or (get_local 0) (get_local 1)) (get_local 2)) (get_local 3))) | |
) | |
(func $mul_256 | |
;; a b c d e f g h | |
;;* i j k l m n o p | |
;;---------------- | |
(param $a i64) | |
(param $c i64) | |
(param $e i64) | |
(param $g i64) | |
(param $i i64) | |
(param $k i64) | |
(param $m i64) | |
(param $o i64) | |
(param $sp i32) | |
(local $b i64) | |
(local $d i64) | |
(local $f i64) | |
(local $h i64) | |
(local $j i64) | |
(local $l i64) | |
(local $n i64) | |
(local $p i64) | |
(local $temp6 i64) | |
(local $temp5 i64) | |
(local $temp4 i64) | |
(local $temp3 i64) | |
(local $temp2 i64) | |
(local $temp1 i64) | |
(local $temp0 i64) | |
;; split the ops | |
(set_local $b (i64.and (get_local $a) (i64.const 4294967295))) | |
(set_local $a (i64.shr_u (get_local $a) (i64.const 32))) | |
(set_local $d (i64.and (get_local $c) (i64.const 4294967295))) | |
(set_local $c (i64.shr_u (get_local $c) (i64.const 32))) | |
(set_local $f (i64.and (get_local $e) (i64.const 4294967295))) | |
(set_local $e (i64.shr_u (get_local $e) (i64.const 32))) | |
(set_local $h (i64.and (get_local $g) (i64.const 4294967295))) | |
(set_local $g (i64.shr_u (get_local $g) (i64.const 32))) | |
(set_local $j (i64.and (get_local $i) (i64.const 4294967295))) | |
(set_local $i (i64.shr_u (get_local $i) (i64.const 32))) | |
(set_local $l (i64.and (get_local $k) (i64.const 4294967295))) | |
(set_local $k (i64.shr_u (get_local $k) (i64.const 32))) | |
(set_local $n (i64.and (get_local $m) (i64.const 4294967295))) | |
(set_local $m (i64.shr_u (get_local $m) (i64.const 32))) | |
(set_local $p (i64.and (get_local $o) (i64.const 4294967295))) | |
(set_local $o (i64.shr_u (get_local $o) (i64.const 32))) | |
;; first row multiplication | |
;; p * h | |
(set_local $temp0 (i64.mul (get_local $p) (get_local $h))) | |
;; p * g + carry | |
(set_local $temp1 (i64.add (i64.mul (get_local $p) (get_local $g)) (i64.shr_u (get_local $temp0) (i64.const 32)))) | |
;; p * f + carry | |
(set_local $temp2 (i64.add (i64.mul (get_local $p) (get_local $f)) (i64.shr_u (get_local $temp1) (i64.const 32)))) | |
;; p * e + carry | |
(set_local $temp3 (i64.add (i64.mul (get_local $p) (get_local $e)) (i64.shr_u (get_local $temp2) (i64.const 32)))) | |
;; p * d + carry | |
(set_local $temp4 (i64.add (i64.mul (get_local $p) (get_local $d)) (i64.shr_u (get_local $temp3) (i64.const 32)))) | |
;; p * c + carry | |
(set_local $temp5 (i64.add (i64.mul (get_local $p) (get_local $c)) (i64.shr_u (get_local $temp4) (i64.const 32)))) | |
;; p * b + carry | |
(set_local $temp6 (i64.add (i64.mul (get_local $p) (get_local $b)) (i64.shr_u (get_local $temp5) (i64.const 32)))) | |
;; p * a + carry | |
(set_local $a (i64.add (i64.mul (get_local $p) (get_local $a)) (i64.shr_u (get_local $temp6) (i64.const 32)))) | |
;; second row | |
;; o * h + $temp1 "pg" | |
(set_local $temp1 (i64.add (i64.mul (get_local $o) (get_local $h)) (i64.and (get_local $temp1) (i64.const 4294967295)))) | |
;; o * g + $temp2 "pf" + carry | |
(set_local $temp2 (i64.add (i64.add (i64.mul (get_local $o) (get_local $g)) (i64.and (get_local $temp2) (i64.const 4294967295))) (i64.shr_u (get_local $temp1) (i64.const 32)))) | |
;; o * f + $temp3 "pe" + carry | |
(set_local $temp3 (i64.add (i64.add (i64.mul (get_local $o) (get_local $f)) (i64.and (get_local $temp3) (i64.const 4294967295))) (i64.shr_u (get_local $temp2) (i64.const 32)))) | |
;; o * e + $temp4 + carry | |
(set_local $temp4 (i64.add (i64.add (i64.mul (get_local $o) (get_local $e)) (i64.and (get_local $temp4) (i64.const 4294967295))) (i64.shr_u (get_local $temp3) (i64.const 32)))) | |
;; o * d + $temp5 + carry | |
(set_local $temp5 (i64.add (i64.add (i64.mul (get_local $o) (get_local $d)) (i64.and (get_local $temp5) (i64.const 4294967295))) (i64.shr_u (get_local $temp4) (i64.const 32)))) | |
;; o * c + $temp6 + carry | |
(set_local $temp6 (i64.add (i64.add (i64.mul (get_local $o) (get_local $c)) (i64.and (get_local $temp6) (i64.const 4294967295))) (i64.shr_u (get_local $temp5) (i64.const 32)))) | |
;; o * b + $a + carry | |
(set_local $a (i64.add (i64.add (i64.mul (get_local $o) (get_local $b)) (i64.and (get_local $a) (i64.const 4294967295))) (i64.shr_u (get_local $temp6) (i64.const 32)))) | |
;; third row - n | |
;; n * h + $temp2 | |
(set_local $temp2 (i64.add (i64.mul (get_local $n) (get_local $h)) (i64.and (get_local $temp2) (i64.const 4294967295)))) | |
;; n * g + $temp3 + carry | |
(set_local $temp3 (i64.add (i64.add (i64.mul (get_local $n) (get_local $g)) (i64.and (get_local $temp3) (i64.const 4294967295))) (i64.shr_u (get_local $temp2) (i64.const 32)))) | |
;; n * f + $temp4 + carry | |
(set_local $temp4 (i64.add (i64.add (i64.mul (get_local $n) (get_local $f)) (i64.and (get_local $temp4) (i64.const 4294967295))) (i64.shr_u (get_local $temp3) (i64.const 32)))) | |
;; n * e + $temp5 + carry | |
(set_local $temp5 (i64.add (i64.add (i64.mul (get_local $n) (get_local $e)) (i64.and (get_local $temp5) (i64.const 4294967295))) (i64.shr_u (get_local $temp4) (i64.const 32)))) | |
;; n * d + $temp6 + carry | |
(set_local $temp6 (i64.add (i64.add (i64.mul (get_local $n) (get_local $d)) (i64.and (get_local $temp6) (i64.const 4294967295))) (i64.shr_u (get_local $temp5) (i64.const 32)))) | |
;; n * c + $a + carry | |
(set_local $a (i64.add (i64.add (i64.mul (get_local $n) (get_local $c)) (i64.and (get_local $a) (i64.const 4294967295))) (i64.shr_u (get_local $temp6) (i64.const 32)))) | |
;; forth row | |
;; m * h + $temp3 | |
(set_local $temp3 (i64.add (i64.mul (get_local $m) (get_local $h)) (i64.and (get_local $temp3) (i64.const 4294967295)))) | |
;; m * g + $temp4 + carry | |
(set_local $temp4 (i64.add (i64.add (i64.mul (get_local $m) (get_local $g)) (i64.and (get_local $temp4) (i64.const 4294967295))) (i64.shr_u (get_local $temp3) (i64.const 32)))) | |
;; m * f + $temp5 + carry | |
(set_local $temp5 (i64.add (i64.add (i64.mul (get_local $m) (get_local $f)) (i64.and (get_local $temp5) (i64.const 4294967295))) (i64.shr_u (get_local $temp4) (i64.const 32)))) | |
;; m * e + $temp6 + carry | |
(set_local $temp6 (i64.add (i64.add (i64.mul (get_local $m) (get_local $e)) (i64.and (get_local $temp6) (i64.const 4294967295))) (i64.shr_u (get_local $temp5) (i64.const 32)))) | |
;; m * d + $a + carry | |
(set_local $a (i64.add (i64.add (i64.mul (get_local $m) (get_local $d)) (i64.and (get_local $a) (i64.const 4294967295))) (i64.shr_u (get_local $temp6) (i64.const 32)))) | |
;; fith row | |
;; l * h + $temp4 | |
(set_local $temp4 (i64.add (i64.mul (get_local $l) (get_local $h)) (i64.and (get_local $temp4) (i64.const 4294967295)))) | |
;; l * g + $temp5 + carry | |
(set_local $temp5 (i64.add (i64.add (i64.mul (get_local $l) (get_local $g)) (i64.and (get_local $temp5) (i64.const 4294967295))) (i64.shr_u (get_local $temp4) (i64.const 32)))) | |
;; l * f + $temp6 + carry | |
(set_local $temp6 (i64.add (i64.add (i64.mul (get_local $l) (get_local $f)) (i64.and (get_local $temp6) (i64.const 4294967295))) (i64.shr_u (get_local $temp5) (i64.const 32)))) | |
;; l * e + $a + carry | |
(set_local $a (i64.add (i64.add (i64.mul (get_local $l) (get_local $e)) (i64.and (get_local $a) (i64.const 4294967295))) (i64.shr_u (get_local $temp6) (i64.const 32)))) | |
;; sixth row | |
;; k * h + $temp5 | |
(set_local $temp5 (i64.add (i64.mul (get_local $k) (get_local $h)) (i64.and (get_local $temp5) (i64.const 4294967295)))) | |
;; k * g + $temp6 + carry | |
(set_local $temp6 (i64.add (i64.add (i64.mul (get_local $k) (get_local $g)) (i64.and (get_local $temp6) (i64.const 4294967295))) (i64.shr_u (get_local $temp5) (i64.const 32)))) | |
;; k * f + $a + carry | |
(set_local $a (i64.add (i64.add (i64.mul (get_local $k) (get_local $f)) (i64.and (get_local $a) (i64.const 4294967295))) (i64.shr_u (get_local $temp6) (i64.const 32)))) | |
;; seventh row | |
;; j * h + $temp6 | |
(set_local $temp6 (i64.add (i64.mul (get_local $j) (get_local $h)) (i64.and (get_local $temp6) (i64.const 4294967295)))) | |
;; j * g + $a + carry | |
;; eigth row | |
;; i * h + $a | |
(set_local $a (i64.add (i64.mul (get_local $i) (get_local $h)) (i64.and (i64.add (i64.add (i64.mul (get_local $j) (get_local $g)) (i64.and (get_local $a) (i64.const 4294967295))) (i64.shr_u (get_local $temp6) (i64.const 32))) (i64.const 4294967295)))) | |
;; combine terms | |
(set_local $a (i64.or (i64.shl (get_local $a) (i64.const 32)) (i64.and (get_local $temp6) (i64.const 4294967295)))) | |
(set_local $c (i64.or (i64.shl (get_local $temp5) (i64.const 32)) (i64.and (get_local $temp4) (i64.const 4294967295)))) | |
(set_local $e (i64.or (i64.shl (get_local $temp3) (i64.const 32)) (i64.and (get_local $temp2) (i64.const 4294967295)))) | |
(set_local $g (i64.or (i64.shl (get_local $temp1) (i64.const 32)) (i64.and (get_local $temp0) (i64.const 4294967295)))) | |
;; save stack | |
(i64.store (get_local $sp) (get_local $a)) | |
(i64.store (i32.sub (get_local $sp) (i32.const 8)) (get_local $c)) | |
(i64.store (i32.sub (get_local $sp) (i32.const 16)) (get_local $e)) | |
(i64.store (i32.sub (get_local $sp) (i32.const 24)) (get_local $g)) | |
) | |
;; is a less than or equal to b // a >= b | |
(func $gte_256 | |
(param $a0 i64) | |
(param $a1 i64) | |
(param $a2 i64) | |
(param $a3 i64) | |
(param $b0 i64) | |
(param $b1 i64) | |
(param $b2 i64) | |
(param $b3 i64) | |
(result i32) | |
;; a0 > b0 || [a0 == b0 && [a1 > b1 || [a1 == b1 && [a2 > b2 || [a2 == b2 && a3 >= b3 ]]]] | |
(i32.or (i64.gt_u (get_local $a0) (get_local $b0)) ;; a0 > b0 | |
(i32.and (i64.eq (get_local $a0) (get_local $b0)) | |
(i32.or (i64.gt_u (get_local $a1) (get_local $b1)) ;; a1 > b1 | |
(i32.and (i64.eq (get_local $a1) (get_local $b1)) ;; a1 == b1 | |
(i32.or (i64.gt_u (get_local $a2) (get_local $b2)) ;; a2 > b2 | |
(i32.and (i64.eq (get_local $a2) (get_local $b2)) | |
(i64.ge_u (get_local $a3) (get_local $b3)))))))) | |
) | |
(func $callback | |
(export "0") | |
call $main | |
) | |
(func $memset | |
(param $ptr i32) | |
(param $value i32) | |
(param $length i32) | |
(result i32) | |
(local $i i32) | |
(set_local $i (i32.const 0)) | |
(block $done | |
(loop $loop | |
(if (i32.ge_u (get_local $i) (get_local $length)) | |
(br $done) | |
) | |
(i32.store8 (i32.add (get_local $ptr) (get_local $i)) (get_local $value)) | |
(set_local $i (i32.add (get_local $i) (i32.const 1))) | |
(br $loop) | |
) | |
) | |
(get_local $ptr) | |
) | |
(func $bswap_i64 | |
(param $int i64) | |
(result i64) | |
(i64.or | |
(i64.or | |
(i64.or | |
(i64.and (i64.shr_u (get_local $int) (i64.const 56)) (i64.const 0xff)) ;; 7 -> 0 | |
(i64.and (i64.shr_u (get_local $int) (i64.const 40)) (i64.const 0xff00))) ;; 6 -> 1 | |
(i64.or | |
(i64.and (i64.shr_u (get_local $int) (i64.const 24)) (i64.const 0xff0000)) ;; 5 -> 2 | |
(i64.and (i64.shr_u (get_local $int) (i64.const 8)) (i64.const 0xff000000)))) ;; 4 -> 3 | |
(i64.or | |
(i64.or | |
(i64.and (i64.shl (get_local $int) (i64.const 8)) (i64.const 0xff00000000)) ;; 3 -> 4 | |
(i64.and (i64.shl (get_local $int) (i64.const 24)) (i64.const 0xff0000000000))) ;; 2 -> 5 | |
(i64.or | |
(i64.and (i64.shl (get_local $int) (i64.const 40)) (i64.const 0xff000000000000)) ;; 1 -> 6 | |
(i64.and (i64.shl (get_local $int) (i64.const 56)) (i64.const 0xff00000000000000)))))) ;; 0 -> 7 | |
(func $main | |
(export "main") | |
(local $jump_dest i32) | |
(set_local $jump_dest (i32.const -1)) | |
(block $done | |
(loop $loop | |
(block $23 (block $22 (block $21 (block $20 (block $19 (block $18 (block $17 (block $16 (block $15 (block $14 (block $13 (block $12 (block $11 (block $10 (block $9 (block $8 (block $7 (block $6 (block $5 (block $4 (block $3 (block $2 (block $1 | |
(block $0 | |
(if | |
(i32.eqz (get_global $init)) | |
(then | |
(set_global $init (i32.const 1)) | |
(br $0)) | |
(else | |
;; the callback dest can never be in the first block | |
(if (i32.eq (get_global $cb_dest) (i32.const 0)) | |
(then | |
(if (i32.eq (get_local $jump_dest) (i32.const 499)) | |
(then (br $23)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 480)) | |
(then (br $21)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 456)) | |
(then (br $20)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 440)) | |
(then (br $19)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 428)) | |
(then (br $18)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 427)) | |
(then (br $17)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 416)) | |
(then (br $16)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 415)) | |
(then (br $15)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 404)) | |
(then (br $14)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 403)) | |
(then (br $13)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 392)) | |
(then (br $12)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 376)) | |
(then (br $11)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 343)) | |
(then (br $10)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 325)) | |
(then (br $9)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 302)) | |
(then (br $8)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 279)) | |
(then (br $7)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 265)) | |
(then (br $6)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 203)) | |
(then (br $5)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 36)) | |
(then (br $4)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 26)) | |
(then (br $3)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 16)) | |
(then (br $2)) | |
(else (if (i32.eq (get_local $jump_dest) (i32.const 15)) | |
(then (br $1)) | |
(else (unreachable))))))))))))))))))))))))))))))))))))))))))))) | |
) | |
(else | |
;; return callback destination and zero out $cb_dest | |
get_global $cb_dest | |
(set_global $cb_dest (i32.const 0)) | |
(br_table $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21 $22 $23) | |
)))))(call $useGas (i64.const 25)) (if (i32.gt_s (get_global $sp) (i32.const 32672)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 96))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $CALLVALUE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 15))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 6)) (if (i32.gt_s (get_global $sp) (i32.const 32672)) | |
(then (unreachable)))(unreachable))(call $useGas (i64.const 1)) )(call $useGas (i64.const 18)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 26))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 440))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 18)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 36))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 440))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 129)) (if (i32.gt_s (get_global $sp) (i32.const 32512)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 443543680542511701)(i64.const 344247212463718940)(i64.const 5992386160940858271)(i64.const -3886226386111196107))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $SWAP (i32.const 6)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 160))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MLOAD) | |
(call $SWAP (i32.const 0)) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const -6238188808268888351)(i64.const -197426961966726749))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const -1425741358519301134)(i64.const 143403728032683259))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const -2620361034835559664)(i64.const -8894889478742909895))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const -6252964947024178105)(i64.const -4019098859909296191))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const -2995236107400314374)(i64.const -1821802546385080839))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 5)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $SWAP (i32.const 4)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
)(call $useGas (i64.const 26)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32768))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 5)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $LT) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 427))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 111)) (if (i32.gt_s (get_global $sp) (i32.const 32608)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 160))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MLOAD) | |
(call $SWAP (i32.const 0)) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 3)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 1))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $SWAP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
)(call $useGas (i64.const 26)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 3)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $LT) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 415))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 8)) (if (i32.gt_s (get_global $sp) (i32.const 32704)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $SWAP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
)(call $useGas (i64.const 26)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 5))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $LT) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 403))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 34)) (if (i32.gt_s (get_global $sp) (i32.const 32576)) | |
(then (unreachable)))(call $DUP (i32.const 5)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 5))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $LT) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ISZERO) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 302))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 0)) (unreachable))(call $useGas (i64.const 64)) (if (i32.gt_s (get_global $sp) (i32.const 32672)) | |
(then (unreachable)))(if (i32.lt_s (get_global $sp) (i32.const 32)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MUL) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $MLOAD) | |
(call $SWAP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MUL) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 6)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ISZERO) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 325))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 0)) (unreachable))(call $useGas (i64.const 48)) (if (i32.gt_s (get_global $sp) (i32.const 32608)) | |
(then (unreachable)))(if (i32.lt_s (get_global $sp) (i32.const 32)) | |
(then (unreachable)))(call $MOD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 6)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 3)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 5))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $LT) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ISZERO) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 343))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 0)) (unreachable))(call $useGas (i64.const 92)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(if (i32.lt_s (get_global $sp) (i32.const 64)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MUL) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 255))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $AND) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 0)) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 2))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $EXP) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $MUL) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 4)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 3)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 5))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $LT) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ISZERO) | |
(call $ISZERO) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 376))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 0)) (unreachable))(call $useGas (i64.const 42)) (if (i32.gt_s (get_global $sp) (i32.const 32672)) | |
(then (unreachable)))(if (i32.lt_s (get_global $sp) (i32.const 64)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MUL) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MLOAD) | |
(call $OR) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
)(call $useGas (i64.const 26)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 1))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 279))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 1)) )(call $useGas (i64.const 26)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $DUP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 1))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 2)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 265))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 1)) )(call $useGas (i64.const 26)) (if (i32.gt_s (get_global $sp) (i32.const 32640)) | |
(then (unreachable)))(call $DUP (i32.const 4)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 1))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 4)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 203))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 1)) )(call $useGas (i64.const 26)) (if (i32.lt_s (get_global $sp) (i32.const 192)) | |
(then (unreachable)))(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 480))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 34)) (if (i32.gt_s (get_global $sp) (i32.const 32608)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 160))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MLOAD) | |
(call $SWAP (i32.const 0)) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 64))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 5))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $SWAP (i32.const 0)) | |
)(call $useGas (i64.const 47)) (if (i32.gt_s (get_global $sp) (i32.const 32672)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $MSTORE) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 32))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $ADD) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 0)) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 1))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $SWAP (i32.const 0)) | |
(call $SUB) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 0)) | |
(call $DUP (i32.const 1)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 456))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 64))) | |
(br_if $loop (i32.eqz (i64.eqz (i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 32))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 40))) | |
(i64.or | |
(i64.load (i32.add (get_global $sp) (i32.const 48))) | |
(i64.load (i32.add (get_global $sp) (i32.const 56))) | |
) | |
) | |
)))) | |
(call $useGas (i64.const 18)) (if (i32.lt_s (get_global $sp) (i32.const 32)) | |
(then (unreachable)))(call $SWAP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -32))) | |
(call $SWAP (i32.const 0)) | |
;; jump | |
(set_local $jump_dest (call $check_overflow | |
(i64.load (get_global $sp)) | |
(i64.load (i32.add (get_global $sp) (i32.const 8))) | |
(i64.load (i32.add (get_global $sp) (i32.const 16))) | |
(i64.load (i32.add (get_global $sp) (i32.const 24))))) | |
(set_global $sp (i32.sub (get_global $sp) (i32.const 32))) | |
(br $loop))(call $useGas (i64.const 16)) (if (i32.gt_s (get_global $sp) (i32.const 32608)) | |
(then (unreachable)))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 54))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $DUP (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 494))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $CODECOPY (i32.const 0)) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -96))) | |
(set_global $cb_dest (i32.const 22)) | |
(br $done))(call $PUSH (i64.const 0)(i64.const 0)(i64.const 0)(i64.const 0))(set_global $sp (i32.add (get_global $sp) (i32.const 32))) | |
(call $RETURN) (br $done) | |
(set_global $sp (i32.add (get_global $sp) (i32.const -64))) | |
)(call $useGas (i64.const 7)) (if (i32.gt_s (get_global $sp) (i32.const 32672)) | |
(then (unreachable)))(unreachable)))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment