diff --git a/sdk/base-sys/src/bindings/native_account.rs b/sdk/base-sys/src/bindings/native_account.rs index 83bc39419..c0a6084fe 100644 --- a/sdk/base-sys/src/bindings/native_account.rs +++ b/sdk/base-sys/src/bindings/native_account.rs @@ -72,7 +72,7 @@ pub fn add_asset(asset: Asset) -> Asset { asset.inner[0], ret_area.as_mut_ptr(), ); - ret_area.assume_init() + ret_area.assume_init().reverse() } } diff --git a/tests/integration/expected/examples/basic_wallet.hir b/tests/integration/expected/examples/basic_wallet.hir index 5c9789f2e..fc7d7989d 100644 --- a/tests/integration/expected/examples/basic_wallet.hir +++ b/tests/integration/expected/examples/basic_wallet.hir @@ -32,33 +32,33 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { v20 = arith.constant 8 : u32; v19 = hir.bitcast v10 : u32; v21 = arith.add v19, v20 : u32 #[overflow = checked]; - v376 = arith.constant 4 : u32; - v23 = arith.mod v21, v376 : u32; + v414 = arith.constant 4 : u32; + v23 = arith.mod v21, v414 : u32; hir.assertz v23 #[code = 250]; v24 = hir.int_to_ptr v21 : ptr; hir.store v24, v2; - v375 = arith.constant 4 : u32; + v413 = arith.constant 4 : u32; v25 = hir.bitcast v10 : u32; - v27 = arith.add v25, v375 : u32 #[overflow = checked]; - v374 = arith.constant 4 : u32; - v29 = arith.mod v27, v374 : u32; + v27 = arith.add v25, v413 : u32 #[overflow = checked]; + v412 = arith.constant 4 : u32; + v29 = arith.mod v27, v412 : u32; hir.assertz v29 #[code = 250]; v30 = hir.int_to_ptr v27 : ptr; hir.store v30, v1; v31 = hir.bitcast v10 : u32; - v373 = arith.constant 4 : u32; - v33 = arith.mod v31, v373 : u32; + v411 = arith.constant 4 : u32; + v33 = arith.mod v31, v411 : u32; hir.assertz v33 #[code = 250]; v34 = hir.int_to_ptr v31 : ptr; hir.store v34, v0; v35 = arith.constant 16 : i32; v36 = arith.add v10, v35 : i32 #[overflow = wrapping]; hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden_base_sys::bindings::native_account::remove_asset(v36, v10) - v372 = arith.constant 16 : i32; - v38 = arith.add v10, v372 : i32 #[overflow = wrapping]; + v410 = arith.constant 16 : i32; + v38 = arith.add v10, v410 : i32 #[overflow = wrapping]; hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden_base_sys::bindings::output_note::add_asset(v38, v4) - v371 = arith.constant 32 : i32; - v40 = arith.add v10, v371 : i32 #[overflow = wrapping]; + v409 = arith.constant 32 : i32; + v40 = arith.add v10, v409 : i32 #[overflow = wrapping]; v41 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr v42 = hir.bitcast v41 : ptr; hir.store v42, v40; @@ -87,30 +87,30 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { v62 = arith.constant 8 : u32; v61 = hir.bitcast v52 : u32; v63 = arith.add v61, v62 : u32 #[overflow = checked]; - v381 = arith.constant 4 : u32; - v65 = arith.mod v63, v381 : u32; + v419 = arith.constant 4 : u32; + v65 = arith.mod v63, v419 : u32; hir.assertz v65 #[code = 250]; v66 = hir.int_to_ptr v63 : ptr; hir.store v66, v45; - v380 = arith.constant 4 : u32; + v418 = arith.constant 4 : u32; v67 = hir.bitcast v52 : u32; - v69 = arith.add v67, v380 : u32 #[overflow = checked]; - v379 = arith.constant 4 : u32; - v71 = arith.mod v69, v379 : u32; + v69 = arith.add v67, v418 : u32 #[overflow = checked]; + v417 = arith.constant 4 : u32; + v71 = arith.mod v69, v417 : u32; hir.assertz v71 #[code = 250]; v72 = hir.int_to_ptr v69 : ptr; hir.store v72, v44; v73 = hir.bitcast v52 : u32; - v378 = arith.constant 4 : u32; - v75 = arith.mod v73, v378 : u32; + v416 = arith.constant 4 : u32; + v75 = arith.mod v73, v416 : u32; hir.assertz v75 #[code = 250]; v76 = hir.int_to_ptr v73 : ptr; hir.store v76, v43; v77 = arith.constant 16 : i32; v78 = arith.add v52, v77 : i32 #[overflow = wrapping]; hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden_base_sys::bindings::native_account::add_asset(v78, v52) - v377 = arith.constant 32 : i32; - v80 = arith.add v52, v377 : i32 #[overflow = wrapping]; + v415 = arith.constant 32 : i32; + v80 = arith.add v52, v415 : i32 #[overflow = wrapping]; v81 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr v82 = hir.bitcast v81 : ptr; hir.store v82, v80; @@ -140,12 +140,12 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { v97 = hir.bitcast v96 : ptr; v98 = hir.load v97 : i32; hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__wasm_call_ctors() - v383 = arith.constant 1 : u8; - v385 = arith.constant 1048584 : i32; - v100 = arith.add v98, v385 : i32 #[overflow = wrapping]; + v421 = arith.constant 1 : u8; + v423 = arith.constant 1048584 : i32; + v100 = arith.add v98, v423 : i32 #[overflow = wrapping]; v104 = hir.bitcast v100 : u32; v105 = hir.int_to_ptr v104 : ptr; - hir.store v105, v383; + hir.store v105, v421; scf.yield ; }; builtin.ret ; @@ -164,22 +164,22 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { v116 = arith.constant 8 : u32; v115 = hir.bitcast v106 : u32; v117 = arith.add v115, v116 : u32 #[overflow = checked]; - v389 = arith.constant 4 : u32; - v119 = arith.mod v117, v389 : u32; + v427 = arith.constant 4 : u32; + v119 = arith.mod v117, v427 : u32; hir.assertz v119 #[code = 250]; v120 = hir.int_to_ptr v117 : ptr; v121 = hir.load v120 : felt; - v388 = arith.constant 4 : u32; + v426 = arith.constant 4 : u32; v122 = hir.bitcast v106 : u32; - v124 = arith.add v122, v388 : u32 #[overflow = checked]; - v387 = arith.constant 4 : u32; - v126 = arith.mod v124, v387 : u32; + v124 = arith.add v122, v426 : u32 #[overflow = checked]; + v425 = arith.constant 4 : u32; + v126 = arith.mod v124, v425 : u32; hir.assertz v126 #[code = 250]; v127 = hir.int_to_ptr v124 : ptr; v128 = hir.load v127 : felt; v129 = hir.bitcast v106 : u32; - v386 = arith.constant 4 : u32; - v131 = arith.mod v129, v386 : u32; + v424 = arith.constant 4 : u32; + v131 = arith.mod v129, v424 : u32; hir.assertz v131 #[code = 250]; v132 = hir.int_to_ptr v129 : ptr; v133 = hir.load v132 : felt; @@ -208,61 +208,61 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { v152 = arith.constant 8 : u32; v151 = hir.bitcast v135 : u32; v153 = arith.add v151, v152 : u32 #[overflow = checked]; - v399 = arith.constant 4 : u32; - v155 = arith.mod v153, v399 : u32; + v437 = arith.constant 4 : u32; + v155 = arith.mod v153, v437 : u32; hir.assertz v155 #[code = 250]; v156 = hir.int_to_ptr v153 : ptr; v157 = hir.load v156 : felt; - v398 = arith.constant 4 : u32; + v436 = arith.constant 4 : u32; v158 = hir.bitcast v135 : u32; - v160 = arith.add v158, v398 : u32 #[overflow = checked]; - v397 = arith.constant 4 : u32; - v162 = arith.mod v160, v397 : u32; + v160 = arith.add v158, v436 : u32 #[overflow = checked]; + v435 = arith.constant 4 : u32; + v162 = arith.mod v160, v435 : u32; hir.assertz v162 #[code = 250]; v163 = hir.int_to_ptr v160 : ptr; v164 = hir.load v163 : felt; v165 = hir.bitcast v135 : u32; - v396 = arith.constant 4 : u32; - v167 = arith.mod v165, v396 : u32; + v434 = arith.constant 4 : u32; + v167 = arith.mod v165, v434 : u32; hir.assertz v167 #[code = 250]; v168 = hir.int_to_ptr v165 : ptr; v169 = hir.load v168 : felt; hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden::native_account::remove_asset(v150, v157, v164, v169, v141) - v395 = arith.constant 8 : u32; + v433 = arith.constant 8 : u32; v170 = hir.bitcast v141 : u32; - v172 = arith.add v170, v395 : u32 #[overflow = checked]; - v394 = arith.constant 8 : u32; - v174 = arith.mod v172, v394 : u32; + v172 = arith.add v170, v433 : u32 #[overflow = checked]; + v432 = arith.constant 8 : u32; + v174 = arith.mod v172, v432 : u32; hir.assertz v174 #[code = 250]; v175 = hir.int_to_ptr v172 : ptr; v176 = hir.load v175 : i64; v178 = arith.constant 24 : u32; v177 = hir.bitcast v141 : u32; v179 = arith.add v177, v178 : u32 #[overflow = checked]; - v393 = arith.constant 8 : u32; - v181 = arith.mod v179, v393 : u32; + v431 = arith.constant 8 : u32; + v181 = arith.mod v179, v431 : u32; hir.assertz v181 #[code = 250]; v182 = hir.int_to_ptr v179 : ptr; hir.store v182, v176; v183 = hir.bitcast v141 : u32; - v392 = arith.constant 8 : u32; - v185 = arith.mod v183, v392 : u32; + v430 = arith.constant 8 : u32; + v185 = arith.mod v183, v430 : u32; hir.assertz v185 #[code = 250]; v186 = hir.int_to_ptr v183 : ptr; v187 = hir.load v186 : i64; v189 = arith.constant 16 : u32; v188 = hir.bitcast v141 : u32; v190 = arith.add v188, v189 : u32 #[overflow = checked]; - v391 = arith.constant 8 : u32; - v192 = arith.mod v190, v391 : u32; + v429 = arith.constant 8 : u32; + v192 = arith.mod v190, v429 : u32; hir.assertz v192 #[code = 250]; v193 = hir.int_to_ptr v190 : ptr; hir.store v193, v187; v194 = arith.constant 16 : i32; v195 = arith.add v141, v194 : i32 #[overflow = wrapping]; hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/::reverse(v134, v195) - v390 = arith.constant 32 : i32; - v197 = arith.add v141, v390 : i32 #[overflow = wrapping]; + v428 = arith.constant 32 : i32; + v197 = arith.add v141, v428 : i32 #[overflow = wrapping]; v198 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr v199 = hir.bitcast v198 : ptr; hir.store v199, v197; @@ -271,212 +271,258 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { private builtin.function @miden_base_sys::bindings::native_account::add_asset(v200: i32, v201: i32) { ^block21(v200: i32, v201: i32): - v203 = arith.constant 12 : u32; - v202 = hir.bitcast v201 : u32; - v204 = arith.add v202, v203 : u32 #[overflow = checked]; - v205 = arith.constant 4 : u32; - v206 = arith.mod v204, v205 : u32; - hir.assertz v206 #[code = 250]; - v207 = hir.int_to_ptr v204 : ptr; - v208 = hir.load v207 : felt; - v210 = arith.constant 8 : u32; - v209 = hir.bitcast v201 : u32; - v211 = arith.add v209, v210 : u32 #[overflow = checked]; - v403 = arith.constant 4 : u32; - v213 = arith.mod v211, v403 : u32; - hir.assertz v213 #[code = 250]; - v214 = hir.int_to_ptr v211 : ptr; - v215 = hir.load v214 : felt; - v402 = arith.constant 4 : u32; - v216 = hir.bitcast v201 : u32; - v218 = arith.add v216, v402 : u32 #[overflow = checked]; - v401 = arith.constant 4 : u32; - v220 = arith.mod v218, v401 : u32; - hir.assertz v220 #[code = 250]; - v221 = hir.int_to_ptr v218 : ptr; - v222 = hir.load v221 : felt; - v223 = hir.bitcast v201 : u32; - v400 = arith.constant 4 : u32; - v225 = arith.mod v223, v400 : u32; - hir.assertz v225 #[code = 250]; - v226 = hir.int_to_ptr v223 : ptr; - v227 = hir.load v226 : felt; - hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden::native_account::add_asset(v208, v215, v222, v227, v200) + v203 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr + v204 = hir.bitcast v203 : ptr; + v205 = hir.load v204 : i32; + v206 = arith.constant 32 : i32; + v207 = arith.sub v205, v206 : i32 #[overflow = wrapping]; + v208 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr + v209 = hir.bitcast v208 : ptr; + hir.store v209, v207; + v211 = arith.constant 12 : u32; + v210 = hir.bitcast v201 : u32; + v212 = arith.add v210, v211 : u32 #[overflow = checked]; + v213 = arith.constant 4 : u32; + v214 = arith.mod v212, v213 : u32; + hir.assertz v214 #[code = 250]; + v215 = hir.int_to_ptr v212 : ptr; + v216 = hir.load v215 : felt; + v218 = arith.constant 8 : u32; + v217 = hir.bitcast v201 : u32; + v219 = arith.add v217, v218 : u32 #[overflow = checked]; + v447 = arith.constant 4 : u32; + v221 = arith.mod v219, v447 : u32; + hir.assertz v221 #[code = 250]; + v222 = hir.int_to_ptr v219 : ptr; + v223 = hir.load v222 : felt; + v446 = arith.constant 4 : u32; + v224 = hir.bitcast v201 : u32; + v226 = arith.add v224, v446 : u32 #[overflow = checked]; + v445 = arith.constant 4 : u32; + v228 = arith.mod v226, v445 : u32; + hir.assertz v228 #[code = 250]; + v229 = hir.int_to_ptr v226 : ptr; + v230 = hir.load v229 : felt; + v231 = hir.bitcast v201 : u32; + v444 = arith.constant 4 : u32; + v233 = arith.mod v231, v444 : u32; + hir.assertz v233 #[code = 250]; + v234 = hir.int_to_ptr v231 : ptr; + v235 = hir.load v234 : felt; + hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden::native_account::add_asset(v216, v223, v230, v235, v207) + v443 = arith.constant 8 : u32; + v236 = hir.bitcast v207 : u32; + v238 = arith.add v236, v443 : u32 #[overflow = checked]; + v442 = arith.constant 8 : u32; + v240 = arith.mod v238, v442 : u32; + hir.assertz v240 #[code = 250]; + v241 = hir.int_to_ptr v238 : ptr; + v242 = hir.load v241 : i64; + v244 = arith.constant 24 : u32; + v243 = hir.bitcast v207 : u32; + v245 = arith.add v243, v244 : u32 #[overflow = checked]; + v441 = arith.constant 8 : u32; + v247 = arith.mod v245, v441 : u32; + hir.assertz v247 #[code = 250]; + v248 = hir.int_to_ptr v245 : ptr; + hir.store v248, v242; + v249 = hir.bitcast v207 : u32; + v440 = arith.constant 8 : u32; + v251 = arith.mod v249, v440 : u32; + hir.assertz v251 #[code = 250]; + v252 = hir.int_to_ptr v249 : ptr; + v253 = hir.load v252 : i64; + v255 = arith.constant 16 : u32; + v254 = hir.bitcast v207 : u32; + v256 = arith.add v254, v255 : u32 #[overflow = checked]; + v439 = arith.constant 8 : u32; + v258 = arith.mod v256, v439 : u32; + hir.assertz v258 #[code = 250]; + v259 = hir.int_to_ptr v256 : ptr; + hir.store v259, v253; + v260 = arith.constant 16 : i32; + v261 = arith.add v207, v260 : i32 #[overflow = wrapping]; + hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/::reverse(v200, v261) + v438 = arith.constant 32 : i32; + v263 = arith.add v207, v438 : i32 #[overflow = wrapping]; + v264 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr + v265 = hir.bitcast v264 : ptr; + hir.store v265, v263; builtin.ret ; }; - private builtin.function @::reverse(v228: i32, v229: i32) { - ^block23(v228: i32, v229: i32): - v232 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr - v233 = hir.bitcast v232 : ptr; - v234 = hir.load v233 : i32; - v235 = arith.constant 16 : i32; - v236 = arith.sub v234, v235 : i32 #[overflow = wrapping]; - v238 = arith.constant 8 : u32; - v237 = hir.bitcast v229 : u32; - v239 = arith.add v237, v238 : u32 #[overflow = checked]; - v490 = arith.constant 8 : u32; - v241 = arith.mod v239, v490 : u32; - hir.assertz v241 #[code = 250]; - v242 = hir.int_to_ptr v239 : ptr; - v243 = hir.load v242 : i64; - v489 = arith.constant 8 : u32; - v244 = hir.bitcast v236 : u32; - v246 = arith.add v244, v489 : u32 #[overflow = checked]; - v247 = arith.constant 4 : u32; - v248 = arith.mod v246, v247 : u32; - hir.assertz v248 #[code = 250]; - v249 = hir.int_to_ptr v246 : ptr; - hir.store v249, v243; - v250 = hir.bitcast v229 : u32; - v488 = arith.constant 8 : u32; - v252 = arith.mod v250, v488 : u32; - hir.assertz v252 #[code = 250]; - v253 = hir.int_to_ptr v250 : ptr; - v254 = hir.load v253 : i64; - v255 = hir.bitcast v236 : u32; - v487 = arith.constant 4 : u32; - v257 = arith.mod v255, v487 : u32; - hir.assertz v257 #[code = 250]; - v258 = hir.int_to_ptr v255 : ptr; - hir.store v258, v254; - v259 = arith.constant 12 : i32; - v260 = arith.add v236, v259 : i32 #[overflow = wrapping]; - v230 = arith.constant 0 : i32; - v458, v459, v460, v461, v462, v463 = scf.while v230, v236, v260, v228 : i32, i32, i32, i32, i32, i32 { - ^block50(v464: i32, v465: i32, v466: i32, v467: i32): - v486 = arith.constant 0 : i32; - v263 = arith.constant 8 : i32; - v264 = arith.eq v464, v263 : i1; - v265 = arith.zext v264 : u32; - v266 = hir.bitcast v265 : i32; - v268 = arith.neq v266, v486 : i1; - v452, v453 = scf.if v268 : i32, i32 { + private builtin.function @::reverse(v266: i32, v267: i32) { + ^block23(v266: i32, v267: i32): + v270 = builtin.global_symbol @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/__stack_pointer : ptr + v271 = hir.bitcast v270 : ptr; + v272 = hir.load v271 : i32; + v273 = arith.constant 16 : i32; + v274 = arith.sub v272, v273 : i32 #[overflow = wrapping]; + v276 = arith.constant 8 : u32; + v275 = hir.bitcast v267 : u32; + v277 = arith.add v275, v276 : u32 #[overflow = checked]; + v534 = arith.constant 8 : u32; + v279 = arith.mod v277, v534 : u32; + hir.assertz v279 #[code = 250]; + v280 = hir.int_to_ptr v277 : ptr; + v281 = hir.load v280 : i64; + v533 = arith.constant 8 : u32; + v282 = hir.bitcast v274 : u32; + v284 = arith.add v282, v533 : u32 #[overflow = checked]; + v285 = arith.constant 4 : u32; + v286 = arith.mod v284, v285 : u32; + hir.assertz v286 #[code = 250]; + v287 = hir.int_to_ptr v284 : ptr; + hir.store v287, v281; + v288 = hir.bitcast v267 : u32; + v532 = arith.constant 8 : u32; + v290 = arith.mod v288, v532 : u32; + hir.assertz v290 #[code = 250]; + v291 = hir.int_to_ptr v288 : ptr; + v292 = hir.load v291 : i64; + v293 = hir.bitcast v274 : u32; + v531 = arith.constant 4 : u32; + v295 = arith.mod v293, v531 : u32; + hir.assertz v295 #[code = 250]; + v296 = hir.int_to_ptr v293 : ptr; + hir.store v296, v292; + v297 = arith.constant 12 : i32; + v298 = arith.add v274, v297 : i32 #[overflow = wrapping]; + v268 = arith.constant 0 : i32; + v502, v503, v504, v505, v506, v507 = scf.while v268, v274, v298, v266 : i32, i32, i32, i32, i32, i32 { + ^block50(v508: i32, v509: i32, v510: i32, v511: i32): + v530 = arith.constant 0 : i32; + v301 = arith.constant 8 : i32; + v302 = arith.eq v508, v301 : i1; + v303 = arith.zext v302 : u32; + v304 = hir.bitcast v303 : i32; + v306 = arith.neq v304, v530 : i1; + v496, v497 = scf.if v306 : i32, i32 { ^block49: - v412 = ub.poison i32 : i32; - scf.yield v412, v412; + v456 = ub.poison i32 : i32; + scf.yield v456, v456; } else { ^block28: - v270 = arith.add v465, v464 : i32 #[overflow = wrapping]; - v271 = hir.bitcast v270 : u32; - v485 = arith.constant 4 : u32; - v273 = arith.mod v271, v485 : u32; - hir.assertz v273 #[code = 250]; - v274 = hir.int_to_ptr v271 : ptr; - v275 = hir.load v274 : felt; - v277 = hir.bitcast v466 : u32; - v484 = arith.constant 4 : u32; - v279 = arith.mod v277, v484 : u32; - hir.assertz v279 #[code = 250]; - v280 = hir.int_to_ptr v277 : ptr; - v281 = hir.load v280 : i32; - v282 = hir.bitcast v270 : u32; - v483 = arith.constant 4 : u32; - v284 = arith.mod v282, v483 : u32; - hir.assertz v284 #[code = 250]; - v285 = hir.int_to_ptr v282 : ptr; - hir.store v285, v281; - v286 = hir.bitcast v466 : u32; - v482 = arith.constant 4 : u32; - v288 = arith.mod v286, v482 : u32; - hir.assertz v288 #[code = 250]; - v289 = hir.int_to_ptr v286 : ptr; - hir.store v289, v275; - v292 = arith.constant -4 : i32; - v293 = arith.add v466, v292 : i32 #[overflow = wrapping]; - v290 = arith.constant 4 : i32; - v291 = arith.add v464, v290 : i32 #[overflow = wrapping]; - scf.yield v291, v293; + v308 = arith.add v509, v508 : i32 #[overflow = wrapping]; + v309 = hir.bitcast v308 : u32; + v529 = arith.constant 4 : u32; + v311 = arith.mod v309, v529 : u32; + hir.assertz v311 #[code = 250]; + v312 = hir.int_to_ptr v309 : ptr; + v313 = hir.load v312 : felt; + v315 = hir.bitcast v510 : u32; + v528 = arith.constant 4 : u32; + v317 = arith.mod v315, v528 : u32; + hir.assertz v317 #[code = 250]; + v318 = hir.int_to_ptr v315 : ptr; + v319 = hir.load v318 : i32; + v320 = hir.bitcast v308 : u32; + v527 = arith.constant 4 : u32; + v322 = arith.mod v320, v527 : u32; + hir.assertz v322 #[code = 250]; + v323 = hir.int_to_ptr v320 : ptr; + hir.store v323, v319; + v324 = hir.bitcast v510 : u32; + v526 = arith.constant 4 : u32; + v326 = arith.mod v324, v526 : u32; + hir.assertz v326 #[code = 250]; + v327 = hir.int_to_ptr v324 : ptr; + hir.store v327, v313; + v330 = arith.constant -4 : i32; + v331 = arith.add v510, v330 : i32 #[overflow = wrapping]; + v328 = arith.constant 4 : i32; + v329 = arith.add v508, v328 : i32 #[overflow = wrapping]; + scf.yield v329, v331; }; - v480 = ub.poison i32 : i32; - v455 = cf.select v268, v480, v467 : i32; - v481 = ub.poison i32 : i32; - v454 = cf.select v268, v481, v465 : i32; - v411 = arith.constant 1 : u32; - v404 = arith.constant 0 : u32; - v457 = cf.select v268, v404, v411 : u32; - v445 = arith.trunc v457 : i1; - scf.condition v445, v452, v454, v453, v455, v465, v467; + v524 = ub.poison i32 : i32; + v499 = cf.select v306, v524, v511 : i32; + v525 = ub.poison i32 : i32; + v498 = cf.select v306, v525, v509 : i32; + v455 = arith.constant 1 : u32; + v448 = arith.constant 0 : u32; + v501 = cf.select v306, v448, v455 : u32; + v489 = arith.trunc v501 : i1; + scf.condition v489, v496, v498, v497, v499, v509, v511; } do { - ^block51(v468: i32, v469: i32, v470: i32, v471: i32, v472: i32, v473: i32): - scf.yield v468, v469, v470, v471; + ^block51(v512: i32, v513: i32, v514: i32, v515: i32, v516: i32, v517: i32): + scf.yield v512, v513, v514, v515; }; - v479 = arith.constant 8 : u32; - v295 = hir.bitcast v462 : u32; - v297 = arith.add v295, v479 : u32 #[overflow = checked]; - v478 = arith.constant 4 : u32; - v299 = arith.mod v297, v478 : u32; - hir.assertz v299 #[code = 250]; - v300 = hir.int_to_ptr v297 : ptr; - v301 = hir.load v300 : i64; - v477 = arith.constant 8 : u32; - v302 = hir.bitcast v463 : u32; - v304 = arith.add v302, v477 : u32 #[overflow = checked]; - v476 = arith.constant 8 : u32; - v306 = arith.mod v304, v476 : u32; - hir.assertz v306 #[code = 250]; - v307 = hir.int_to_ptr v304 : ptr; - hir.store v307, v301; - v308 = hir.bitcast v462 : u32; - v475 = arith.constant 4 : u32; - v310 = arith.mod v308, v475 : u32; - hir.assertz v310 #[code = 250]; - v311 = hir.int_to_ptr v308 : ptr; - v312 = hir.load v311 : i64; - v313 = hir.bitcast v463 : u32; - v474 = arith.constant 8 : u32; - v315 = arith.mod v313, v474 : u32; - hir.assertz v315 #[code = 250]; - v316 = hir.int_to_ptr v313 : ptr; - hir.store v316, v312; + v523 = arith.constant 8 : u32; + v333 = hir.bitcast v506 : u32; + v335 = arith.add v333, v523 : u32 #[overflow = checked]; + v522 = arith.constant 4 : u32; + v337 = arith.mod v335, v522 : u32; + hir.assertz v337 #[code = 250]; + v338 = hir.int_to_ptr v335 : ptr; + v339 = hir.load v338 : i64; + v521 = arith.constant 8 : u32; + v340 = hir.bitcast v507 : u32; + v342 = arith.add v340, v521 : u32 #[overflow = checked]; + v520 = arith.constant 8 : u32; + v344 = arith.mod v342, v520 : u32; + hir.assertz v344 #[code = 250]; + v345 = hir.int_to_ptr v342 : ptr; + hir.store v345, v339; + v346 = hir.bitcast v506 : u32; + v519 = arith.constant 4 : u32; + v348 = arith.mod v346, v519 : u32; + hir.assertz v348 #[code = 250]; + v349 = hir.int_to_ptr v346 : ptr; + v350 = hir.load v349 : i64; + v351 = hir.bitcast v507 : u32; + v518 = arith.constant 8 : u32; + v353 = arith.mod v351, v518 : u32; + hir.assertz v353 #[code = 250]; + v354 = hir.int_to_ptr v351 : ptr; + hir.store v354, v350; builtin.ret ; }; - private builtin.function @miden::native_account::add_asset(v317: felt, v318: felt, v319: felt, v320: felt, v321: i32) { - ^block29(v317: felt, v318: felt, v319: felt, v320: felt, v321: i32): - v322, v323, v324, v325 = hir.exec @miden/native_account/add_asset(v317, v318, v319, v320) : felt, felt, felt, felt - v326 = hir.bitcast v321 : u32; - v327 = hir.int_to_ptr v326 : ptr; - hir.store v327, v322; - v328 = arith.constant 4 : u32; - v329 = arith.add v326, v328 : u32 #[overflow = checked]; - v330 = hir.int_to_ptr v329 : ptr; - hir.store v330, v323; - v331 = arith.constant 8 : u32; - v332 = arith.add v326, v331 : u32 #[overflow = checked]; - v333 = hir.int_to_ptr v332 : ptr; - hir.store v333, v324; - v334 = arith.constant 12 : u32; - v335 = arith.add v326, v334 : u32 #[overflow = checked]; - v336 = hir.int_to_ptr v335 : ptr; - hir.store v336, v325; + private builtin.function @miden::native_account::add_asset(v355: felt, v356: felt, v357: felt, v358: felt, v359: i32) { + ^block29(v355: felt, v356: felt, v357: felt, v358: felt, v359: i32): + v360, v361, v362, v363 = hir.exec @miden/native_account/add_asset(v355, v356, v357, v358) : felt, felt, felt, felt + v364 = hir.bitcast v359 : u32; + v365 = hir.int_to_ptr v364 : ptr; + hir.store v365, v360; + v366 = arith.constant 4 : u32; + v367 = arith.add v364, v366 : u32 #[overflow = checked]; + v368 = hir.int_to_ptr v367 : ptr; + hir.store v368, v361; + v369 = arith.constant 8 : u32; + v370 = arith.add v364, v369 : u32 #[overflow = checked]; + v371 = hir.int_to_ptr v370 : ptr; + hir.store v371, v362; + v372 = arith.constant 12 : u32; + v373 = arith.add v364, v372 : u32 #[overflow = checked]; + v374 = hir.int_to_ptr v373 : ptr; + hir.store v374, v363; builtin.ret ; }; - private builtin.function @miden::native_account::remove_asset(v337: felt, v338: felt, v339: felt, v340: felt, v341: i32) { - ^block33(v337: felt, v338: felt, v339: felt, v340: felt, v341: i32): - v342, v343, v344, v345 = hir.exec @miden/native_account/remove_asset(v337, v338, v339, v340) : felt, felt, felt, felt - v346 = hir.bitcast v341 : u32; - v347 = hir.int_to_ptr v346 : ptr; - hir.store v347, v342; - v348 = arith.constant 4 : u32; - v349 = arith.add v346, v348 : u32 #[overflow = checked]; - v350 = hir.int_to_ptr v349 : ptr; - hir.store v350, v343; - v351 = arith.constant 8 : u32; - v352 = arith.add v346, v351 : u32 #[overflow = checked]; - v353 = hir.int_to_ptr v352 : ptr; - hir.store v353, v344; - v354 = arith.constant 12 : u32; - v355 = arith.add v346, v354 : u32 #[overflow = checked]; - v356 = hir.int_to_ptr v355 : ptr; - hir.store v356, v345; + private builtin.function @miden::native_account::remove_asset(v375: felt, v376: felt, v377: felt, v378: felt, v379: i32) { + ^block33(v375: felt, v376: felt, v377: felt, v378: felt, v379: i32): + v380, v381, v382, v383 = hir.exec @miden/native_account/remove_asset(v375, v376, v377, v378) : felt, felt, felt, felt + v384 = hir.bitcast v379 : u32; + v385 = hir.int_to_ptr v384 : ptr; + hir.store v385, v380; + v386 = arith.constant 4 : u32; + v387 = arith.add v384, v386 : u32 #[overflow = checked]; + v388 = hir.int_to_ptr v387 : ptr; + hir.store v388, v381; + v389 = arith.constant 8 : u32; + v390 = arith.add v384, v389 : u32 #[overflow = checked]; + v391 = hir.int_to_ptr v390 : ptr; + hir.store v391, v382; + v392 = arith.constant 12 : u32; + v393 = arith.add v384, v392 : u32 #[overflow = checked]; + v394 = hir.int_to_ptr v393 : ptr; + hir.store v394, v383; builtin.ret ; }; - private builtin.function @miden::output_note::add_asset(v357: felt, v358: felt, v359: felt, v360: felt, v361: felt) { - ^block35(v357: felt, v358: felt, v359: felt, v360: felt, v361: felt): - hir.exec @miden/output_note/add_asset(v357, v358, v359, v360, v361) + private builtin.function @miden::output_note::add_asset(v395: felt, v396: felt, v397: felt, v398: felt, v399: felt) { + ^block35(v395: felt, v396: felt, v397: felt, v398: felt, v399: felt): + hir.exec @miden/output_note/add_asset(v395, v396, v397, v398, v399) builtin.ret ; }; @@ -491,15 +537,15 @@ builtin.component miden:basic-wallet/basic-wallet@0.1.0 { builtin.segment @1048576 = 0x0000000100000001; }; - public builtin.function @receive-asset(v362: felt, v363: felt, v364: felt, v365: felt) { - ^block38(v362: felt, v363: felt, v364: felt, v365: felt): - hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden:basic-wallet/basic-wallet@0.1.0#receive-asset(v362, v363, v364, v365) + public builtin.function @receive-asset(v400: felt, v401: felt, v402: felt, v403: felt) { + ^block38(v400: felt, v401: felt, v402: felt, v403: felt): + hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden:basic-wallet/basic-wallet@0.1.0#receive-asset(v400, v401, v402, v403) builtin.ret ; }; - public builtin.function @move-asset-to-note(v366: felt, v367: felt, v368: felt, v369: felt, v370: felt) { - ^block40(v366: felt, v367: felt, v368: felt, v369: felt, v370: felt): - hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden:basic-wallet/basic-wallet@0.1.0#move-asset-to-note(v366, v367, v368, v369, v370) + public builtin.function @move-asset-to-note(v404: felt, v405: felt, v406: felt, v407: felt, v408: felt) { + ^block40(v404: felt, v405: felt, v406: felt, v407: felt, v408: felt): + hir.exec @miden:basic-wallet/basic-wallet@0.1.0/basic_wallet/miden:basic-wallet/basic-wallet@0.1.0#move-asset-to-note(v404, v405, v406, v407, v408) builtin.ret ; }; }; \ No newline at end of file diff --git a/tests/integration/expected/examples/basic_wallet.masm b/tests/integration/expected/examples/basic_wallet.masm index e97f30a45..b1a26c174 100644 --- a/tests/integration/expected/examples/basic_wallet.masm +++ b/tests/integration/expected/examples/basic_wallet.masm @@ -669,8 +669,28 @@ proc miden_base_sys::bindings::native_account::add_asset( i32, i32 ) + push.1114144 + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::load_sw + trace.252 + nop + push.32 + u32wrapping_sub + push.1114144 + dup.1 + swap.1 + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::store_sw + trace.252 + nop push.12 - dup.2 + dup.3 add u32assert push.4 @@ -687,7 +707,7 @@ proc miden_base_sys::bindings::native_account::add_asset( trace.252 nop push.8 - dup.3 + dup.4 add u32assert push.4 @@ -704,7 +724,7 @@ proc miden_base_sys::bindings::native_account::add_asset( trace.252 nop push.4 - dup.4 + dup.5 add u32assert push.4 @@ -720,7 +740,7 @@ proc miden_base_sys::bindings::native_account::add_asset( exec.::intrinsics::mem::load_felt trace.252 nop - movup.4 + movup.5 push.4 dup.1 swap.1 @@ -734,13 +754,106 @@ proc miden_base_sys::bindings::native_account::add_asset( exec.::intrinsics::mem::load_felt trace.252 nop - movdn.3 - swap.2 + dup.4 + swap.1 + swap.3 + swap.1 + swap.4 trace.240 nop exec.::miden:basic-wallet/basic-wallet@0.1.0::basic_wallet::miden::native_account::add_asset trace.252 nop + push.8 + dup.1 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::load_dw + trace.252 + nop + swap.1 + push.24 + dup.3 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz + u32divmod.4 + swap.1 + movup.2 + movdn.3 + trace.240 + nop + exec.::intrinsics::mem::store_dw + trace.252 + nop + dup.0 + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::load_dw + trace.252 + nop + swap.1 + push.16 + dup.3 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz + u32divmod.4 + swap.1 + movup.2 + movdn.3 + trace.240 + nop + exec.::intrinsics::mem::store_dw + trace.252 + nop + push.16 + dup.1 + u32wrapping_add + movup.2 + trace.240 + nop + exec.::miden:basic-wallet/basic-wallet@0.1.0::basic_wallet::::reverse + trace.252 + nop + push.32 + u32wrapping_add + push.1114144 + u32divmod.4 + swap.1 + trace.240 + nop + exec.::intrinsics::mem::store_sw + trace.252 + nop end @callconv("C") diff --git a/tests/integration/expected/examples/basic_wallet.wat b/tests/integration/expected/examples/basic_wallet.wat index 4969facfe..19c6b387a 100644 --- a/tests/integration/expected/examples/basic_wallet.wat +++ b/tests/integration/expected/examples/basic_wallet.wat @@ -161,6 +161,12 @@ global.set $__stack_pointer ) (func $miden_base_sys::bindings::native_account::add_asset (;7;) (type 4) (param i32 i32) + (local i32) + global.get $__stack_pointer + i32.const 32 + i32.sub + local.tee 2 + global.set $__stack_pointer local.get 1 f32.load offset=12 local.get 1 @@ -169,8 +175,25 @@ f32.load offset=4 local.get 1 f32.load - local.get 0 + local.get 2 call $miden::native_account::add_asset + local.get 2 + local.get 2 + i64.load offset=8 + i64.store offset=24 + local.get 2 + local.get 2 + i64.load + i64.store offset=16 + local.get 0 + local.get 2 + i32.const 16 + i32.add + call $::reverse + local.get 2 + i32.const 32 + i32.add + global.set $__stack_pointer ) (func $::reverse (;8;) (type 4) (param i32 i32) (local i32 i32 i32 f32)