(** Inversion on [transf_function] *)
Inductive transf_function_spec (f: RTL.function) (tf: LTL.function) : Prop :=
| transf_function_spec_intro:
forall env an mv k e1 e2,
wt_function f env ->
analyze f env (pair_codes f tf) = Some an ->
(LTL.fn_code tf)!(LTL.fn_entrypoint tf) = Some(expand_moves mv (Lbranch (RTL.fn_entrypoint f) :: k)) ->
wf_moves mv ->
transfer f env (pair_codes f tf) (RTL.fn_entrypoint f) an!!(RTL.fn_entrypoint f) = OK e1 ->
track_moves env mv e1 = Some e2 ->
compat_entry (RTL.fn_params f) (loc_parameters (fn_sig tf)) e2 = true ->
can_undef destroyed_at_function_entry e2 = true ->
RTL.fn_stacksize f = LTL.fn_stacksize tf ->
RTL.fn_sig f = LTL.fn_sig tf ->
transf_function_spec f tf.

Lemma invert_code:
forall f env tf pc i opte e,
wt_function f env ->
(RTL.fn_code f)!pc = Some i ->
transfer f env (pair_codes f tf) pc opte = OK e ->
exists eafter, exists bsh, exists bb,
opte = OK eafter /\
(pair_codes f tf)!pc = Some bsh /\
(LTL.fn_code tf)!pc = Some bb /\
expand_block_shape bsh i bb /\
transfer_aux f env bsh eafter = Some e /\
wt_instr f env i.