(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)

(** Correctness proof for expression simplification. *)

Require Import FunInd.
Require Import Coqlib Maps Errors Integers.
Require Import AST Linking.
Require Import Values Memory Events Globalenvs Smallstep.
Require Import Ctypes Cop Csyntax Csem Cstrategy Clight.
Require Import SimplExpr SimplExprspec.

(** ** Relational specification of the translation. *)

Definition match_prog (p: Csyntax.program) (tp: Clight.program) :=
    match_program (fun ctx f tf => tr_fundef f tf) eq p tp
 /\ prog_types tp = prog_types p.

Lemma transf_program_match:
  forall p tp, transl_program p = OK tp -> match_prog p tp.
Proof.
  unfold transl_program; intros. monadInv H. split; auto.
  unfold program_of_program; simpl. destruct x; simpl.
  eapply match_transform_partial_program_contextual. eexact EQ. 
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply transl_fundef_spec; auto. 
Qed.

(** ** Semantic preservation *)

Section PRESERVATION.

Variable prog: Csyntax.program.
Variable tprog: Clight.program.
Hypothesis TRANSL: match_prog prog tprog.

Let ge := Csem.globalenv prog.
Let tge := Clight.globalenv tprog.

(** Invariance properties. *)

Lemma comp_env_preserved:
  Clight.genv_cenv tge = Csem.genv_cenv ge.
Proof.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. destruct TRANSL. generalize (prog_comp_env_eq tprog) (prog_comp_env_eq prog). 
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  congruence.
Qed.

Lemma symbols_preserved:
  forall (s: ident), Genv.find_symbol tge s = Genv.find_symbol ge s.
Proof (Genv.find_symbol_match (proj1 TRANSL)).

Lemma senv_preserved:
  Senv.equiv ge tge.
Proof (Genv.senv_match (proj1 TRANSL)).

Lemma function_ptr_translated:
  forall b f,
  Genv.find_funct_ptr ge b = Some f ->
  exists tf,
  Genv.find_funct_ptr tge b = Some tf /\ tr_fundef f tf.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros.
(* Goal: @ex fundef (fun tf : fundef => and (@eq (option fundef) (@Genv.find_funct_ptr fundef type (genv_genv tge) b) (@Some fundef tf)) (tr_fundef f tf)) *)
  edestruct (Genv.find_funct_ptr_match (proj1 TRANSL)) as (ctx & tf & A & B & C); eauto.
Qed.

Lemma functions_translated:
  forall v f,
  Genv.find_funct ge v = Some f ->
  exists tf,
  Genv.find_funct tge v = Some tf /\ tr_fundef f tf.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros.
(* Goal: @ex fundef (fun tf : fundef => and (@eq (option fundef) (@Genv.find_funct fundef type (genv_genv tge) v) (@Some fundef tf)) (tr_fundef f tf)) *)
  edestruct (Genv.find_funct_match (proj1 TRANSL)) as (ctx & tf & A & B & C); eauto.
Qed.

Lemma type_of_fundef_preserved:
  forall f tf, tr_fundef f tf ->
  type_of_fundef tf = Csyntax.type_of_fundef f.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  inv H0; simpl. unfold type_of_function, Csyntax.type_of_function. congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
Qed.

Lemma function_return_preserved:
  forall f tf, tr_function f tf ->
  fn_return tf = Csyntax.fn_return f.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H; auto.
Qed.

(** Properties of smart constructors. *)

Lemma eval_Ederef':
  forall ge e le m a t l ofs,
  eval_expr ge e le m a (Vptr l ofs) ->
  eval_lvalue ge e le m (Ederef' a t) l ofs.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold Ederef'; destruct a; auto using eval_Ederef.
(* Goal: eval_lvalue ge0 e le m (if type_eq t (typeof a) then a else Ederef (Eaddrof a t0) t) l ofs *)
  destruct (type_eq t (typeof a)); auto using eval_Ederef.
(* Goal: final_state S' r *)
  inv H.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- auto. 
- inv H0.
Qed.

Lemma typeof_Ederef':
  forall a t, typeof (Ederef' a t) = t.
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  unfold Ederef'; intros; destruct a; auto. destruct (type_eq t (typeof a)); auto. 
Qed.

Lemma eval_Eaddrof':
  forall ge e le m a t l ofs,
  eval_lvalue ge e le m a l ofs ->
  eval_expr ge e le m (Eaddrof' a t) (Vptr l ofs).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold Eaddrof'; destruct a; auto using eval_Eaddrof.
(* Goal: eval_expr ge0 e le m (if type_eq t (typeof a) then a else Eaddrof (Ederef a t0) t) (Vptr l ofs) *)
  destruct (type_eq t (typeof a)); auto using eval_Eaddrof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  inv H; auto.
Qed.

Lemma typeof_Eaddrof':
  forall a t, typeof (Eaddrof' a t) = t.
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  unfold Eaddrof'; intros; destruct a; auto. destruct (type_eq t (typeof a)); auto. 
Qed.

(** Translation of simple expressions. *)

Lemma tr_simple_nil:
  (forall le dst r sl a tmps, tr_expr le dst r sl a tmps ->
   dst = For_val \/ dst = For_effects -> simple r = true -> sl = nil)
/\(forall le rl sl al tmps, tr_exprlist le rl sl al tmps ->
   simplelist rl = true -> sl = nil).
Proof.
  assert (A: forall dst a, dst = For_val \/ dst = For_effects -> final dst a = nil).
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
    intros. destruct H; subst dst; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_exprlist; intros; simpl in *; try discriminate; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; auto. simpl; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; auto. simpl; auto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  destruct H1; congruence.
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  destruct (andb_prop _ _ H6). inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    rewrite H0; eauto. simpl; auto.
(* Goal: @eq (list statement) (@app statement sl1 (@cons statement (make_set t a1) (final dst (Etempvar t (Csyntax.typeof e1))))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
    unfold chunk_for_volatile_type in H9.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
    destruct (type_is_volatile (Csyntax.typeof e1)); simpl in H8; congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; auto. simpl; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; auto. simpl; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (andb_prop _ _ H7). rewrite H0; auto. rewrite H2; auto. simpl; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; auto. simpl; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (andb_prop _ _ H6). rewrite H0; auto.
Qed.

Lemma tr_simple_expr_nil:
  forall le dst r sl a tmps, tr_expr le dst r sl a tmps ->
  dst = For_val \/ dst = For_effects -> simple r = true -> sl = nil.
Proof (proj1 tr_simple_nil).

Lemma tr_simple_exprlist_nil:
  forall le rl sl al tmps, tr_exprlist le rl sl al tmps ->
  simplelist rl = true -> sl = nil.
Proof (proj2 tr_simple_nil).

(** Translation of [deref_loc] and [assign_loc] operations. *)

Remark deref_loc_translated:
  forall ty m b ofs t v,
  Csem.deref_loc ge ty m b ofs t v ->
  match chunk_for_volatile_type ty with
  | None => t = E0 /\ Clight.deref_loc ty m b ofs v
  | Some chunk => volatile_load tge chunk m b ofs t v
  end.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold chunk_for_volatile_type. inv H.
  (* By_value, not volatile *)
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  rewrite H1. split; auto. eapply deref_loc_value; eauto.
  (* By_value, volatile *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; rewrite H1. eapply volatile_load_preserved with (ge1 := ge); auto. apply senv_preserved.
  (* By reference *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0. destruct (type_is_volatile ty); split; auto; eapply deref_loc_reference; eauto.
  (* By copy *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0. destruct (type_is_volatile ty); split; auto; eapply deref_loc_copy; eauto.
Qed.

Remark assign_loc_translated:
  forall ty m b ofs v t m',
  Csem.assign_loc ge ty m b ofs v t m' ->
  match chunk_for_volatile_type ty with
  | None => t = E0 /\ Clight.assign_loc tge ty m b ofs v m'
  | Some chunk => volatile_store tge chunk m b ofs v t m'
  end.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold chunk_for_volatile_type. inv H.
  (* By_value, not volatile *)
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  rewrite H1. split; auto. eapply assign_loc_value; eauto.
  (* By_value, volatile *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H0; rewrite H1. eapply volatile_store_preserved with (ge1 := ge); auto. apply senv_preserved.
  (* By copy *)
  rewrite H0. rewrite <- comp_env_preserved in *.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (type_is_volatile ty); split; auto; eapply assign_loc_copy; eauto.
Qed.

(** Evaluation of simple expressions and of their translation *)

Lemma tr_simple:
 forall e m,
 (forall r v,
  eval_simple_rvalue ge e m r v ->
  forall le dst sl a tmps,
  tr_expr le dst r sl a tmps ->
  match dst with
  | For_val => sl = nil /\ Csyntax.typeof r = typeof a /\ eval_expr tge e le m a v
  | For_effects => sl = nil
  | For_set sd =>
      exists b, sl = do_set sd b
             /\ Csyntax.typeof r = typeof b
             /\ eval_expr tge e le m b v
  end)
/\
 (forall l b ofs,
  eval_simple_lvalue ge e m l b ofs ->
  forall le sl a tmps,
  tr_expr le For_val l sl a tmps ->
  sl = nil /\ Csyntax.typeof l = typeof a /\ eval_lvalue tge e le m a b ofs).
Proof.
Opaque makeif.
(* Goal: forall (e : Csem.env) (m : Mem.mem) (l : Csyntax.expr) (b : block) (ofs : Ptrofs.int) (_ : eval_simple_lvalue ge e m l b ofs) (le : temp_env) (sl : list statement) (a : expr) (tmps : list ident) (_ : tr_expr le For_val l sl a tmps), and (@eq (list statement) sl (@nil statement)) (and (@eq type (Csyntax.typeof l) (typeof a)) (eval_lvalue tge e le m a b ofs)) *)
  intros e m.
  apply (eval_simple_rvalue_lvalue_ind ge e m); intros until tmps; intros TR; inv TR.
(* value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exists a0; auto.
(* rvalof *)
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  inv H7; try congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]].
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  subst sl1; simpl.
  assert (eval_expr tge e le m a v).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    eapply eval_Elvalue. eauto.
    rewrite <- B.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    exploit deref_loc_translated; eauto. unfold chunk_for_volatile_type; rewrite H2. tauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct dst; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. split. simpl; eauto. auto.
(* addrof *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]].
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  subst sl1; simpl.
  assert (eval_expr tge e le m (Eaddrof' a1 ty) (Vptr b ofs)) by (apply eval_Eaddrof'; auto).
  assert (typeof (Eaddrof' a1 ty) = ty) by (apply typeof_Eaddrof').
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct dst; auto. simpl; econstructor; eauto.  
(* unop *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]].
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  subst sl1; simpl.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  assert (eval_expr tge e le m (Eunop op a1 ty) v). econstructor; eauto. congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct dst; auto. simpl; econstructor; eauto.
(* binop *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H2; eauto. intros [D [E F]].
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  subst sl1 sl2; simpl.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  assert (eval_expr tge e le m (Ebinop op a1 a2 ty) v). econstructor; eauto. rewrite comp_env_preserved; congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct dst; auto. simpl; econstructor; eauto.
(* cast *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]].
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  subst sl1; simpl.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  assert (eval_expr tge e le m (Ecast a1 ty) v). econstructor; eauto. congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct dst; auto. simpl; econstructor; eauto.
(* sizeof *)
  rewrite <- comp_env_preserved.
  destruct dst.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split; auto. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exists (Esizeof ty1 ty). split. auto. split. auto. constructor.
(* alignof *)
  rewrite <- comp_env_preserved.
  destruct dst.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split; auto. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exists (Ealignof ty1 ty). split. auto. split. auto. constructor.
(* var local *)
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split; auto. apply eval_Evar_local; auto.
(* var global *)
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split; auto. apply eval_Evar_global; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    rewrite symbols_preserved; auto.
(* deref *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]]. subst sl1.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split. rewrite typeof_Ederef'; auto. apply eval_Ederef'; auto. 
(* field struct *)
  rewrite <- comp_env_preserved in *.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]]. subst sl1.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split; auto. rewrite B in H1. eapply eval_Efield_struct; eauto.
(* field union *)
  rewrite <- comp_env_preserved in *.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [A [B C]]. subst sl1.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  split; auto. split; auto. rewrite B in H1. eapply eval_Efield_union; eauto.
Qed.

Lemma tr_simple_rvalue:
  forall e m r v,
  eval_simple_rvalue ge e m r v ->
  forall le dst sl a tmps,
  tr_expr le dst r sl a tmps ->
  match dst with
  | For_val => sl = nil /\ Csyntax.typeof r = typeof a /\ eval_expr tge e le m a v
  | For_effects => sl = nil
  | For_set sd =>
      exists b, sl = do_set sd b
             /\ Csyntax.typeof r = typeof b
             /\ eval_expr tge e le m b v
  end.
Proof.
(* Goal: forall (e : Csem.env) (m : Mem.mem) (l : Csyntax.expr) (b : block) (ofs : Ptrofs.int) (_ : eval_simple_lvalue ge e m l b ofs) (le : temp_env) (sl : list statement) (a : expr) (tmps : list ident) (_ : tr_expr le For_val l sl a tmps), and (@eq (list statement) sl (@nil statement)) (and (@eq type (Csyntax.typeof l) (typeof a)) (eval_lvalue tge e le m a b ofs)) *)
  intros e m. exact (proj1 (tr_simple e m)).
Qed.

Lemma tr_simple_lvalue:
  forall e m l b ofs,
  eval_simple_lvalue ge e m l b ofs ->
  forall le sl a tmps,
  tr_expr le For_val l sl a tmps ->
  sl = nil /\ Csyntax.typeof l = typeof a /\ eval_lvalue tge e le m a b ofs.
Proof.
(* Goal: forall (e : Csem.env) (m : Mem.mem) (l : Csyntax.expr) (b : block) (ofs : Ptrofs.int) (_ : eval_simple_lvalue ge e m l b ofs) (le : temp_env) (sl : list statement) (a : expr) (tmps : list ident) (_ : tr_expr le For_val l sl a tmps), and (@eq (list statement) sl (@nil statement)) (and (@eq type (Csyntax.typeof l) (typeof a)) (eval_lvalue tge e le m a b ofs)) *)
  intros e m. exact (proj2 (tr_simple e m)).
Qed.

Lemma tr_simple_exprlist:
  forall le rl sl al tmps,
  tr_exprlist le rl sl al tmps ->
  forall e m tyl vl,
  eval_simple_list ge e m rl tyl vl ->
  sl = nil /\ eval_exprlist tge e le m al tyl vl.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  induction 1; intros.
(* Goal: final_state S' r *)
  inv H. split. auto. constructor.
(* Goal: final_state (Returnstate (Vint r) tk m) r *)
  inv H4.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [A [B C]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit IHtr_exprlist; eauto. intros [D E].
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  split. subst; auto. econstructor; eauto. congruence.
Qed.

(** Commutation between the translation of expressions and left contexts. *)

Lemma typeof_context:
  forall k1 k2 C, leftcontext k1 k2 C ->
  forall e1 e2, Csyntax.typeof e1 = Csyntax.typeof e2 ->
  Csyntax.typeof (C e1) = Csyntax.typeof (C e2).
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; intros; auto.
Qed.

Scheme leftcontext_ind2 := Minimality for leftcontext Sort Prop
  with leftcontextlist_ind2 := Minimality for leftcontextlist Sort Prop.
Combined Scheme leftcontext_leftcontextlist_ind from leftcontext_ind2, leftcontextlist_ind2.

Lemma tr_expr_leftcontext_rec:
 (
  forall from to C, leftcontext from to C ->
  forall le e dst sl a tmps,
  tr_expr le dst (C e) sl a tmps ->
  exists dst', exists sl1, exists sl2, exists a', exists tmp',
  tr_expr le dst' e sl1 a' tmp'
  /\ sl = sl1 ++ sl2
  /\ incl tmp' tmps
  /\ (forall le' e' sl3,
        tr_expr le' dst' e' sl3 a' tmp' ->
        (forall id, ~In id tmp' -> le'!id = le!id) ->
        Csyntax.typeof e' = Csyntax.typeof e ->
        tr_expr le' dst (C e') (sl3 ++ sl2) a tmps)
 ) /\ (
  forall from C, leftcontextlist from C ->
  forall le e sl a tmps,
  tr_exprlist le (C e) sl a tmps ->
  exists dst', exists sl1, exists sl2, exists a', exists tmp',
  tr_expr le dst' e sl1 a' tmp'
  /\ sl = sl1 ++ sl2
  /\ incl tmp' tmps
  /\ (forall le' e' sl3,
        tr_expr le' dst' e' sl3 a' tmp' ->
        (forall id, ~In id tmp' -> le'!id = le!id) ->
        Csyntax.typeof e' = Csyntax.typeof e ->
        tr_exprlist le' (C e') (sl3 ++ sl2) a tmps)
).
Proof.

Ltac TR :=
  econstructor; econstructor; econstructor; econstructor; econstructor;
  split; [eauto | split; [idtac | split]].

Ltac NOTIN :=
  match goal with
  | [ H1: In ?x ?l, H2: list_disjoint ?l _ |- ~In ?x _ ] =>
        red; intro; elim (H2 x x); auto; fail
  | [ H1: In ?x ?l, H2: list_disjoint _ ?l |- ~In ?x _ ] =>
        red; intro; elim (H2 x x); auto; fail
  end.

Ltac UNCHANGED :=
  match goal with
  | [ H: (forall (id: ident), ~In id _ -> ?le' ! id = ?le ! id) |-
         (forall (id: ident), In id _ -> ?le' ! id = ?le ! id) ] =>
      intros; apply H; NOTIN
  end.

  (*generalize compat_dest_change; intro CDC.*)
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply leftcontext_leftcontextlist_ind; intros.

(* base *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite <- app_nil_end; auto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_nil_end; auto.
(* deref *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1; rewrite app_ass; eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* field *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0. eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1; rewrite app_ass; eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* rvalof *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1; rewrite app_ass; eauto. red; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass; econstructor; eauto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  exploit typeof_context; eauto. congruence.
(* addrof *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1; rewrite app_ass; eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* unop *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1; rewrite app_ass; eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* binop left *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* binop right *)
  inv H2.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl2. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3 ++ sl2') with (nil ++ sl3 ++ sl2'). rewrite app_ass. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* cast *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1; rewrite app_ass; eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* seqand *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
(* seqor *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
(* condition *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto. auto. auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. eapply tr_condition_effects. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
  TR.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite Q. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. eapply tr_condition_set. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto. auto. auto.
(* assign left *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto. auto. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply typeof_context; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* assign right *)
  inv H2.
  (* for effects *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl2. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3 ++ sl2') with (nil ++ (sl3 ++ sl2')). rewrite app_ass.
  econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto. auto. auto. auto.
  (* for val *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl2. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3 ++ sl2') with (nil ++ (sl3 ++ sl2')). rewrite app_ass.
  econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto. auto. auto. auto. auto. auto. auto. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply typeof_context; eauto.
(* assignop left *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  symmetry; eapply typeof_context; eauto. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto. auto. auto.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eauto. auto. auto. auto. auto. auto. auto. auto. auto. auto. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply typeof_context; eauto.
(* assignop right *)
  inv H2.
  (* for effects *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl2. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl0 ++ sl2') with (nil ++ sl0 ++ sl2'). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto. auto. eauto. auto. auto. auto. auto. auto. auto.
  (* for val *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl2. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl0 ++ sl2') with (nil ++ sl0 ++ sl2'). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto. eauto. auto. auto. auto. auto. auto. auto. auto. auto. auto. auto. auto.
(* postincr *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  symmetry; eapply typeof_context; eauto.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply typeof_context; eauto.
(* call left *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_exprlist_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. auto. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_exprlist_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
(* call right *)
  inv H2.
  (* for effects *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto.
  (*destruct dst'; constructor||contradiction.*)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3++sl2') with (nil ++ sl3 ++ sl2'). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto. auto. auto. auto.
  (* for val *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto.
  (*destruct dst'; constructor||contradiction.*)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3++sl2') with (nil ++ sl3 ++ sl2'). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto. auto.
(* builtin *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3++sl2') with (nil ++ sl3 ++ sl2'). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto. auto.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. change (sl3++sl2') with (nil ++ sl3 ++ sl2'). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. apply S; auto. auto. auto.
(* comma *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q; rewrite app_ass; eauto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto.
(* paren *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q. eauto. red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. econstructor; eauto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q. eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. econstructor; eauto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. rewrite Q. eauto. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. econstructor; eauto.
(* cons left *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H0; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl1. rewrite app_ass. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_ass. econstructor. apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_exprlist_invariant; eauto.  UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto.
(* cons right *)
  inv H2.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  assert (sl1 = nil) by (eapply tr_simple_expr_nil; eauto). subst sl1; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit H1; eauto. intros [dst' [sl1' [sl2' [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  TR. subst sl2. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. change sl3 with (nil ++ sl3). rewrite app_ass. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_invariant; eauto. UNCHANGED.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto.
Qed.

Theorem tr_expr_leftcontext:
  forall C le r dst sl a tmps,
  leftcontext RV RV C ->
  tr_expr le dst (C r) sl a tmps ->
  exists dst', exists sl1, exists sl2, exists a', exists tmp',
  tr_expr le dst' r sl1 a' tmp'
  /\ sl = sl1 ++ sl2
  /\ incl tmp' tmps
  /\ (forall le' r' sl3,
        tr_expr le' dst' r' sl3 a' tmp' ->
        (forall id, ~In id tmp' -> le'!id = le!id) ->
        Csyntax.typeof r' = Csyntax.typeof r ->
        tr_expr le' dst (C r') (sl3 ++ sl2) a tmps).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. eapply (proj1 tr_expr_leftcontext_rec); eauto.
Qed.

Theorem tr_top_leftcontext:
  forall e le m dst rtop sl a tmps,
  tr_top tge e le m dst rtop sl a tmps ->
  forall r C,
  rtop = C r ->
  leftcontext RV RV C ->
  exists dst', exists sl1, exists sl2, exists a', exists tmp',
  tr_top tge e le m dst' r sl1 a' tmp'
  /\ sl = sl1 ++ sl2
  /\ incl tmp' tmps
  /\ (forall le' m' r' sl3,
        tr_expr le' dst' r' sl3 a' tmp' ->
        (forall id, ~In id tmp' -> le'!id = le!id) ->
        Csyntax.typeof r' = Csyntax.typeof r ->
        tr_top tge e le' m' dst (C r') (sl3 ++ sl2) a tmps).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  induction 1; intros.
(* val for val *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H2; inv H1.
  exists For_val; econstructor; econstructor; econstructor; econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  split. apply tr_top_val_val; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  split. instantiate (1 := nil); auto.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  split. apply incl_refl.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite <- app_nil_end. constructor; auto.
(* base *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  subst r. exploit tr_expr_leftcontext; eauto.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  exists dst'; exists sl1; exists sl2; exists a'; exists tmp'.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  split. apply tr_top_base; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  split. auto. split. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply tr_top_base. apply S; auto.
Qed.

(** Semantics of smart constructors *)

Remark sem_cast_deterministic:
  forall v ty ty' m1 v1 m2 v2,
  sem_cast v ty ty' m1 = Some v1 ->
  sem_cast v ty ty' m2 = Some v2 ->
  v1 = v2.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  unfold sem_cast; intros. destruct (classify_cast ty ty'); try congruence.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
- destruct v; try congruence.
(* Goal: @eq val v1 v2 *)
  destruct Archi.ptr64; try discriminate.
(* Goal: final_state S' r *)
  destruct (Mem.weak_valid_pointer m1 b (Ptrofs.unsigned i)); inv H.
(* Goal: final_state S' r *)
  destruct (Mem.weak_valid_pointer m2 b (Ptrofs.unsigned i)); inv H0.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
- destruct v; try congruence. 
(* Goal: @eq val v1 v2 *)
  destruct (negb Archi.ptr64); try discriminate.
(* Goal: final_state S' r *)
  destruct (Mem.weak_valid_pointer m1 b (Ptrofs.unsigned i)); inv H.
(* Goal: final_state S' r *)
  destruct (Mem.weak_valid_pointer m2 b (Ptrofs.unsigned i)); inv H0.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
Qed.

Lemma eval_simpl_expr_sound:
  forall e le m a v, eval_expr tge e le m a v ->
  match eval_simpl_expr a with Some v' => v' = v | None => True end.
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; simpl; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (eval_simpl_expr a); auto. subst.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (sem_cast v1 (typeof a) ty Mem.empty) as [v'|] eqn:C; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply sem_cast_deterministic; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  inv H; simpl; auto.
Qed.

Lemma static_bool_val_sound:
  forall v t m b, bool_val v t Mem.empty = Some b -> bool_val v t m = Some b.
Proof.
(* Goal: forall (v : val) (t : type) (m : Mem.mem) (b : bool) (_ : @eq (option bool) (bool_val v t Mem.empty) (@Some bool b)), @eq (option bool) (bool_val v t m) (@Some bool b) *)
  assert (A: forall b ofs, Mem.weak_valid_pointer Mem.empty b ofs = false).
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  { unfold Mem.weak_valid_pointer, Mem.valid_pointer, proj_sumbool; intros.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    rewrite ! pred_dec_false by (apply Mem.perm_empty). auto. }  
(* Goal: forall (v : val) (t : type) (m : Mem.mem) (b : bool) (_ : @eq (option bool) (bool_val v t Mem.empty) (@Some bool b)), @eq (option bool) (bool_val v t m) (@Some bool b) *)
  intros until b; unfold bool_val.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (classify_bool t); destruct v; destruct Archi.ptr64 eqn:SF; auto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
- rewrite A; congruence.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
- simpl; rewrite A; congruence.
Qed.

Lemma step_makeif:
  forall f a s1 s2 k e le m v1 b,
  eval_expr tge e le m a v1 ->
  bool_val v1 (typeof a) m = Some b ->
  star step1 tge (State f (makeif a s1 s2) k e le m)
             E0 (State f (if b then s1 else s2) k e le m).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. functional induction (makeif a s1 s2).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- exploit eval_simpl_expr_sound; eauto. rewrite e0. intro EQ; subst v.
(* Goal: @star genv state step1 tge (State f s1 k e le m) E0 (State f (if b then s1 else s2) k e le m) *)
  assert (bool_val v1 (typeof a) m = Some true) by (apply static_bool_val_sound; auto).
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  replace b with true by congruence. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- exploit eval_simpl_expr_sound; eauto. rewrite e0. intro EQ; subst v.
(* Goal: @star genv state step1 tge (State f s2 k e le m) E0 (State f (if b then s1 else s2) k e le m) *)
  assert (bool_val v1 (typeof a) m = Some false) by (apply static_bool_val_sound; auto).
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  replace b with false by congruence. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- apply star_one. eapply step_ifthenelse; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- apply star_one. eapply step_ifthenelse; eauto.
Qed.

Lemma step_make_set:
  forall id a ty m b ofs t v e le f k,
  Csem.deref_loc ge ty m b ofs t v ->
  eval_lvalue tge e le m a b ofs ->
  typeof a = ty ->
  step1 tge (State f (make_set id a) k e le m)
          t (State f Sskip k e (PTree.set id v le) m).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. exploit deref_loc_translated; eauto. rewrite <- H1.
  unfold make_set. destruct (chunk_for_volatile_type (typeof a)) as [chunk|].
(* volatile case *)
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. change (PTree.set id v le) with (set_opttemp (Some id) v le). econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. constructor. eauto.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. unfold sem_cast. simpl. eauto. constructor.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. econstructor; eauto.
(* nonvolatile case *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intros [A B]. subst t. constructor. eapply eval_Elvalue; eauto.
Qed.

Lemma step_make_assign:
  forall a1 a2 ty m b ofs t v m' v2 e le f k,
  Csem.assign_loc ge ty m b ofs v t m' ->
  eval_lvalue tge e le m a1 b ofs ->
  eval_expr tge e le m a2 v2 ->
  sem_cast v2 (typeof a2) ty m = Some v ->
  typeof a1 = ty ->
  step1 tge (State f (make_assign a1 a2) k e le m)
          t (State f Sskip k e le m').
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. exploit assign_loc_translated; eauto. rewrite <- H3.
  unfold make_assign. destruct (chunk_for_volatile_type (typeof a1)) as [chunk|].
(* volatile case *)
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. change le with (set_opttemp None Vundef le) at 2. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. constructor. eauto.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. unfold sem_cast. simpl. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. rewrite H3; eauto. constructor.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. econstructor; eauto.
(* nonvolatile case *)
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  intros [A B]. subst t. econstructor; eauto. congruence.
Qed.

Fixpoint Kseqlist (sl: list statement) (k: cont) :=
  match sl with
  | nil => k
  | s :: l => Kseq s (Kseqlist l k)
  end.

Remark Kseqlist_app:
  forall sl1 sl2 k,
  Kseqlist (sl1 ++ sl2) k = Kseqlist sl1 (Kseqlist sl2 k).
Proof.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  induction sl1; simpl; congruence.
Qed.

Lemma push_seq:
  forall f sl k e le m,
  star step1 tge (State f (makeseq sl) k e le m)
              E0 (State f Sskip (Kseqlist sl k) e le m).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold makeseq. generalize Sskip. revert sl k.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  induction sl; simpl; intros.
  apply star_refl.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  eapply star_right. apply IHsl. constructor. traceEq.
Qed.

Lemma step_tr_rvalof:
  forall ty m b ofs t v e le a sl a' tmp f k,
  Csem.deref_loc ge ty m b ofs t v ->
  eval_lvalue tge e le m a b ofs ->
  tr_rvalof ty a sl a' tmp ->
  typeof a = ty ->
  exists le',
    star step1 tge (State f Sskip (Kseqlist sl k) e le m)
                 t (State f Sskip k e le' m)
  /\ eval_expr tge e le' m a' v
  /\ typeof a' = typeof a
  /\ forall x, ~In x tmp -> le'!x = le!x.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H1.
  (* not volatile *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit deref_loc_translated; eauto. unfold chunk_for_volatile_type; rewrite H3.
  intros [A B]. subst t.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  exists le; split. apply star_refl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  split. eapply eval_Elvalue; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
  (* volatile *)
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. exists (PTree.set t0 v le); split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. eapply star_two. econstructor. eapply step_make_set; eauto. traceEq.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  split. constructor. apply PTree.gss.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  split. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. congruence.
Qed.

(** Matching between continuations *)

Inductive match_cont : Csem.cont -> cont -> Prop :=
  | match_Kstop:
      match_cont Csem.Kstop Kstop
  | match_Kseq: forall s k ts tk,
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont (Csem.Kseq s k) (Kseq ts tk)
  | match_Kwhile2: forall r s k s' ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont (Csem.Kwhile2 r s k)
                 (Kloop1 (Ssequence s' ts) Sskip tk)
  | match_Kdowhile1: forall r s k s' ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont (Csem.Kdowhile1 r s k)
                 (Kloop1 ts s' tk)
  | match_Kfor3: forall r s3 s k ts3 s' ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s3 ts3 ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont (Csem.Kfor3 r s3 s k)
                 (Kloop1 (Ssequence s' ts) ts3 tk)
  | match_Kfor4: forall r s3 s k ts3 s' ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s3 ts3 ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont (Csem.Kfor4 r s3 s k)
                 (Kloop2 (Ssequence s' ts) ts3 tk)
  | match_Kswitch2: forall k tk,
      match_cont k tk ->
      match_cont (Csem.Kswitch2 k) (Kswitch tk)
  | match_Kcall: forall f e C ty k optid tf le sl tk a dest tmps,
      tr_function f tf ->
      leftcontext RV RV C ->
      (forall v m, tr_top tge e (set_opttemp optid v le) m dest (C (Csyntax.Eval v ty)) sl a tmps) ->
      match_cont_exp dest a k tk ->
      match_cont (Csem.Kcall f e C ty k)
                 (Kcall optid tf e le (Kseqlist sl tk))
(*
  | match_Kcall_some: forall f e C ty k dst tf le sl tk a dest tmps,
      transl_function f = Errors.OK tf ->
      leftcontext RV RV C ->
      (forall v m, tr_top tge e (PTree.set dst v le) m dest (C (C.Eval v ty)) sl a tmps) ->
      match_cont_exp dest a k tk ->
      match_cont (Csem.Kcall f e C ty k)
                 (Kcall (Some dst) tf e le (Kseqlist sl tk))
*)

with match_cont_exp : destination -> expr -> Csem.cont -> cont -> Prop :=
  | match_Kdo: forall k a tk,
      match_cont k tk ->
      match_cont_exp For_effects a (Csem.Kdo k) tk
  | match_Kifthenelse_empty: forall a k tk,
      match_cont k tk ->
      match_cont_exp For_val a (Csem.Kifthenelse Csyntax.Sskip Csyntax.Sskip k) (Kseq Sskip tk)
  | match_Kifthenelse_1: forall a s1 s2 k ts1 ts2 tk,
      tr_stmt s1 ts1 -> tr_stmt s2 ts2 ->
      match_cont k tk ->
      match_cont_exp For_val a (Csem.Kifthenelse s1 s2 k) (Kseq (Sifthenelse a ts1 ts2) tk)
  | match_Kwhile1: forall r s k s' a ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont_exp For_val a
         (Csem.Kwhile1 r s k)
         (Kseq (makeif a Sskip Sbreak)
           (Kseq ts (Kloop1 (Ssequence s' ts) Sskip tk)))
  | match_Kdowhile2: forall r s k s' a ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont_exp For_val a
        (Csem.Kdowhile2 r s k)
        (Kseq (makeif a Sskip Sbreak) (Kloop2 ts s' tk))
  | match_Kfor2: forall r s3 s k s' a ts3 ts tk,
      tr_if r Sskip Sbreak s' ->
      tr_stmt s3 ts3 ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_cont_exp For_val a
        (Csem.Kfor2 r s3 s k)
        (Kseq (makeif a Sskip Sbreak)
          (Kseq ts (Kloop1 (Ssequence s' ts) ts3 tk)))
  | match_Kswitch1: forall ls k a tls tk,
      tr_lblstmts ls tls ->
      match_cont k tk ->
      match_cont_exp For_val a (Csem.Kswitch1 ls k) (Kseq (Sswitch a tls) tk)
  | match_Kreturn: forall k a tk,
      match_cont k tk ->
      match_cont_exp For_val a (Csem.Kreturn k) (Kseq (Sreturn (Some a)) tk).

Lemma match_cont_call:
  forall k tk,
  match_cont k tk ->
  match_cont (Csem.call_cont k) (call_cont tk).
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; simpl; auto. constructor. econstructor; eauto.
Qed.

(** Matching between states *)

Inductive match_states: Csem.state -> state -> Prop :=
  | match_exprstates: forall f r k e m tf sl tk le dest a tmps,
      tr_function f tf ->
      tr_top tge e le m dest r sl a tmps ->
      match_cont_exp dest a k tk ->
      match_states (Csem.ExprState f r k e m)
                   (State tf Sskip (Kseqlist sl tk) e le m)
  | match_regularstates: forall f s k e m tf ts tk le,
      tr_function f tf ->
      tr_stmt s ts ->
      match_cont k tk ->
      match_states (Csem.State f s k e m)
                   (State tf ts tk e le m)
  | match_callstates: forall fd args k m tfd tk,
      tr_fundef fd tfd ->
      match_cont k tk ->
      match_states (Csem.Callstate fd args k m)
                   (Callstate tfd args tk m)
  | match_returnstates: forall res k m tk,
      match_cont k tk ->
      match_states (Csem.Returnstate res k m)
                   (Returnstate res tk m)
  | match_stuckstate: forall S,
      match_states Csem.Stuckstate S.

(** Additional results on translation of statements *)

Lemma tr_select_switch:
  forall n ls tls,
  tr_lblstmts ls tls ->
  tr_lblstmts (Csem.select_switch n ls) (select_switch n tls).
Proof.
  assert (DFL: forall ls tls,
      tr_lblstmts ls tls ->
      tr_lblstmts (Csem.select_switch_default ls) (select_switch_default tls)).
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  { induction 1; simpl. constructor. destruct c; auto. constructor; auto. }
  assert (CASE: forall n ls tls,
      tr_lblstmts ls tls ->
      match Csem.select_switch_case n ls with
      | None =>
          select_switch_case n tls = None
      | Some ls' =>
          exists tls', select_switch_case n tls = Some tls' /\ tr_lblstmts ls' tls'
      end).
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  { induction 1; simpl; intros.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    destruct c; auto. destruct (zeq z n); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; split; eauto. constructor; auto. }
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold Csem.select_switch, select_switch.
(* Goal: tr_lblstmts match Csem.select_switch_case n ls with | Some sl' => sl' | None => Csem.select_switch_default ls end match select_switch_case n tls with | Some sl' => sl' | None => select_switch_default tls end *)
  specialize (CASE n ls tls H).
(* Goal: tr_lblstmts match Csem.select_switch_case n ls with | Some sl' => sl' | None => Csem.select_switch_default ls end match select_switch_case n tls with | Some sl' => sl' | None => select_switch_default tls end *)
  destruct (Csem.select_switch_case n ls) as [ls'|].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct CASE as [tls' [P Q]]. rewrite P. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite CASE. apply DFL; auto.
Qed.

Lemma tr_seq_of_labeled_statement:
  forall ls tls,
  tr_lblstmts ls tls ->
  tr_stmt (Csem.seq_of_labeled_statement ls) (seq_of_labeled_statement tls).
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; simpl; constructor; auto.
Qed.

(** Commutation between translation and the "find label" operation. *)

Section FIND_LABEL.

Variable lbl: label.

Definition nolabel (s: statement) : Prop :=
  forall k, find_label lbl s k = None.

Fixpoint nolabel_list (sl: list statement) : Prop :=
  match sl with
  | nil => True
  | s1 :: sl' => nolabel s1 /\ nolabel_list sl'
  end.

Lemma nolabel_list_app:
  forall sl2 sl1, nolabel_list sl1 -> nolabel_list sl2 -> nolabel_list (sl1 ++ sl2).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  induction sl1; simpl; intros. auto. tauto.
Qed.

Lemma makeseq_nolabel:
  forall sl, nolabel_list sl -> nolabel (makeseq sl).
Proof.
  assert (forall sl s, nolabel s -> nolabel_list sl -> nolabel (makeseq_rec s sl)).
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  induction sl; simpl; intros. auto. destruct H0. apply IHsl; auto.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  red. intros; simpl. rewrite H. apply H0.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. unfold makeseq. apply H; auto. red. auto.
Qed.

Lemma makeif_nolabel:
  forall a s1 s2, nolabel s1 -> nolabel s2 -> nolabel (makeif a s1 s2).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. functional induction (makeif a s1 s2); auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  red; simpl; intros. rewrite H; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  red; simpl; intros. rewrite H; auto.
Qed.

Lemma make_set_nolabel:
  forall t a, nolabel (make_set t a).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  unfold make_set; intros; red; intros.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (chunk_for_volatile_type (typeof a)); auto.
Qed.

Lemma make_assign_nolabel:
  forall l r, nolabel (make_assign l r).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  unfold make_assign; intros; red; intros.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (chunk_for_volatile_type (typeof l)); auto.
Qed.

Lemma tr_rvalof_nolabel:
  forall ty a sl a' tmp, tr_rvalof ty a sl a' tmp -> nolabel_list sl.
Proof.
(* Goal: forall (ty : type) (a : expr) (sl : list statement) (a' : expr) (tmp : list ident) (_ : tr_rvalof ty a sl a' tmp), nolabel_list sl *)
  destruct 1; simpl; intuition. apply make_set_nolabel.
Qed.

Lemma nolabel_do_set:
  forall sd a, nolabel_list (do_set sd a).
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction sd; intros; simpl; split; auto; red; auto.
Qed.

Lemma nolabel_final:
  forall dst a, nolabel_list (final dst a).
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  destruct dst; simpl; intros. auto. auto. apply nolabel_do_set.
Qed.

Ltac NoLabelTac :=
  match goal with
  | [ |- nolabel_list nil ] => exact I
  | [ |- nolabel_list (final _ _) ] => apply nolabel_final (*; NoLabelTac*)
  | [ |- nolabel_list (_ :: _) ] => simpl; split; NoLabelTac
  | [ |- nolabel_list (_ ++ _) ] => apply nolabel_list_app; NoLabelTac
  | [ H: _ -> nolabel_list ?x |- nolabel_list ?x ] => apply H; NoLabelTac
  | [ |- nolabel (makeseq _) ] => apply makeseq_nolabel; NoLabelTac
  | [ |- nolabel (makeif _ _ _) ] => apply makeif_nolabel; NoLabelTac
  | [ |- nolabel (make_set _ _) ] => apply make_set_nolabel
  | [ |- nolabel (make_assign _ _) ] => apply make_assign_nolabel
  | [ |- nolabel _ ] => red; intros; simpl; auto
  | [ |- _ /\ _ ] => split; NoLabelTac
  | _ => auto
  end.

Lemma tr_find_label_expr:
  (forall le dst r sl a tmps, tr_expr le dst r sl a tmps -> nolabel_list sl)
/\(forall le rl sl al tmps, tr_exprlist le rl sl al tmps -> nolabel_list sl).
Proof.
(* Goal: and (forall (le : temp_env) (dst : destination) (r : Csyntax.expr) (sl : list statement) (a : expr) (tmps : list ident) (_ : tr_expr le dst r sl a tmps), nolabel_list sl) (forall (le : temp_env) (rl : exprlist) (sl : list statement) (al : list expr) (tmps : list ident) (_ : tr_exprlist le rl sl al tmps), nolabel_list sl) *)
  apply tr_expr_exprlist; intros; NoLabelTac.
(* Goal: nolabel_list (do_set sd (Econst_int Int.one ty)) *)
(* Goal: nolabel_list sl3 *)
(* Goal: nolabel_list sl3 *)
(* Goal: nolabel_list sl2 *)
  apply nolabel_do_set.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_rvalof_nolabel; eauto.
(* Goal: nolabel_list (do_set sd (Econst_int Int.one ty)) *)
(* Goal: nolabel_list sl3 *)
(* Goal: nolabel_list sl3 *)
(* Goal: nolabel_list sl2 *)
  apply nolabel_do_set.
(* Goal: nolabel_list (do_set sd (Econst_int Int.one ty)) *)
(* Goal: nolabel_list sl3 *)
(* Goal: nolabel_list sl3 *)
(* Goal: nolabel_list sl2 *)
  apply nolabel_do_set.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_rvalof_nolabel; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_rvalof_nolabel; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_rvalof_nolabel; eauto.
Qed.

Lemma tr_find_label_top:
  forall e le m dst r sl a tmps,
  tr_top tge e le m dst r sl a tmps -> nolabel_list sl.
Proof.
(* Goal: forall (e : env) (le : temp_env) (m : Mem.mem) (dst : destination) (r : Csyntax.expr) (sl : list statement) (a : expr) (tmps : list ident) (_ : tr_top tge e le m dst r sl a tmps), nolabel_list sl *)
  induction 1; intros; NoLabelTac.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply (proj1 tr_find_label_expr); eauto.
Qed.

Lemma tr_find_label_expression:
  forall r s a, tr_expression r s a -> forall k, find_label lbl s k = None.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H.
  assert (nolabel (makeseq sl)). apply makeseq_nolabel.
  eapply tr_find_label_top with (e := empty_env) (le := PTree.empty val) (m := Mem.empty).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eauto. apply H.
Qed.

Lemma tr_find_label_expr_stmt:
  forall r s, tr_expr_stmt r s -> forall k, find_label lbl s k = None.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H.
  assert (nolabel (makeseq sl)). apply makeseq_nolabel.
  eapply tr_find_label_top with (e := empty_env) (le := PTree.empty val) (m := Mem.empty).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eauto. apply H.
Qed.

Lemma tr_find_label_if:
  forall r s,
  tr_if r Sskip Sbreak s ->
  forall k, find_label lbl s k = None.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H.
  assert (nolabel (makeseq (sl ++ makeif a Sskip Sbreak :: nil))).
  apply makeseq_nolabel.
  apply nolabel_list_app.
  eapply tr_find_label_top with (e := empty_env) (le := PTree.empty val) (m := Mem.empty).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eauto.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  simpl; split; auto. apply makeif_nolabel. red; simpl; auto. red; simpl; auto.
  apply H.
Qed.

Lemma tr_find_label:
  forall s k ts tk
    (TR: tr_stmt s ts)
    (MC: match_cont k tk),
  match Csem.find_label lbl s k with
  | None =>
      find_label lbl ts tk = None
  | Some (s', k') =>
      exists ts', exists tk',
          find_label lbl ts tk = Some (ts', tk')
       /\ tr_stmt s' ts'
       /\ match_cont k' tk'
  end
with tr_find_label_ls:
  forall s k ts tk
    (TR: tr_lblstmts s ts)
    (MC: match_cont k tk),
  match Csem.find_label_ls lbl s k with
  | None =>
      find_label_ls lbl ts tk = None
  | Some (s', k') =>
      exists ts', exists tk',
          find_label_ls lbl ts tk = Some (ts', tk')
       /\ tr_stmt s' ts'
       /\ match_cont k' tk'
  end.
Proof.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  induction s; intros; inversion TR; subst; clear TR; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_find_label_expr_stmt; eauto.
(* seq *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs1 (Csem.Kseq s2 k)); eauto. constructor; eauto.
  destruct (Csem.find_label lbl s1 (Csem.Kseq s2 k)) as [[s' k'] | ].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intro EQ. rewrite EQ. eapply IHs2; eauto.
(* if empty *)
  rename s' into sr.
  rewrite (tr_find_label_expression _ _ _ H3).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* if not empty *)
  rename s' into sr.
  rewrite (tr_find_label_expression _ _ _ H2).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs1 k); eauto.
  destruct (Csem.find_label lbl s1 k) as [[s' k'] | ].
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; intuition.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intro EQ. rewrite EQ. eapply IHs2; eauto.
(* while *)
  rename s' into sr.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite (tr_find_label_if _ _ H1); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs (Kwhile2 e s k)); eauto. econstructor; eauto.
  destruct (Csem.find_label lbl s (Kwhile2 e s k)) as [[s' k'] | ].
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; intuition.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intro EQ. rewrite EQ. auto.
(* dowhile *)
  rename s' into sr.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite (tr_find_label_if _ _ H1); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs (Kdowhile1 e s k)); eauto. econstructor; eauto.
  destruct (Csem.find_label lbl s (Kdowhile1 e s k)) as [[s' k'] | ].
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; intuition.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intro EQ. rewrite EQ. auto.
(* for skip *)
  rename s' into sr.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite (tr_find_label_if _ _ H4); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs3 (Csem.Kfor3 e s2 s3 k)); eauto. econstructor; eauto.
  destruct (Csem.find_label lbl s3 (Csem.Kfor3 e s2 s3 k)) as [[s' k'] | ].
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; intuition.
  intro EQ. rewrite EQ.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs2 (Csem.Kfor4 e s2 s3 k)); eauto. econstructor; eauto.
(* for not skip *)
  rename s' into sr.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite (tr_find_label_if _ _ H3); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs1 (Csem.Kseq (Csyntax.Sfor Csyntax.Sskip e s2 s3) k)); eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto. econstructor; eauto.
  destruct (Csem.find_label lbl s1
               (Csem.Kseq (Csyntax.Sfor Csyntax.Sskip e s2 s3) k)) as [[s' k'] | ].
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; intuition.
  intro EQ; rewrite EQ.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs3 (Csem.Kfor3 e s2 s3 k)); eauto. econstructor; eauto.
  destruct (Csem.find_label lbl s3 (Csem.Kfor3 e s2 s3 k)) as [[s'' k''] | ].
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; intuition.
  intro EQ'. rewrite EQ'.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (IHs2 (Csem.Kfor4 e s2 s3 k)); eauto. econstructor; eauto.
(* break, continue, return 0 *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto. auto.
(* return 1 *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite (tr_find_label_expression _ _ _ H0). auto.
(* switch *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite (tr_find_label_expression _ _ _ H1). apply tr_find_label_ls. auto. constructor; auto.
(* labeled stmt *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct (ident_eq lbl l). exists ts0; exists tk; auto. apply IHs; auto.
(* goto *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.

(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  induction s; intros; inversion TR; subst; clear TR; simpl.
(* nil *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* case *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit (tr_find_label s (Csem.Kseq (Csem.seq_of_labeled_statement s0) k)); eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. apply tr_seq_of_labeled_statement; eauto.
  destruct (Csem.find_label lbl s
    (Csem.Kseq (Csem.seq_of_labeled_statement s0) k)) as [[s' k'] | ].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intros [ts' [tk' [A [B C]]]]. rewrite A. exists ts'; exists tk'; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  intro EQ. rewrite EQ. eapply IHs; eauto.
Qed.

End FIND_LABEL.

(** Anti-stuttering measure *)

(** There are some stuttering steps in the translation:
- The execution of [Sdo a] where [a] is side-effect free,
  which is three transitions in the source:
<<
    Sdo a, k  --->  a, Kdo k ---> rval v, Kdo k ---> Sskip, k
>>
  but the translation, which is [Sskip], makes no transitions.
- The reduction [Ecomma (Eval v) r2 --> r2].
- The reduction [Eparen (Eval v) --> Eval v] in a [For_effects] context.

The following measure decreases for these stuttering steps. *)

Fixpoint esize (a: Csyntax.expr) : nat :=
  match a with
  | Csyntax.Eloc _ _ _ => 1%nat
  | Csyntax.Evar _ _ => 1%nat
  | Csyntax.Ederef r1 _ => S(esize r1)
  | Csyntax.Efield l1 _ _ => S(esize l1)
  | Csyntax.Eval _ _ => O
  | Csyntax.Evalof l1 _ => S(esize l1)
  | Csyntax.Eaddrof l1 _ => S(esize l1)
  | Csyntax.Eunop _ r1 _ => S(esize r1)
  | Csyntax.Ebinop _ r1 r2 _ => S(esize r1 + esize r2)%nat
  | Csyntax.Ecast r1 _ => S(esize r1)
  | Csyntax.Eseqand r1 _ _ => S(esize r1)
  | Csyntax.Eseqor r1 _ _ => S(esize r1)
  | Csyntax.Econdition r1 _ _ _ => S(esize r1)
  | Csyntax.Esizeof _ _ => 1%nat
  | Csyntax.Ealignof _ _ => 1%nat
  | Csyntax.Eassign l1 r2 _ => S(esize l1 + esize r2)%nat
  | Csyntax.Eassignop _ l1 r2 _ _ => S(esize l1 + esize r2)%nat
  | Csyntax.Epostincr _ l1 _ => S(esize l1)
  | Csyntax.Ecomma r1 r2 _ => S(esize r1 + esize r2)%nat
  | Csyntax.Ecall r1 rl2 _ => S(esize r1 + esizelist rl2)%nat
  | Csyntax.Ebuiltin ef _ rl _ => S(esizelist rl)%nat
  | Csyntax.Eparen r1 _ _ => S(esize r1)
  end

with esizelist (el: Csyntax.exprlist) : nat :=
  match el with
  | Csyntax.Enil => O
  | Csyntax.Econs r1 rl2 => (esize r1 + esizelist rl2)%nat
  end.

Definition measure (st: Csem.state) : nat :=
  match st with
  | Csem.ExprState _ r _ _ _ => (esize r + 1)%nat
  | Csem.State _ Csyntax.Sskip _ _ _ => 0%nat
  | Csem.State _ (Csyntax.Sdo r) _ _ _ => (esize r + 2)%nat
  | Csem.State _ (Csyntax.Sifthenelse r _ _) _ _ _ => (esize r + 2)%nat
  | _ => 0%nat
  end.

Lemma leftcontext_size:
  forall from to C,
  leftcontext from to C ->
  forall e1 e2,
  (esize e1 < esize e2)%nat ->
  (esize (C e1) < esize (C e2))%nat
with leftcontextlist_size:
  forall from C,
  leftcontextlist from C ->
  forall e1 e2,
  (esize e1 < esize e2)%nat ->
  (esizelist (C e1) < esizelist (C e2))%nat.
Proof.
  induction 1; intros; simpl; auto with arith.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit leftcontextlist_size; eauto. auto with arith.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit leftcontextlist_size; eauto. auto with arith.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; intros; simpl; auto with arith. exploit leftcontext_size; eauto. auto with arith.
Qed.

(** Forward simulation for expressions. *)

Lemma tr_val_gen:
  forall le dst v ty a tmp,
  typeof a = ty ->
  (forall tge e le' m,
      (forall id, In id tmp -> le'!id = le!id) ->
      eval_expr tge e le' m a v) ->
  tr_expr le dst (Csyntax.Eval v ty) (final dst a) a tmp.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. destruct dst; simpl; econstructor; auto.
Qed.

Lemma estep_simulation:
  forall S1 t S2, Cstrategy.estep ge S1 t S2 ->
  forall S1' (MS: match_states S1 S1'),
  exists S2',
     (plus step1 tge S1' t S2' \/
       (star step1 tge S1' t S2' /\ measure S2 < measure S1)%nat)
  /\ match_states S2 S2'.
Proof.
  induction 1; intros; inv MS.
(* expr *)
  assert (tr_expr le dest r sl a tmps).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    inv H9. contradiction. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. destruct dest.
  (* for val *)
  intros [SL1 [TY1 EV1]]. subst sl.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  right; split. apply star_refl. destruct r; simpl; (contradiction || omega).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  instantiate (1 := tmps). apply tr_top_val_val; auto.
  (* for effects *)
  intros SL1. subst sl.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  right; split. apply star_refl. destruct r; simpl; (contradiction || omega).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  instantiate (1 := tmps). apply tr_top_base. constructor.
  (* for set *)
  inv H10.
(* rval volatile *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H11.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  inv P. inv H2. inv H7; try congruence.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  exploit tr_simple_lvalue; eauto. intros [SL [TY EV]]. subst sl0; simpl.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. eapply plus_two. constructor. eapply step_make_set; eauto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
  change (final dst' (Etempvar t0 (Csyntax.typeof l)) ++ sl2) with (nil ++ (final dst' (Etempvar t0 (Csyntax.typeof l)) ++ sl2)).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_val_gen. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. constructor. rewrite H5; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. red; intros; subst; elim H5; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
(* seqand true *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_paren_val with (a1 := a2); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_monotone with tmp2; eauto. auto. auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_paren_effects with (a1 := a2); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_monotone with tmp2; eauto. auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_paren_set with (a1 := a2) (t := sd_temp sd); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_monotone with tmp2; eauto. auto. auto.
(* seqand false *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  apply star_one. constructor. constructor. reflexivity. reflexivity.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  change sl2 with (nil ++ sl2). apply S. econstructor; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. constructor. rewrite H2. apply PTree.gss. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  apply step_makeif with (b := false) (v1 := v); auto. congruence.
  reflexivity.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  change sl2 with (nil ++ sl2). apply S. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply S. econstructor; eauto. intros. constructor. auto. auto.
(* seqor true *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  apply star_one. constructor. constructor. reflexivity. reflexivity.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  change sl2 with (nil ++ sl2). apply S. econstructor; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. constructor. rewrite H2. apply PTree.gss. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  apply step_makeif with (b := true) (v1 := v); auto. congruence.
  reflexivity.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  change sl2 with (nil ++ sl2). apply S. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply S. econstructor; eauto. intros. constructor. auto. auto.
(* seqand false *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for val *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_paren_val with (a1 := a2); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_monotone with tmp2; eauto. auto. auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_paren_effects with (a1 := a2); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_monotone with tmp2; eauto. auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. apply tr_paren_set with (a1 := a2) (t := sd_temp sd); auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_expr_monotone with tmp2; eauto. auto. auto.
(* condition *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist. destruct b.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. econstructor; eauto. apply tr_expr_monotone with tmp2; eauto. auto. auto.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq. reflexivity. reflexivity.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply match_exprstates; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. econstructor; eauto. apply tr_expr_monotone with tmp3; eauto. auto. auto.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist. destruct b.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq.
  reflexivity. traceEq.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eauto. apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto. apply tr_expr_monotone with tmp2; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq.
  reflexivity. traceEq.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eauto. apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto. apply tr_expr_monotone with tmp3; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
  (* for set *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL [TY EV]].
  subst sl0; simpl Kseqlist. destruct b.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := true) (v1 := v); auto. congruence.
  apply push_seq.
  reflexivity. traceEq.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eauto. apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto. apply tr_expr_monotone with tmp2; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  eapply star_trans. apply step_makeif with (b := false) (v1 := v); auto. congruence.
  apply push_seq.
  reflexivity. traceEq.
  rewrite <- Kseqlist_app.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eauto. apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto. apply tr_expr_monotone with tmp3; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* assign *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H12.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: final_state (Returnstate (Vint r) tk m) r *)
  inv P. inv H4.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL2 [TY2 EV2]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply star_one. eapply step_make_assign; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite <- TY2; eauto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. auto. change sl2 with (nil ++ sl2). apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. auto. auto. auto.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL2 [TY2 EV2]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    eapply tr_expr_invariant with (le' := PTree.set t0 v' le). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
    intros. apply PTree.gso. intuition congruence.
  intros [SL1 [TY1 EV1]].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_left. constructor. econstructor. eauto. rewrite <- TY2; eauto. 
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  eapply star_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply star_one. eapply step_make_assign; eauto.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  constructor. apply PTree.gss. simpl. eapply cast_idempotent; eauto. 
  reflexivity. reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. auto. apply S.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply tr_val_gen. auto. intros. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H4; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. intuition congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* assignop *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H15.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H6.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit step_tr_rvalof; eauto. intros [le' [EXEC [EV3 [TY3 INV]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue. eauto. eapply tr_expr_invariant with (le := le) (le' := le'). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply INV. NOTIN. intros [? [? EV1']].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue. eauto. eapply tr_expr_invariant with (le := le) (le' := le'). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply INV. NOTIN. simpl. intros [SL2 [TY2 EV2]].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. eapply star_plus_trans. rewrite app_ass. rewrite Kseqlist_app. eexact EXEC.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  eapply plus_two. simpl. econstructor. eapply step_make_assign; eauto.
    econstructor. eexact EV3. eexact EV2.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    rewrite TY3; rewrite <- TY1; rewrite <- TY2; rewrite comp_env_preserved; auto.
  reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. auto. change sl2 with (nil ++ sl2). apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. auto. auto. auto.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit step_tr_rvalof; eauto. intros [le' [EXEC [EV3 [TY3 INV]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue. eauto. eapply tr_expr_invariant with (le := le) (le' := le'). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply INV. NOTIN. intros [? [? EV1']].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue. eauto. eapply tr_expr_invariant with (le := le) (le' := le'). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply INV. NOTIN. simpl. intros [SL2 [TY2 EV2]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    eapply tr_expr_invariant with (le := le) (le' := PTree.set t v4 le'). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
    intros. rewrite PTree.gso. apply INV. NOTIN. intuition congruence.
  intros [? [? EV1'']].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. rewrite app_ass. rewrite Kseqlist_app.
  eapply star_plus_trans. eexact EXEC.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. eapply plus_four. econstructor. econstructor.
    econstructor. econstructor. eexact EV3. eexact EV2.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    rewrite TY3; rewrite <- TY1; rewrite <- TY2; rewrite comp_env_preserved; eauto.
    eassumption.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eapply step_make_assign; eauto.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
    constructor. apply PTree.gss. simpl. eapply cast_idempotent; eauto.
    reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. auto. apply S.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply tr_val_gen. auto. intros. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H10; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. rewrite PTree.gso. apply INV.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  red; intros; elim H10; auto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  intuition congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* assignop stuck *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H12.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: final_state (Returnstate (Vint r) tk m) r *)
  inv P. inv H4.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL2 [TY2 EV2]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit step_tr_rvalof; eauto. intros [le' [EXEC [EV3 [TY3 INV]]]].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  right; split. rewrite app_ass. rewrite Kseqlist_app. eexact EXEC.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. omega.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL2 [TY2 EV2]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit step_tr_rvalof; eauto. intros [le' [EXEC [EV3 [TY3 INV]]]].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  right; split. rewrite app_ass. rewrite Kseqlist_app. eexact EXEC.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. omega.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
(* postincr *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H14.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H5.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit step_tr_rvalof; eauto. intros [le' [EXEC [EV3 [TY3 INV]]]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue. eauto. eapply tr_expr_invariant with (le := le) (le' := le'). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply INV. NOTIN. intros [? [? EV1']].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. rewrite app_ass; rewrite Kseqlist_app.
  eapply star_plus_trans. eexact EXEC.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  eapply plus_two. simpl. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply step_make_assign; eauto.
  unfold transl_incrdecr. destruct id; simpl in H2.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eauto. constructor. rewrite TY3; rewrite <- TY1; rewrite comp_env_preserved. simpl; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. eauto. constructor. rewrite TY3; rewrite <- TY1; rewrite comp_env_preserved. simpl; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct id; auto.
  reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. auto. change sl2 with (nil ++ sl2). apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. auto. auto. auto.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
    eapply tr_expr_invariant with (le' := PTree.set t v1 le). eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
    intros. apply PTree.gso. intuition congruence.
  intros [SL2 [TY2 EV2]].
  subst; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_four. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply step_make_set; eauto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply step_make_assign; eauto.
  unfold transl_incrdecr. destruct id; simpl in H2.
  econstructor. constructor. apply PTree.gss. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite comp_env_preserved; simpl; eauto.
  econstructor. constructor. apply PTree.gss. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite comp_env_preserved; simpl; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct id; auto.
  traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. auto. apply S.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply tr_val_gen. auto. intros. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H5; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. intuition congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* postincr stuck *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H11.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H3.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit step_tr_rvalof; eauto. intros [le' [EXEC [EV3 [TY3 INV]]]].
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  subst. simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  right; split. rewrite app_ass; rewrite Kseqlist_app. eexact EXEC.
  simpl; omega.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_lvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  subst. simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. eapply plus_two. constructor. eapply step_make_set; eauto.
  traceEq.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
(* comma *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv P. inv H1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. simpl; intro SL1.
  subst sl0; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  right; split. apply star_refl. simpl. apply plus_lt_compat_r.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  apply (leftcontext_size _ _ _ H). simpl. omega.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply tr_expr_monotone; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto. auto.
(* paren *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [b [SL1 [TY1 EV1]]].
  subst sl1; simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor. apply star_one.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor. econstructor; eauto. rewrite <- TY1; eauto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
  change sl2 with (final For_val (Etempvar t (Csyntax.typeof r)) ++ sl2). apply S.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  constructor. auto. intros. constructor. rewrite H2; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. intuition congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
  (* for effects *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  right; split. apply star_refl. simpl. apply plus_lt_compat_r.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  apply (leftcontext_size _ _ _ H). simpl. omega.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  exploit tr_simple_rvalue; eauto. simpl. intros A. subst sl1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. constructor; auto. auto. auto.
  (* for set *)
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  exploit tr_simple_rvalue; eauto. simpl. intros [b [SL1 [TY1 EV1]]]. subst sl1.
  simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. eapply plus_left. constructor. apply star_one. econstructor. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite <- TY1; eauto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply S. constructor; auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. constructor. rewrite H2. apply PTree.gss. auto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.

(* call *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H12.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H5.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_exprlist; eauto. intros [SL2 EV2].
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  subst. simpl Kseqlist.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit functions_translated; eauto. intros [tfd [J K]].
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.  apply star_one.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. rewrite <- TY1; eauto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  exploit type_of_fundef_preserved; eauto. congruence.
  traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. econstructor; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. change sl2 with (nil ++ sl2). apply S.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. auto. auto.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_rvalue; eauto. intros [SL1 [TY1 EV1]].
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_exprlist; eauto. intros [SL2 EV2].
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  subst. simpl Kseqlist.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit functions_translated; eauto. intros [tfd [J K]].
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.  apply star_one.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. rewrite <- TY1; eauto.
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  exploit type_of_fundef_preserved; eauto. congruence.
  traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. econstructor; eauto.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply S.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  destruct dst'; constructor.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  auto. intros. constructor. rewrite H5; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  auto. intros. constructor. rewrite H5; auto. apply PTree.gss.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. apply PTree.gso. intuition congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.

(* builtin *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_leftcontext; eauto. clear H9.
  intros [dst' [sl1 [sl2 [a' [tmp' [P [Q [R S]]]]]]]].
  inv P. inv H2.
  (* for effects *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_exprlist; eauto. intros [SL EV].
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  subst. simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.  apply star_one.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply external_call_symbols_preserved; eauto. apply senv_preserved.
  traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  change sl2 with (nil ++ sl2). apply S. constructor. simpl; auto. auto.
  (* for value *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_simple_exprlist; eauto. intros [SL EV].
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  subst. simpl Kseqlist.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor. apply star_one.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply external_call_symbols_preserved; eauto. apply senv_preserved.
  traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
  change sl2 with (nil ++ sl2). apply S.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  apply tr_val_gen. auto. intros. constructor. rewrite H2; auto. simpl. apply PTree.gss.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  intros; simpl. apply PTree.gso. intuition congruence.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  auto.
Qed.

(** Forward simulation for statements. *)

Lemma tr_top_val_for_val_inv:
  forall e le m v ty sl a tmps,
  tr_top tge e le m For_val (Csyntax.Eval v ty) sl a tmps ->
  sl = nil /\ typeof a = ty /\ eval_expr tge e le m a v.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H. auto. inv H0. auto.
Qed.

Lemma alloc_variables_preserved:
  forall e m params e' m',
  Csem.alloc_variables ge e m params e' m' ->
  alloc_variables tge e m params e' m'.
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; econstructor; eauto. rewrite comp_env_preserved; auto.
Qed.

Lemma bind_parameters_preserved:
  forall e m params args m',
  Csem.bind_parameters ge e m params args m' ->
  bind_parameters tge e m params args m'.
Proof.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  induction 1; econstructor; eauto. inv H0.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- eapply assign_loc_value; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- inv H4. eapply assign_loc_value; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
- rewrite <- comp_env_preserved in *. eapply assign_loc_copy; eauto.
Qed.

Lemma blocks_of_env_preserved:
  forall e, blocks_of_env tge e = Csem.blocks_of_env ge e.
Proof.
(* Goal: forall e : env, @eq (list (prod (prod block Z) Z)) (blocks_of_env tge e) (Csem.blocks_of_env ge e) *)
  intros; unfold blocks_of_env, Csem.blocks_of_env.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (block_of_binding tge) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (Csem.block_of_binding ge) (@PTree.elements (prod block type) e)) *)
  unfold block_of_binding, Csem.block_of_binding.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite comp_env_preserved. auto.
Qed.

Lemma sstep_simulation:
  forall S1 t S2, Csem.sstep ge S1 t S2 ->
  forall S1' (MS: match_states S1 S1'),
  exists S2',
     (plus step1 tge S1' t S2' \/
       (star step1 tge S1' t S2' /\ measure S2 < measure S1)%nat)
  /\ match_states S2 S2'.
Proof.
  induction 1; intros; inv MS.
(* do 1 *)
(* Goal: final_state S' r *)
  inv H6. inv H0.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  right; split. apply push_seq.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  simpl. omega.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor. auto.
(* do 2 *)
(* Goal: final_state S' r *)
  inv H7. inv H6. inv H.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  right; split. apply star_refl. simpl. omega.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor.

(* seq *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H6. econstructor; split. left. apply plus_one. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor; auto.
(* skip seq *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H6; inv H7. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. apply plus_one; constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* continue seq *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H6; inv H7. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. apply plus_one; constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor.
(* break seq *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H6; inv H7. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. apply plus_one; constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor.
(* ifthenelse *)
  inv H6.
(* ifthenelse empty *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H3. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor. apply push_seq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* ifthenelse non empty *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H2. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor. apply push_seq. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. econstructor; eauto.
(* ifthenelse *)
  inv H8.
(* ifthenelse empty *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  econstructor; split; simpl.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  right. destruct b; econstructor; eauto.
  eapply star_left. apply step_skip_seq. econstructor. traceEq.
  eapply star_left. apply step_skip_seq. econstructor. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct b; econstructor; eauto. econstructor; eauto. econstructor; eauto.
  (* ifthenelse non empty *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_two. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply step_ifthenelse with (v1 := v) (b := b); auto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  destruct b; econstructor; eauto.
(* while *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H6. inv H1. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. eapply plus_left. constructor.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  eapply star_left. constructor.
  apply push_seq.
  reflexivity. traceEq. rewrite Kseqlist_app.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  econstructor; eauto. simpl.  econstructor; eauto. econstructor; eauto.
(* while false *)
  inv H8.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  left. simpl. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_trans. apply step_makeif with (v1 := v) (b := false); auto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  eapply star_two. constructor. apply step_break_loop1.
  reflexivity. reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.
(* while true *)
  inv H8.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  left. simpl. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_right. apply step_makeif with (v1 := v) (b := true); auto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
  reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor; auto.
(* skip-or-continue while *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  assert (ts = Sskip \/ ts = Scontinue). destruct H; subst s0; inv H7; auto.
  inv H8.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. eapply plus_two. apply step_skip_or_continue_loop1; auto.
  apply step_skip_loop2. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor; auto.
(* break while *)
  inv H6. inv H7.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. apply plus_one. apply step_break_loop1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.

(* dowhile *)
  inv H6.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. apply plus_one. apply step_loop.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor; auto.
(* skip_or_continue dowhile *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  assert (ts = Sskip \/ ts = Scontinue). destruct H; subst s0; inv H7; auto.
(* Goal: final_state (Returnstate (Vint r) tk m) r *)
  inv H8. inv H4.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. eapply plus_left. apply step_skip_or_continue_loop1. auto.
  apply push_seq.
  traceEq.
  rewrite Kseqlist_app.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  econstructor; eauto. simpl. econstructor; auto. econstructor; eauto.
(* dowhile false *)
  inv H8.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  left. simpl. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_right. apply step_makeif with (v1 := v) (b := false); auto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
  reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.
(* dowhile true *)
  inv H8.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  left. simpl. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_right. apply step_makeif with (v1 := v) (b := true); auto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
  reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor; auto.
(* break dowhile *)
  inv H6. inv H7.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. apply plus_one. apply step_break_loop1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.

(* for start *)
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  inv H7. congruence.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left; apply plus_one. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor; auto. econstructor; eauto.
(* for *)
(* Goal: @eq (option val) (sem_cast v' (typeof a1) ty m) (@Some val v) *)
  inv H6; try congruence. inv H2.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. eapply plus_left. apply step_loop.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  eapply star_left. constructor. apply push_seq.
  reflexivity. traceEq.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  rewrite Kseqlist_app. econstructor; eauto. simpl. constructor; auto. econstructor; eauto.
(* for false *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  inv H8. exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  left. simpl. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_trans. apply step_makeif with (v1 := v) (b := false); auto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  eapply star_two. constructor. apply step_break_loop1.
  reflexivity. reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.
(* for true *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  inv H8. exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq composite_env (genv_cenv tge) (Csem.genv_cenv ge) *)
  left. simpl. eapply plus_left. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply star_right. apply step_makeif with (v1 := v) (b := true); auto.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  constructor.
  reflexivity. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor; auto.
(* skip_or_continue for3 *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  assert (ts = Sskip \/ ts = Scontinue). destruct H; subst x; inv H7; auto.
  inv H8.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. apply plus_one. apply step_skip_or_continue_loop1. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. econstructor; auto.
(* break for3 *)
  inv H6. inv H7.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left. apply plus_one. apply step_break_loop1.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor.
(* skip for4 *)
  inv H6. inv H7.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left. apply plus_one. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor; auto.


(* return none *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H7. econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. apply plus_one. econstructor; eauto. rewrite blocks_of_env_preserved; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. apply match_cont_call; auto.
(* return some 1 *)
(* Goal: final_state S' r *)
  inv H6. inv H0. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left; eapply plus_left. constructor. apply push_seq. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor. auto.
(* return some 2 *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  inv H9. exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. eapply plus_two. constructor. econstructor. eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  erewrite function_return_preserved; eauto. rewrite blocks_of_env_preserved; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eauto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. apply match_cont_call; auto.
(* skip return *)
  inv H8.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  assert (is_call_cont tk). inv H9; simpl in *; auto.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. apply plus_one. apply step_skip_call; eauto. rewrite blocks_of_env_preserved; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. auto.

(* switch *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst a2))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eaddrof' a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Eunop op a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (@app statement sl2 (final dst (Ebinop op a1 a2 ty)))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 (final dst (Ecast a1 ty))) (@nil statement) *)
(* Goal: @eq (list statement) (@app statement sl1 sl2) (@nil statement) *)
  inv H6. inv H1.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left; eapply plus_left. constructor. apply push_seq. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto. constructor; auto.
(* expr switch *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  inv H8. exploit tr_top_val_for_val_inv; eauto. intros [A [B C]]. subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left; eapply plus_two. constructor. econstructor; eauto. traceEq.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply tr_seq_of_labeled_statement. apply tr_select_switch. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto.

(* skip-or-break switch *)
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  assert (ts = Sskip \/ ts = Sbreak). destruct H; subst x; inv H7; auto.
  inv H8.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left; apply plus_one. apply step_skip_break_switch. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.

(* continue switch *)
  inv H6. inv H7.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left; apply plus_one. apply step_continue_switch.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto. constructor.

(* label *)
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  inv H6. econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left; apply plus_one. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto.

(* goto *)
  inv H7.
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  inversion H6; subst.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit tr_find_label. eauto. apply match_cont_call. eauto.
(* Goal: @eq (option (prod statement cont)) match find_label lbl s (Kseq a k) with | Some sk => @Some (prod statement cont) sk | None => find_label lbl a k end (@None (prod statement cont)) *)
(* Goal: forall (sl : list statement) (_ : nolabel_list sl), nolabel (makeseq sl) *)
  instantiate (1 := lbl). rewrite H.
  intros [ts' [tk' [P [Q R]]]].
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left. apply plus_one. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.

(* internal function *)
(* Goal: match sem_cast v0 (typeof a) ty Mem.empty with | Some v' => @eq val v' v | None => True end *)
(* Goal: match eval_simpl_expr a with | Some v' => @eq val v' v | None => True end *)
  inv H7. inversion H3; subst.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  left; apply plus_one. eapply step_internal_function. econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H6; rewrite H7; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H6; rewrite H7. eapply alloc_variables_preserved; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite H6. eapply bind_parameters_preserved; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto.

(* external function *)
  inv H5.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  left; apply plus_one. econstructor; eauto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply external_call_symbols_preserved; eauto. apply senv_preserved.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor; auto.

(* return *)
  inv H3.
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
(* Goal: final_state (Returnstate (Vint r) Kstop m) r *)
  left; apply plus_one. constructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  econstructor; eauto.
Qed.

(** Semantic preservation *)

Theorem simulation:
  forall S1 t S2, Cstrategy.step ge S1 t S2 ->
  forall S1' (MS: match_states S1 S1'),
  exists S2',
     (plus step1 tge S1' t S2' \/
       (star step1 tge S1' t S2' /\ measure S2 < measure S1)%nat)
  /\ match_states S2 S2'.
Proof.
(* Goal: forall (S1 : Csem.state) (t : trace) (S2 : Csem.state) (_ : Cstrategy.step ge S1 t S2) (S1' : state) (_ : match_states S1 S1'), @ex state (fun S2' : state => and (or (@plus genv state step1 tge S1' t S2') (and (@star genv state step1 tge S1' t S2') (lt (measure S2) (measure S1)))) (match_states S2 S2')) *)
  intros S1 t S2 STEP. destruct STEP.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply estep_simulation; auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  apply sstep_simulation; auto.
Qed.

Lemma transl_initial_states:
  forall S,
  Csem.initial_state prog S ->
  exists S', Clight.initial_state tprog S' /\ match_states S S'.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  exploit function_ptr_translated; eauto. intros [tf [FIND TR]].
(* Goal: and (@eq (list statement) (@app statement sl1 sl2) (@nil statement)) (eval_exprlist tge e le m (@cons expr a1 al2) (Tcons ty tyl0) (@cons val v vl0)) *)
  econstructor; split.
  econstructor.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  eapply (Genv.init_mem_match (proj1 TRANSL)); eauto.
  replace (prog_main tprog) with (prog_main prog).
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite symbols_preserved. eauto. 
(* Goal: @eq composite_env (@prog_comp_env function tprog) (@prog_comp_env Csyntax.function prog) *)
  destruct TRANSL. destruct H as (A & B & C). simpl in B. auto. 
  eexact FIND.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  rewrite <- H3. apply type_of_fundef_preserved. auto.
(* Goal: @eq (list (prod (prod block Z) Z)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) (@map (prod ident (prod block type)) (prod (prod block Z) Z) (fun id_b_ty : prod ident (prod block type) => let (_, p) := id_b_ty in let (b, ty) := p in @pair (prod block Z) Z (@pair block Z b Z0) (sizeof (Csem.genv_cenv ge) ty)) (@PTree.elements (prod block type) e)) *)
  constructor. auto. constructor.
Qed.

Lemma transl_final_states:
  forall S S' r,
  match_states S S' -> Csem.final_state S r -> Clight.final_state S' r.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  intros. inv H0. inv H. inv H4. constructor.
Qed.

Theorem transl_program_correct:
  forward_simulation (Cstrategy.semantics prog) (Clight.semantics1 tprog).
Proof.
  eapply forward_simulation_star_wf with (order := ltof _ measure).
(* Goal: Senv.equiv (@Genv.to_senv Csyntax.fundef type (Csem.genv_genv ge)) (@Genv.to_senv fundef type (genv_genv tge)) *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  eapply senv_preserved.
  eexact transl_initial_states.
  eexact transl_final_states.
  apply well_founded_ltof.
  exact simulation.
Qed.

End PRESERVATION.

(** ** Commutation with linking *)

Instance TransfSimplExprLink : TransfLink match_prog.
Proof.
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
  red; intros. eapply Ctypes.link_match_program; eauto. 
(* Goal: forall (S : Csem.state) (S' : state) (r : Int.int) (_ : match_states S S') (_ : Csem.final_state S r), final_state S' r *)
- intros.
Local Transparent Linker_fundef.
  simpl in *; unfold link_fundef in *. inv H3; inv H4; try discriminate.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  destruct ef; inv H2. exists (Internal tf); split; auto. constructor; auto.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  destruct ef; inv H2. exists (Internal tf); split; auto. constructor; auto.
  destruct (external_function_eq ef ef0 && typelist_eq targs targs0 &&
            type_eq tres tres0 && calling_convention_eq cconv cconv0); inv H2.
(* Goal: and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs v m') *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs v t m' | None => and (@eq trace t E0) (assign_loc (genv_cenv tge) ty m b ofs v m') end *)
(* Goal: match (if type_is_volatile ty then match access_mode ty with | By_value chunk => @Some memory_chunk chunk | By_reference => @None memory_chunk | By_copy => @None memory_chunk | By_nothing => @None memory_chunk end else @None memory_chunk) with | Some chunk => volatile_store (@Genv.to_senv fundef type (genv_genv tge)) chunk m b ofs (Vptr b' ofs') E0 m' | None => and (@eq trace E0 E0) (assign_loc (genv_cenv tge) ty m b ofs (Vptr b' ofs') m') end *)
  exists (External ef targs tres cconv); split; auto. constructor.
Qed.
