;;; TOOL: run-interp
;;; ARGS*: --enable-tail-call
(module
  (func (export "fac10") (result i32)
    i32.const 10
    i32.const 1
    call $fac
    return)

(;; Tail call version of factorial ;;)
(;; fac(Ix,So) => Ix==0?So:fac(Ix-1,So*Ix) ;;)
  (func $fac (param i32 i32) (result i32)
    local.get 0
    i32.const 0
    i32.gt_s
    if (result i32)
      local.get 0
      i32.const 1
      i32.sub
      local.get 1
      local.get 0
      i32.mul
      return_call $fac
    else
      local.get 1
      return
    end)
)
(;; STDOUT ;;;
fac10() => i32:3628800
;;; STDOUT ;;)
