(module $generator (type $gen (;0;) (func (param i64))) (type $geny (;1;) (func (param i32))) (type $cont0 (;2;) (cont $gen)) (type $cont (;3;) (cont $geny)) (type (;4;) (func (param i64) (result i32))) (type (;5;) (func (param i64 i64) (result i64))) (type (;6;) (func (param i64 (ref $cont0)) (result i64 (ref $cont)))) (type (;7;) (func (param i64 (ref $cont)))) (tag $yield (;0;) (type 4) (param i64) (result i32)) (global $hook (;0;) (mut (ref $gen)) ref.func $dummy) (export "hook" (global $hook)) (export "start" (func $gen)) (export "sum" (func 2)) (elem (;0;) declare func $gen) (func $dummy (;0;) (type $gen) (param i64)) (func $gen (;1;) (type $gen) (param $i i64) loop $l local.get $i suspend $yield br_if 1 local.get $i global.get $hook call_ref $gen local.get $i i64.const 1 i64.add local.set $i br $l end ) (func (;2;) (type 5) (param $i i64) (param $j i64) (result i64) (local $sum i64) (local $n i64) (local $k (ref null $cont)) local.get $i ref.func $gen cont.new $cont0 block $on_first_yield (type 6) (param i64 (ref $cont0)) (result i64 (ref $cont)) resume $cont0 (on $yield $on_first_yield) unreachable end loop $on_yield (type 7) (param i64 (ref $cont)) local.set $k local.set $n local.get $sum local.get $n i64.add local.set $sum local.get $n local.get $j i64.eq local.get $k resume $cont (on $yield $on_yield) end local.get $sum return ) )