Admitted.

(* Specifications: *)
Lemma gss_restrPermMap:
forall Sems Semt hb i (tp: t_ (ThreadPool hb Sems Semt)) m c
(cnti: containsThread tp i)
(COMPT: HybridMachine.mem_compatible hb Sems Semt
(updThread cnti c (getCurPerm m, snd (getThreadR cnti))) m),
mem_equiv (restrPermMap (FST (COMPT i cnti))) m.
Lemma concur_stable_thread_step_target:
forall  cd f (c1:C1) m1 c2 m2 f' ts1' m1' ts2' m2' tid,
forall (Htid1: containsThread c1 tid)
(Htid2: containsThread c2 tid)
(LT : (tid < hb')%nat)
(Hcmpt1: HybridMachine.mem_compatible hb1 Sems Semt c1 m1)
(Hcmpt2: HybridMachine.mem_compatible hb2 Sems Semt c2 m2),
concur_match cd f c1 m1 c2 m2 ->
is_ext f (Mem.nextblock m1) f' (Mem.nextblock m2) ->
semantics.mem_step (restrPermMap (FST (Hcmpt1 _ Htid1))) m1' ->
semantics.mem_step (restrPermMap (FST (Hcmpt2 _ Htid2))) m2' ->
match_self (code_inject Asm_self_simulation) f' ts1' m1' ts2' m2' ->
concur_match cd f'
(updThread Htid1  (Krun (TState _ _ ts1')) (getCurPerm m1', (snd (getThreadR Htid1))))  m1'
(updThread Htid2 (Krun (TState _ _ ts2')) (getCurPerm m2', (snd (getThreadR Htid2)))) m2'.
Lemma Asm_mem_semantics:
forall genv c1 m1 t c2 m2
(Astep: Asm.step genv (Asm.State c1 m1) t (Asm.State c2 m2)),
semantics.mem_step m1 m2.
Lemma hybrid_thread_diagram:
forall (U0 : list nat) (st1 : C1) (m1 : mem) (st1' : C1) (m1' : mem),
machine_semantics.thread_step (HCSem Sems Semt hb1 U) genv U0 st1 m1 st1' m1' ->
forall cd (st2 : C2) (mu : meminj) (m2 : mem),
concur_match cd mu st1 m1 st2 m2 ->
exists (st2' : C2) (m2' : mem) cd' (mu' : meminj),
concur_match cd' mu' st1' m1' st2' m2' /\
(machine_semantics_lemmas.thread_step_plus
(HCSem Sems Semt hb2 U) genv U0 st2 m2 st2' m2' \/
machine_semantics_lemmas.thread_step_star
(HCSem Sems Semt hb2 U) genv U0 st2 m2 st2' m2'
/\ option_compiler_order cd' cd).
Lemma thread_step_plus_from_corestep:
forall (m : option mem) (tge : ClightSemanticsForMachines.G * Asm.genv)
(U : list nat) (st1 : t) (m1 : mem) (Htid : containsThread st1 hb)
(st2 : t) (mu : meminj) (m2 : mem) (cd0 : compiler_index)
(H0 : concur_match (Some cd0) mu st1 m1 st2 m2) (code2 : Asm.state)
(s4' : Smallstep.state (Asm.part_semantics Asm_g))
(m4' : mem),
corestep_plus (Asm_core.Asm_core_sem Asm_g) code2
(restrPermMap
(proj1 ((memcompat2 H0) hb (contains12 H0 Htid))))
s4' m4' ->
forall Htid' : containsThread st2 hb,
machine_semantics_lemmas.thread_step_plus (HybConcSem (Some (S hb)) m) tge U st2
m2
(updThread Htid' (Krun (TState Clight.state Asm.state s4'))
(getCurPerm m4', snd (getThreadR Htid'))) m4'.
(** *Need an extra fact about simulations*)
Lemma step2corestep_plus:
forall (s1 s2: Smallstep.state (Asm.part_semantics Asm_g)) m1 t,
Smallstep.plus
(Asm.step (Genv.globalenv Asm_program))
(Smallstep.set_mem s1 m1) t s2 ->
(corestep_plus (Asm_core.Asm_core_sem Asm_g))
s1 m1 s2 (Smallstep.get_mem s2).
Lemma trivial_asm_simulation:
(HybridMachine_simulation
(HybConcSem None (Genv.init_mem Asm_program))
(X86Context.AsmConcurSem
(the_program:=Asm_program)
(Hsafe:=Asm_genv_safe)
(Genv.init_mem Asm_program))).
Lemma semax_assign: forall P x y v,
semax (y =# v && (own x * TT) && subst x (Some(pfullshare, v)) P) (Assign x y) P.
Lemma semax_load: forall x y p v v0 sh sh',
semax (^stk env_mapsto x Share.top v0 * ^stk (env_mapsto y sh p) *
^hp env_mapsto p sh' v)
(Load x y)
(^stk env_mapsto x Share.top v * ^stk (env_mapsto y sh p) *
^hp env_mapsto p sh' v).
Lemma semax_store: forall x y p v v0 sh sh',
semax (^stk env_mapsto x sh p * ^stk (env_mapsto y sh' v) *
^hp env_mapsto p Share.top v0)
(Store x y)
(^stk env_mapsto x sh p * ^stk (env_mapsto y sh' v) *
^hp env_mapsto p Share.top v).
Lemma semax_seq: forall P c1 Q c2 R,
semax P c1 Q -> semax Q c2 R -> semax P (Seq c1 c2) R.
Lemma frame: forall F P c Q,
semax P c Q -> semax (P * F) c (Q * F).
Lemma PreImage_Full: forall  {A B: Type} {sA: SigmaAlgebra A} {sB: SigmaAlgebra B} (f: MeasurableFunction A B),
Same_MSet (PreImage_MSet f (Full_MSet B)) (Full_MSet A).
Lemma varspecs_sub_refl: forall vl, varspecs_sub vl vl = true.
Lemma funspecs_sub_refl: forall g, funspecs_sub g g.
Ltac next_module H :=
first
[ apply semax_func_cons; [ reflexivity | apply H | ]
| eapply semax_func_app;
[apply H | | reflexivity | reflexivity
|   try apply varspecs_sub_refl; try reflexivity
|   try apply varspecs_sub_refl; try reflexivity
|   try apply funspecs_sub_refl; try (repeat split; simpl; auto)
|   try apply funspecs_sub_refl; try (repeat split; simpl; auto)
]
].
Lemma log3range: forall j,
1 <= j < 256 ->
1 <= log3 (Int.repr j) < 256.
Lemma mod_range: forall i m,
0 <= i ->
0 < m ->
0 <= Int.unsigned (Int.mods (Int.repr i) (Int.repr m)) < m.
Lemma pow2_range: forall e,
0 <= e ->
0 <= Int.unsigned (pow2 e) < 256.
Lemma pow3_range: forall e,
0 <= e ->
0 <= Int.unsigned (pow3 e) < 256.
Lemma pow3_inj: forall (i j : Z),
pow3 i = pow3 j -> Int.eqmod 255 i j.
Lemma invert_pow3: forall i,
1 <= i < 256 ->
exists j, 1 <= j < 256 /\ i = (Int.unsigned (pow3 j)).
Lemma times3_equiv: forall b,
0 <= Int.unsigned b < 256 ->
times3 b = ff_mult (Int.repr 3) b.
Lemma Znth_partially_filled: forall (i j n: Z) (f: Z -> int),
0 <= i -> i < j -> j <= n ->
Znth i (partially_filled j n f) = Vint (f i).
Lemma byte1_word_to_int: forall b0 b1 b2 b3,
byte1 (word_to_int (b0, b1, b2, b3)) = Int.unsigned b1.
Lemma byte2_word_to_int: forall b0 b1 b2 b3,
byte2 (word_to_int (b0, b1, b2, b3)) = Int.unsigned b2.
Lemma byte3_word_to_int: forall b0 b1 b2 b3,
byte3 (word_to_int (b0, b1, b2, b3)) = Int.unsigned b3.
Lemma xor_byte0_with_FSb: forall b0 b1 b2 b3 i,
Int.xor (word_to_int (b0, b1, b2, b3)) (Znth i tablesLL.FSb)
= word_to_int ((Int.xor b0 (Znth i tablesLL.FSb)), b1, b2, b3).
Lemma xor_byte1_with_FSb: forall b0 b1 b2 b3 i,
Int.xor (word_to_int (b0, b1, b2, b3)) (Int.shl (Znth i tablesLL.FSb) (Int.repr 8))
= word_to_int (b0, (Int.xor b1 (Znth i tablesLL.FSb)), b2, b3).
Lemma xor_byte2_with_FSb: forall b0 b1 b2 b3 i,
Int.xor (word_to_int (b0, b1, b2, b3)) (Int.shl (Znth i tablesLL.FSb) (Int.repr 16))
= word_to_int (b0, b1, (Int.xor b2 (Znth i tablesLL.FSb)), b3).
Lemma xor_byte3_with_FSb: forall b0 b1 b2 b3 i,
Int.xor (word_to_int (b0, b1, b2, b3)) (Int.shl (Znth i tablesLL.FSb) (Int.repr 24))
= word_to_int (b0, b1, b2, (Int.xor b3 (Znth i tablesLL.FSb))).
Lemma equiv_sbox: forall b,
Znth (Int.unsigned b) tablesLL.FSb = look_sbox b.
Lemma xor_word_to_int: forall a0 a1 a2 a3 b0 b1 b2 b3,
Int.xor (word_to_int (a0, a1, a2, a3)) (word_to_int (b0, b1, b2, b3))
= word_to_int ((Int.xor a0 b0), (Int.xor a1 b1), (Int.xor a2 b2), (Int.xor a3 b3)).
Lemma rot8_word_to_int: forall b0 b1 b2 b3,
rot8 (word_to_int (b0, b1, b2, b3)) = word_to_int (b3, b0, b1, b2).
Lemma mask_byte_nop: forall i,
0 <= Int.unsigned i < 256 ->
Int.and i (Int.repr 255) = i.
Lemma FSb_range: forall i,
0 <= Int.unsigned (Znth i FSb) < 256.
Lemma zero_ext_nop: forall i,
0 <= (Int.unsigned i) < 256 ->
Int.zero_ext 8 i = i.
Lemma FSb_inj: forall i j,
0 <= i < 256 ->
0 <= j < 256 ->
Znth i FSb = Znth j FSb ->
i = j.
Lemma FSb_RSb_id: forall j,
0 <= j < 256 ->
j = Int.unsigned (Znth (Int.unsigned (Znth j RSb)) FSb).
Lemma RSb_inj: forall i j,
0 <= i < 256 ->
0 <= j < 256 ->
Znth i RSb = Znth j RSb ->
i = j.
Lemma RSb_range: forall i,
0 <= Int.unsigned (Znth i RSb) < 256.
(* TODO also requires that 0 <= b0, b1, b2, b3 < 256 *)
Lemma xor_is_or_4_bytes: forall b0 b1 b2 b3,
(Int.xor (Int.xor (Int.xor b0
(Int.shl b1 (Int.repr 8)))
(Int.shl b2 (Int.repr 16)))
(Int.shl b3 (Int.repr 24))) =
(Int.or  (Int.or  (Int.or  b0
(Int.shl b1 (Int.repr 8)))
(Int.shl b2 (Int.repr 16)))
(Int.shl b3 (Int.repr 24))).
Lemma masked_byte_range: forall i,
0 <= Z.land i 255 < 256.
Lemma zero_ext_mask: forall i,
Int.zero_ext 8 i = Int.and i (Int.repr 255).
Lemma key_expansion_final_eq: forall key_chars,
pow_fun GrowKeyByOne (Z.to_nat (Nb * (Nr + 2) - Nk)) (key_bytes_to_key_words key_chars)
= KeyExpansion2 (key_bytes_to_key_words key_chars).
Lemma body_key_expansion: semax_body Vprog Gprog f_mbedtls_aes_setkey_enc key_expansion_spec.
Lemma Zlength_partially_expanded_key: forall i key_chars,
0 <= i < 7 ->
Zlength key_chars = 32 ->
Zlength (map Vint (pow_fun GrowKeyByOne (Z.to_nat (i * 8)) (key_bytes_to_key_words key_chars)) ++
repeat_op_table (60 - i * 8) Vundef id) = 68.
Lemma update_partially_expanded_key: forall k j j' v key_chars,
j = j'+k-8 ->
upd_Znth (j' + k) (map Vint (pow_fun GrowKeyByOne (Z.to_nat j) (key_bytes_to_key_words key_chars))
++ repeat_op_table (60 - j) Vundef id) v
= (map Vint (pow_fun GrowKeyByOne (Z.to_nat (j + 1)) (key_bytes_to_key_words key_chars))
++ repeat_op_table (60 - (j + 1)) Vundef id).
Lemma zero_ext_mask: forall i,
Int.zero_ext 8 i = Int.and i (Int.repr 255).