makepad/libs/stitch/benches/wat/fib_iter.wat
2025-05-06 10:11:37 +02:00

57 lines
No EOL
1.2 KiB
WebAssembly Text Format

(func $fib_iter (export "fib_iter") (param $n i64) (result i64)
(local $n1 i64)
(local $n2 i64)
(local $i i64)
(local $tmp i64)
(if
(i64.lt_u
(local.get $n)
(i64.const 2)
)
(then
(return
(local.get $n)
)
)
)
(local.set $n1
(i64.const 0)
)
(local.set $n2
(i64.const 1)
)
(local.set $i
(i64.const 2)
)
(block $break
(loop $continue
(local.set $tmp
(i64.add
(local.get $n1)
(local.get $n2)
)
)
(local.set $n1
(local.get $n2)
)
(local.set $n2
(local.get $tmp)
)
(br_if $break
(i64.eq
(local.get $i)
(local.get $n)
)
)
(local.set $i
(i64.add
(local.get $i)
(i64.const 1)
)
)
(br $continue)
)
)
(local.get $n2)
)