import TsmLean

open TsmLean.Core in
def main : IO UInt32 := do
  -- Demo: 5 + 3, then * 2 = 16
  let prog : Array Instr := #[
    .push 5,
    .push 3,
    .add,
    .push 2,
    .mul,
    .halt
  ]
  let s₀ : State := { code := prog, pc := 0, stack := [] }
  match run 100 s₀ with
  | some s_final =>
    IO.println s!"final stack: {repr s_final.stack}"
    IO.println s!"final pc: {s_final.pc}"
    return 0
  | none =>
    IO.eprintln "execution did not terminate within fuel"
    return 1
