(module (type $ii (;0;) (func (param i32) (result i32))) (type $ll (;1;) (func (param i64) (result i64))) (type $lll (;2;) (func (param i64 i64) (result i64))) (type (;3;) (func (param (ref $ii) i32) (result i32))) (type (;4;) (func (result i32))) (global $fac (;0;) (ref $ll) ref.func $fac) (global $fac-acc (;1;) (ref $lll) ref.func $fac-acc) (global $fib (;2;) (ref $ll) ref.func $fib) (global $even (;3;) (ref $ll) ref.func $even) (global $odd (;4;) (ref $ll) ref.func $odd) (export "run" (func 3)) (export "null" (func 4)) (export "fac" (func $fac)) (export "fac-acc" (func $fac-acc)) (export "fib" (func $fib)) (export "even" (func $even)) (export "odd" (func $odd)) (elem (;0;) declare func $f $g) (elem (;1;) declare func $fac) (elem (;2;) declare func $fac-acc) (elem (;3;) declare func $fib) (elem (;4;) declare func $even $odd) (func $apply (;0;) (type 3) (param $f (ref $ii)) (param $x i32) (result i32) local.get $x local.get $f call_ref $ii ) (func $f (;1;) (type $ii) (param i32) (result i32) local.get 0 local.get 0 i32.mul ) (func $g (;2;) (type $ii) (param i32) (result i32) i32.const 0 local.get 0 i32.sub ) (func (;3;) (type $ii) (param $x i32) (result i32) (local $rf (ref null $ii)) (local $rg (ref null $ii)) ref.func $f local.set $rf ref.func $g local.set $rg local.get $x local.get $rf call_ref $ii local.get $rg call_ref $ii ) (func (;4;) (type 4) (result i32) i32.const 1 ref.null $ii call_ref $ii ) (func $fac (;5;) (type $ll) (param i64) (result i64) local.get 0 i64.eqz if (result i64) ;; label = @1 i64.const 1 else local.get 0 local.get 0 i64.const 1 i64.sub global.get $fac call_ref $ll i64.mul end ) (func $fac-acc (;6;) (type $lll) (param i64 i64) (result i64) local.get 0 i64.eqz if (result i64) ;; label = @1 local.get 1 else local.get 0 i64.const 1 i64.sub local.get 0 local.get 1 i64.mul global.get $fac-acc call_ref $lll end ) (func $fib (;7;) (type $ll) (param i64) (result i64) local.get 0 i64.const 1 i64.le_u if (result i64) ;; label = @1 i64.const 1 else local.get 0 i64.const 2 i64.sub global.get $fib call_ref $ll local.get 0 i64.const 1 i64.sub global.get $fib call_ref $ll i64.add end ) (func $even (;8;) (type $ll) (param i64) (result i64) local.get 0 i64.eqz if (result i64) ;; label = @1 i64.const 44 else local.get 0 i64.const 1 i64.sub global.get $odd call_ref $ll end ) (func $odd (;9;) (type $ll) (param i64) (result i64) local.get 0 i64.eqz if (result i64) ;; label = @1 i64.const 99 else local.get 0 i64.const 1 i64.sub global.get $even call_ref $ll end ) )