;;; TOOL: run-roundtrip
;;; ARGS: --stdout --fold-exprs --debug-names --generate-names
(module
  (func $fac-stack-raw (param $n i64) (result i64)
    (local $i i64)
    (local $res i64)
    local.get $n
    local.set $i
    i64.const 1
    local.set $res
    block $done
      loop $loop
        local.get $i
        i64.const 0
        i64.eq
        if $body
          br $done
        else $body
          local.get $i
          local.get $res
          i64.mul
          local.set $res
          local.get $i
          i64.const 1
          i64.sub
          local.set $i
        end $body
        br $loop
      end $loop
    end $done
    local.get $res))
(;; STDOUT ;;;
(module
  (type $t0 (func (param i64) (result i64)))
  (func $fac-stack-raw (type $t0) (param $n i64) (result i64)
    (local $i i64) (local $res i64)
    (local.set $i
      (local.get $n))
    (local.set $res
      (i64.const 1))
    (block $B0
      (loop $L1
        (if $I2
          (i64.eq
            (local.get $i)
            (i64.const 0))
          (then
            (br $B0))
          (else
            (local.set $res
              (i64.mul
                (local.get $i)
                (local.get $res)))
            (local.set $i
              (i64.sub
                (local.get $i)
                (i64.const 1)))))
        (br $L1)))
    (local.get $res)))
;;; STDOUT ;;)
