Inductive match_states (j:meminj): CMinSel_core -> mem -> RTL_core -> mem -> Prop :=
| match_state:
forall f s k sp e m tm cs tf ns rs map ncont nexits ngoto nret rret sp'
(MWF: map_wf map)
(TS: tr_stmt tf.(fn_code) map s ns ncont nexits ngoto nret rret)
(TF: tr_fun tf map f ngoto nret rret)
(TK: tr_cont j tf.(fn_code) map k ncont nexits ngoto nret rret cs)
(ME: match_env j map e nil rs)
(*(MEXT: Mem.extends m tm)*)
(MINJ: Mem.inject j m tm)
(*NEW:*) (SP: sp_preserved j sp sp'), match_states j (CMinSel_State f s k sp e) m (RTL_State cs tf sp' ns rs) tm | match_callstate: forall f args targs k m tm cs tf (TF: transl_fundef f = OK tf) (MS: match_stacks j k cs) (*(LD: Val.lessdef_list args targs)*)
(AINJ: val_list_inject j args targs)
(*(MEXT: Mem.extends m tm)*)
(MINJ: Mem.inject j m tm),
match_states j (CMinSel_Callstate f args k) m
(RTL_Callstate cs tf targs) tm
| match_returnstate:
forall v tv k m tm cs
(MS: match_stacks j k cs)
(*(LD: Val.lessdef v tv)*)
(VINJ: val_inject j v tv)
(*(MEXT: Mem.extends m tm)*)
(MINJ: Mem.inject j m tm),
match_states j (CMinSel_Returnstate v k) m
(RTL_Returnstate cs tv) tm.

(* Specifications: *)
Lemma match_stacks_call_cont:
forall j c map k ncont nexits ngoto nret rret cs,
tr_cont j c map k ncont nexits ngoto nret rret cs ->
match_stacks j (call_cont k) cs /\ c!nret = Some(Ireturn rret).
Lemma tr_cont_call_cont:
forall j c map k ncont nexits ngoto nret rret cs,
tr_cont j c map k ncont nexits ngoto nret rret cs ->
tr_cont j c map (call_cont k) nret nil ngoto nret rret cs.
Lemma tr_find_label:
forall j c map lbl n (ngoto: labelmap) nret rret s' k' cs,
ngoto!lbl = Some n ->
forall s k ns1 nd1 nexits1,
find_label lbl s k = Some (s', k') ->
tr_stmt c map s ns1 nd1 nexits1 ngoto nret rret ->
tr_cont j c map k nd1 nexits1 ngoto nret rret cs ->
exists ns2, exists nd2, exists nexits2,
c!n = Some(Inop ns2)
/\ tr_stmt c map s' ns2 nd2 nexits2 ngoto nret rret
/\ tr_cont j c map k' nd2 nexits2 ngoto nret rret cs.