;;; 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)
    get_local 0
    i32.const 0
    i32.gt_s
    if (result i32)
      get_local 0
      i32.const 1
      i32.sub
      get_local 1
      get_local 0
      i32.mul
      return_call $fac
    else
      get_local 1
      return
    end)
)
(;; STDOUT ;;;
fac10() => i32:3628800
;;; STDOUT ;;)
