Instance CompSpecs : compspecs. make_compspecs prog. Defined.
Definition Vprog : varspecs. mk_varspecs prog. Defined.
Definition putchars_spec := DECLARE _putchars putchars_spec.
Definition getchars_spec := DECLARE _getchars getchars_spec.
Program Fixpoint chars_of_Z (n : Z) { measure (Z.to_nat n) } : list byte :=
let n' := n / 10 in
match n' <=? 0 with true => [Byte.repr (n + char0)] | false => chars_of_Z n' ++ [Byte.repr (n mod 10 + char0)] end.
Next Obligation.
(*Opaque bind.  Opaque Nat.div Nat.modulo.*)
Definition ext_link := ext_link_prog prog.
Instance Espec : OracleKind := IO_Espec ext_link.
Definition init_mem_exists : { m | Genv.init_mem prog = Some m }.
Definition init_mem := proj1_sig init_mem_exists.
Definition main_block_exists : {b | Genv.find_symbol (Genv.globalenv prog) (prog_main prog) = Some b}.
Definition main_block := proj1_sig main_block_exists.

Theorem prog_toplevel : exists q,
semantics.initial_core (Clight_core.cl_core_sem (globalenv prog)) 0 init_mem q init_mem (Vptr main_block Ptrofs.zero) [] /\
forall n, @step_lemmas.dry_safeN _ _ _ _ semax.genv_symb_injective (Clight_core.cl_core_sem (globalenv prog))
(io_dry_spec ext_link) (Genv.globalenv prog) n
main_itree q init_mem.