@@ -43,7 +43,7 @@ object "object" {
4343 x_7 := x_11
4444 }
4545 {
46- let _5, _6, _7, _8 := iszero_169_788 (_1, _1, _1, lt_171 (x_4, x_5, x_6, x_7, _1, _1, _1, 10))
46+ let _5, _6, _7, _8 := iszero_200_924_1535 (_1, _1, _1, lt_202 (x_4, x_5, x_6, x_7, _1, _1, _1, 10))
4747 if i32.eqz(i64.eqz(i64.or(i64.or(_5, _6), i64.or(_7, _8)))) { break }
4848 if i32.eqz(i64.eqz(i64.or(_3, i64.or(_1, eq(x_4, x_5, x_6, x_7, _1, _1, _1, 2))))) { break }
4949 if i32.eqz(i64.eqz(i64.or(_3, i64.or(_1, eq(x_4, x_5, x_6, x_7, _1, _1, _1, 4))))) { continue }
@@ -67,7 +67,7 @@ object "object" {
6767 let r1_1, carry_2 := add_carry(x1, y1, carry_1)
6868 r1 := r1_1
6969 }
70- function iszero_169_788 (x1, x2, x3, x4) -> r1, r2, r3, r4
70+ function iszero_200_924_1535 (x1, x2, x3, x4) -> r1, r2, r3, r4
7171 {
7272 r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(x1, x2), i64.or(x3, x4))))
7373 }
@@ -87,7 +87,7 @@ object "object" {
8787 case 1:i32 { r := 0xffffffff:i32 }
8888 default { r := i64.ne(a, b) }
8989 }
90- function lt_171 (x1, x2, x3, x4, y1, y2, y3, y4) -> z4
90+ function lt_202 (x1, x2, x3, x4, y1, y2, y3, y4) -> z4
9191 {
9292 let z:i32 := false
9393 switch cmp(x1, y1)
@@ -106,6 +106,12 @@ object "object" {
106106 default { z := 1:i32 }
107107 z4 := i64.extend_i32_u(z)
108108 }
109+ function u256_to_i32(x1, x2, x3, x4) -> v:i32
110+ {
111+ if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { unreachable() }
112+ if i64.ne(0, i64.shr_u(x4, 32)) { unreachable() }
113+ v := i32.wrap_i64(x4)
114+ }
109115 function bswap16(x) -> y
110116 {
111117 y := i64.or(i64.and(i64.shl(x, 8), 0xff00), i64.and(i64.shr_u(x, 8), 0xff))
@@ -122,13 +128,36 @@ object "object" {
122128 }
123129 function calldataload(x1, x2, x3, x4) -> z1, z2, z3, z4
124130 {
125- if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { unreachable() }
126- if i64.ne(0, i64.shr_u(x4, 32)) { unreachable() }
127- eth.callDataCopy(0:i32, i32.wrap_i64(x4), 32:i32)
128- let z1_1 := bswap64(i64.load(0:i32))
129- let z2_1 := bswap64(i64.load(i32.add(0:i32, 8:i32)))
130- let z3_1 := bswap64(i64.load(i32.add(0:i32, 16:i32)))
131- let z4_1 := bswap64(i64.load(i32.add(0:i32, 24:i32)))
131+ let cds:i32 := eth.getCallDataSize()
132+ let _1 := 0
133+ let destination:i32 := u256_to_i32(_1, _1, _1, _1)
134+ let offset:i32 := u256_to_i32(x1, x2, x3, x4)
135+ let copy_size:i32 := u256_to_i32(_1, _1, _1, 32)
136+ let copy_size_1:i32 := copy_size
137+ if i32.gt_u(offset, i32.sub(0xffffffff:i32, copy_size)) { eth.revert(0:i32, 0:i32) }
138+ if i32.gt_u(i32.add(copy_size, offset), cds)
139+ {
140+ copy_size := i32.sub(cds, offset)
141+ }
142+ let _2:i32 := 0:i32
143+ if i32.gt_u(copy_size, _2)
144+ {
145+ eth.callDataCopy(destination, offset, copy_size)
146+ }
147+ let _3:i32 := i32.sub(copy_size_1, copy_size)
148+ if i32.gt_u(_3, _2)
149+ {
150+ let _4:i32 := i32.add(destination, copy_size)
151+ let i:i32 := _2
152+ for { } i32.lt_u(i, _3) { i := i32.add(i, 1:i32) }
153+ {
154+ i32.store8(i32.add(_4, i), _2)
155+ }
156+ }
157+ let z1_1 := bswap64(i64.load(_2))
158+ let z2_1 := bswap64(i64.load(i32.add(_2, 8:i32)))
159+ let z3_1 := bswap64(i64.load(i32.add(_2, 16:i32)))
160+ let z4_1 := bswap64(i64.load(i32.add(_2, 24:i32)))
132161 z1 := z1_1
133162 z2 := z2_1
134163 z3 := z3_1
@@ -152,11 +181,13 @@ object "object" {
152181
153182
154183Binary representation:
155- 0061736d0100000001480a60000060017e017e60027e7e017f60037e7e7e017e60047e7e7e7e017e60087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60057f7e7e7e7e0060027f7f0060037f7f7f0002310208657468657265756d0c73746f7261676553746f7265000808657468657265756d0c63616c6c44617461436f70790009030e0d0003060406020601010104070505030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00020af0070da302030b7e017f087e02404200210002402000200020002000100c21012300210223012103230221040b20012105200221062003210720042108420121092000200084210a200a200020098484504545210b02400340200b45450d01024002402000200020002005200620072008200020002000420a10081005210c2300210d2301210e2302210f0b200c200d84200e200f8484504504400c030b200a20002005200620072008200020002000420210068484504504400c030b200a20002005200620072008200020002000420410068484504504400c010b0b024020052006200720082000200020002009100421102300211123012112230221130b201021052011210620122107201321080c000b0b20002000200020002005200620072008100e0b0b2901037e0240200020017c2105200520027c21032005200054200320055472ad21040b2004240020030b6c010b7e0240200320077c210c200c42007c210b024020022006200c200354200b200c5472ad1003210d2300210e0b200d210a024020012005200e1003210f230021100b200f2109024020002004201010032111230021120b201121080b20092400200a2401200b240220080b2401047e0240200020018420022003848450ad21070b20052400200624012007240220040b2d01017e024020002004510440200120055104402002200651044020032007510440420121080b0b0b0b0b20080b2701027f024002402000200154210320034101460440417f210205200020015221020b0b0b20020b8a0102017e047f0240410021090240200020041007210a200a41004604400240200120051007210b200b41004604400240200220061007210c200c41004604402003200754210905200c41014604404100210905410121090b0b0b05200b41014604404100210905410121090b0b0b05200a41014604404100210905410121090b0b0b2009ad21080b20080b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100942108621022002200042108810098421010b20010b1e01027e02402000100a422086210220022000422088100a8421010b20010b7601087e024042002000200184200284520440000b42002003422088520440000b41002003a7412010014100290000100b2108410041086a290000100b2109410041106a290000100b210a410041186a290000100b210b2008210420092105200a2106200b21070b20052400200624012007240220040b3200024020002001100b370000200041086a2002100b370000200041106a2003100b370000200041186a2004100b3700000b0b2300024041002000200120022003100d41202004200520062007100d4100412010000b0b
184+ 0061736d0100000001540c6000006000017f60017e017e60027e7e017f60037e7e7e017e60047e7e7e7e017e60047e7e7e7e017f60087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60057f7e7e7e7e0060027f7f0060037f7f7f00025e0408657468657265756d0c73746f7261676553746f7265000a08657468657265756d06726576657274000a08657468657265756d0f67657443616c6c4461746153697a65000108657468657265756d0c63616c6c44617461436f7079000b030f0e000408050803080602020205090705030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00040aa4090ea302030b7e017f087e02404200210002402000200020002000100f21012300210223012103230221040b20012105200221062003210720042108420121092000200084210a200a200020098484504545210b02400340200b45450d01024002402000200020002005200620072008200020002000420a100a1007210c2300210d2301210e2302210f0b200c200d84200e200f8484504504400c030b200a20002005200620072008200020002000420210088484504504400c030b200a20002005200620072008200020002000420410088484504504400c010b0b024020052006200720082000200020002009100621102300211123012112230221130b201021052011210620122107201321080c000b0b2000200020002000200520062007200810110b0b2901037e0240200020017c2105200520027c21032005200054200320055472ad21040b2004240020030b6c010b7e0240200320077c210c200c42007c210b024020022006200c200354200b200c5472ad1005210d2300210e0b200d210a024020012005200e1005210f230021100b200f2109024020002004201010052111230021120b201121080b20092400200a2401200b240220080b2401047e0240200020018420022003848450ad21070b20052400200624012007240220040b2d01017e024020002004510440200120055104402002200651044020032007510440420121080b0b0b0b0b20080b2701027f024002402000200154210320034101460440417f210205200020015221020b0b0b20020b8a0102017e047f0240410021090240200020041009210a200a41004604400240200120051009210b200b41004604400240200220061009210c200c41004604402003200754210905200c41014604404100210905410121090b0b0b05200b41014604404100210905410121090b0b0b05200a41014604404100210905410121090b0b0b2009ad21080b20080b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100c421086210220022000421088100c8421010b20010b1e01027e02402000100d422086210220022000422088100d8421010b20010bff0105047e017f017e087f047e024010022108420021092009200920092009100b210a2000200120022003100b210b2009200920094220100b210c200c210d200b417f200c6b4b04404100410010010b200c200b6a20084b04402008200b6b210c0b4100210e200c200e4b0440200a200b200c10030b200d200c6b210f200f200e4b0440200a200c6a2110200e2111024003402011200f49450d010240201020116a200e3a00000b201141016a21110c000b0b0b200e290000100e2112200e41086a290000100e2113200e41106a290000100e2114200e41186a290000100e2115201221042013210520142106201521070b20052400200624012007240220040b3200024020002001100e370000200041086a2002100e370000200041106a2003100e370000200041186a2004100e3700000b0b230002404100200020012002200310104120200420052006200710104100412010000b0b
156185
157186Text representation:
158187(module
159188 (import "ethereum" "storageStore" (func $eth.storageStore (param i32 i32)))
189+ (import "ethereum" "revert" (func $eth.revert (param i32 i32)))
190+ (import "ethereum" "getCallDataSize" (func $eth.getCallDataSize (result i32)))
160191 (import "ethereum" "callDataCopy" (func $eth.callDataCopy (param i32 i32 i32)))
161192 (memory $memory (export "memory") 1)
162193 (export "main" (func $main))
@@ -206,7 +237,7 @@ Text representation:
206237 (br_if $label__3 (i32.eqz (i32.eqz (local.get $_4))))
207238 (block $label__4
208239 (block
209- (local.set $_5 (call $iszero_169_788 (local.get $_1) (local.get $_1) (local.get $_1) (call $lt_171 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 10))))
240+ (local.set $_5 (call $iszero_200_924_1535 (local.get $_1) (local.get $_1) (local.get $_1) (call $lt_202 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 10))))
210241 (local.set $_6 (global.get $global_))
211242 (local.set $_7 (global.get $global__1))
212243 (local.set $_8 (global.get $global__2))
@@ -310,7 +341,7 @@ Text representation:
310341 (local.get $r1)
311342)
312343
313- (func $iszero_169_788
344+ (func $iszero_200_924_1535
314345 (param $x1 i64)
315346 (param $x2 i64)
316347 (param $x3 i64)
@@ -377,7 +408,7 @@ Text representation:
377408 (local.get $r)
378409)
379410
380- (func $lt_171
411+ (func $lt_202
381412 (param $x1 i64)
382413 (param $x2 i64)
383414 (param $x3 i64)
@@ -437,11 +468,29 @@ Text representation:
437468 (local.get $z4)
438469)
439470
471+ (func $u256_to_i32
472+ (param $x1 i64)
473+ (param $x2 i64)
474+ (param $x3 i64)
475+ (param $x4 i64)
476+ (result i32)
477+ (local $v i32)
478+ (block $label__15
479+ (if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then
480+ (unreachable)))
481+ (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then
482+ (unreachable)))
483+ (local.set $v (i32.wrap_i64 (local.get $x4)))
484+
485+ )
486+ (local.get $v)
487+ )
488+
440489(func $bswap16
441490 (param $x i64)
442491 (result i64)
443492 (local $y i64)
444- (block $label__15
493+ (block $label__16
445494 (local.set $y (i64.or (i64.and (i64.shl (local.get $x) (i64.const 8)) (i64.const 65280)) (i64.and (i64.shr_u (local.get $x) (i64.const 8)) (i64.const 255))))
446495
447496 )
@@ -453,7 +502,7 @@ Text representation:
453502 (result i64)
454503 (local $y i64)
455504 (local $hi i64)
456- (block $label__16
505+ (block $label__17
457506 (local.set $hi (i64.shl (call $bswap16 (local.get $x)) (i64.const 16)))
458507 (local.set $y (i64.or (local.get $hi) (call $bswap16 (i64.shr_u (local.get $x) (i64.const 16)))))
459508
@@ -466,7 +515,7 @@ Text representation:
466515 (result i64)
467516 (local $y i64)
468517 (local $hi i64)
469- (block $label__17
518+ (block $label__18
470519 (local.set $hi (i64.shl (call $bswap32 (local.get $x)) (i64.const 32)))
471520 (local.set $y (i64.or (local.get $hi) (call $bswap32 (i64.shr_u (local.get $x) (i64.const 32)))))
472521
@@ -484,20 +533,55 @@ Text representation:
484533 (local $z2 i64)
485534 (local $z3 i64)
486535 (local $z4 i64)
536+ (local $cds i32)
537+ (local $_1 i64)
538+ (local $destination i32)
539+ (local $offset i32)
540+ (local $copy_size i32)
541+ (local $copy_size_1 i32)
542+ (local $_2 i32)
543+ (local $_3 i32)
544+ (local $_4 i32)
545+ (local $i i32)
487546 (local $z1_1 i64)
488547 (local $z2_1 i64)
489548 (local $z3_1 i64)
490549 (local $z4_1 i64)
491- (block $label__18
492- (if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then
493- (unreachable)))
494- (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then
495- (unreachable)))
496- (call $eth.callDataCopy (i32.const 0) (i32.wrap_i64 (local.get $x4)) (i32.const 32))
497- (local.set $z1_1 (call $bswap64 (i64.load (i32.const 0))))
498- (local.set $z2_1 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8)))))
499- (local.set $z3_1 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16)))))
500- (local.set $z4_1 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24)))))
550+ (block $label__19
551+ (local.set $cds (call $eth.getCallDataSize))
552+ (local.set $_1 (i64.const 0))
553+ (local.set $destination (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)))
554+ (local.set $offset (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)))
555+ (local.set $copy_size (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 32)))
556+ (local.set $copy_size_1 (local.get $copy_size))
557+ (if (i32.gt_u (local.get $offset) (i32.sub (i32.const 4294967295) (local.get $copy_size))) (then
558+ (call $eth.revert (i32.const 0) (i32.const 0))))
559+ (if (i32.gt_u (i32.add (local.get $copy_size) (local.get $offset)) (local.get $cds)) (then
560+ (local.set $copy_size (i32.sub (local.get $cds) (local.get $offset)))
561+ ))
562+ (local.set $_2 (i32.const 0))
563+ (if (i32.gt_u (local.get $copy_size) (local.get $_2)) (then
564+ (call $eth.callDataCopy (local.get $destination) (local.get $offset) (local.get $copy_size))))
565+ (local.set $_3 (i32.sub (local.get $copy_size_1) (local.get $copy_size)))
566+ (if (i32.gt_u (local.get $_3) (local.get $_2)) (then
567+ (local.set $_4 (i32.add (local.get $destination) (local.get $copy_size)))
568+ (local.set $i (local.get $_2))
569+ (block $label__20
570+ (loop $label__22
571+ (br_if $label__20 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3))))
572+ (block $label__21
573+ (i32.store8 (i32.add (local.get $_4) (local.get $i)) (local.get $_2))
574+ )
575+ (local.set $i (i32.add (local.get $i) (i32.const 1)))
576+ (br $label__22)
577+ )
578+
579+ )
580+ ))
581+ (local.set $z1_1 (call $bswap64 (i64.load (local.get $_2))))
582+ (local.set $z2_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 8)))))
583+ (local.set $z3_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 16)))))
584+ (local.set $z4_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 24)))))
501585 (local.set $z1 (local.get $z1_1))
502586 (local.set $z2 (local.get $z2_1))
503587 (local.set $z3 (local.get $z3_1))
@@ -516,7 +600,7 @@ Text representation:
516600 (param $y2 i64)
517601 (param $y3 i64)
518602 (param $y4 i64)
519- (block $label__19
603+ (block $label__23
520604 (i64.store (local.get $pos) (call $bswap64 (local.get $y1)))
521605 (i64.store (i32.add (local.get $pos) (i32.const 8)) (call $bswap64 (local.get $y2)))
522606 (i64.store (i32.add (local.get $pos) (i32.const 16)) (call $bswap64 (local.get $y3)))
@@ -533,7 +617,7 @@ Text representation:
533617 (param $y2 i64)
534618 (param $y3 i64)
535619 (param $y4 i64)
536- (block $label__20
620+ (block $label__24
537621 (call $mstore_internal (i32.const 0) (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))
538622 (call $mstore_internal (i32.const 32) (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4))
539623 (call $eth.storageStore (i32.const 0) (i32.const 32))
0 commit comments