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.

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.