diff options
author | Braxton Hall | 2022-10-25 04:06:43 +0000 |
---|---|---|
committer | GitHub | 2022-10-25 04:06:43 +0000 |
commit | dc1605d28833762797f19285cb673d2019b7a3bd (patch) | |
tree | f3581216fd7c6f9c21f12354a6a39c588adae03b /entries/adirar111/wasm | |
parent | 38781fac8ddeb81670de5aa18f55fa7a2edb1bb7 (diff) | |
parent | 316a252403ab4fdda81bc34528625cd28dca9c0a (diff) |
Merge pull request #34 from adirar111/main
filesystem cache in c
Diffstat (limited to 'entries/adirar111/wasm')
-rw-r--r-- | entries/adirar111/wasm/fib.wat | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/entries/adirar111/wasm/fib.wat b/entries/adirar111/wasm/fib.wat index 255fa12..6ec9b69 100644 --- a/entries/adirar111/wasm/fib.wat +++ b/entries/adirar111/wasm/fib.wat @@ -4,43 +4,24 @@ (module (export "fib" (func $fib)) (func $fib (param $n i32) (result i32) - (local $last i32) - (local $sum i32) - (local $i i32) - (local $tmp i32) - (if - (i32.lt_s - (local.get $n) - (i32.const 2) + (local $last i32) + (local $sum i32) + (local $i i32) + (local $tmp i32) + (if (i32.lt_s (local.get $n) (i32.const 2)) + (return (local.get $n)) ) - (return (local.get $n)) - ) - (local.set $last (i32.const 0)) - (local.set $sum (i32.const 1)) - (local.set $i (i32.const 2)) - (local.set $n (i32.add (local.get $n) (i32.const 1))) - (loop $loop - (local.set $tmp (local.get $sum)) - (local.set $sum - (i32.add - (local.get $sum) - (local.get $last) - ) - ) - (local.set $last (local.get $tmp)) - (local.set $i - (i32.add - (local.get $i) - (i32.const 1) - ) + (local.set $last (i32.const 0)) + (local.set $sum (i32.const 1)) + (local.set $i (i32.const 2)) + (local.set $n (i32.add (local.get $n) (i32.const 1))) + (loop $loop + (local.set $tmp (local.get $sum)) + (local.set $sum (i32.add (local.get $sum) (local.get $last))) + (local.set $last (local.get $tmp)) + (local.set $i (i32.add (local.get $i) (i32.const 1))) + (br_if $loop (i32.lt_s (local.get $i) (local.get $n))) ) - (br_if $loop - (i32.lt_s - (local.get $i) - (local.get $n) - ) - ) - ) - (return (local.get $sum)) + (return (local.get $sum)) ) ) |