Local Open Scope logic.
Definition final_loop :=
Sfor (Sset _xn (Econst_int (Int.repr 0) tint))
(Ebinop Olt (Etempvar _xn tuint)
(Ebinop Odiv (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 4) tint) tint) tint)
(Ssequence
(Sset _ll (Ederef
(Ebinop Oadd
(Efield
(Ederef
(Etempvar _c
(tptr t_struct_SHA256state_st))
t_struct_SHA256state_st) _h
(tarray tuint 8)) (Etempvar _xn tuint)
(tptr tuint)) tuint))
(Ssequence
(Scall None
(Evar ___builtin_write32_reversed
(Tfunction
(Tcons (tptr tuint) (Tcons tuint Tnil))
tvoid cc_default))
[Ecast (Etempvar _md (tptr tuchar))
(tptr tuint); Etempvar _ll tuint])
(Sset _md
(Ebinop Oadd (Etempvar _md (tptr tuchar))
(Econst_int (Int.repr 4) tint)
(tptr tuchar)))))
(Sset _xn
(Ebinop Oadd (Etempvar _xn tuint)
(Econst_int (Int.repr 1) tint) tuint)).
Definition sha_final_epilog :=
(Ssequence
(Scall None
(Evar _sha256_block_data_order (Tfunction
(Tcons(tptr t_struct_SHA256state_st)
(Tcons (tptr tvoid) Tnil))
tvoid cc_default))
((Etempvar _c (tptr t_struct_SHA256state_st)) ::
(Etempvar _p (tptr tuchar)) :: nil))
(Ssequence
(Sassign
(Efield
(Ederef
(Etempvar _c (tptr t_struct_SHA256state_st))
t_struct_SHA256state_st) _num tuint)
(Econst_int (Int.repr 0) tint))
(Ssequence
(Scall None
(Evar _memset (Tfunction
(Tcons (tptr tvoid)
(Tcons tint
(Tcons tuint Tnil)))
(tptr tvoid) cc_default))
((Etempvar _p (tptr tuchar)) ::
(Econst_int (Int.repr 0) tint) ::
(Ebinop Omul (Econst_int (Int.repr 16) tint)
(Econst_int (Int.repr 4) tint) tint) ::
nil))
(Ssequence final_loop (Sreturn None))))).
Definition sha_final_part2 :=
(Ssequence
(Sset _cNh
(Efield
(Ederef (Etempvar _c (tptr t_struct_SHA256state_st))
t_struct_SHA256state_st) _Nh tuint))
(Ssequence
(Ssequence
(Scall None
(Evar ___builtin_write32_reversed
(Tfunction (Tcons (tptr tuint) (Tcons tuint Tnil)) tvoid cc_default))
[Ecast (Etempvar _p (tptr tuchar)) (tptr tuint);
Etempvar _cNh tuint])
(Sset _p
(Ebinop Oadd (Etempvar _p (tptr tuchar))
(Econst_int (Int.repr 4) tint) (tptr tuchar))))
(Ssequence
(Sset _cNl
(Efield
(Ederef (Etempvar _c (tptr t_struct_SHA256state_st))
t_struct_SHA256state_st) _Nl tuint))
(Ssequence
(Ssequence
(Scall None
(Evar ___builtin_write32_reversed
(Tfunction (Tcons (tptr tuint) (Tcons tuint Tnil))
tvoid cc_default))
[Ecast (Etempvar _p (tptr tuchar)) (tptr tuint);
Etempvar _cNl tuint])
(Sset _p
(Ebinop Oadd (Etempvar _p (tptr tuchar))
(Econst_int (Int.repr 4) tint) (tptr tuchar))))
(Ssequence
(Sset _p
(Ebinop Osub (Etempvar _p (tptr tuchar))
(Ebinop Omul (Econst_int (Int.repr 16) tint)
(Econst_int (Int.repr 4) tint) tint) (tptr tuchar)))
sha_final_epilog))))).

(* Specifications: *)
Lemma align_compatible_tarray_tuchar:
forall n v, align_compatible (tarray tuchar n) v.
Lemma sha_final_part3:
forall (Espec : OracleKind) (md c : val) (wsh shmd : share)
(hashed lastblock: list int) msg gv
(Hwsh: writable_share wsh)
(Hshmd: writable_share shmd),
(LBLOCKz | Zlength hashed) ->
Zlength lastblock = LBLOCKz ->
generate_and_pad msg = hashed++lastblock ->
semax
(func_tycontext f_SHA256_Final Vprog Gtot nil)
(PROP  ()
LOCAL  (temp _p (field_address t_struct_SHA256state_st [StructField _data] c);
temp _md md; temp _c c;
gvars gv)
SEP
(data_at wsh t_struct_SHA256state_st
(map Vint (hash_blocks init_registers hashed),
(Vundef, (Vundef, (map Vubyte (intlist_to_bytelist lastblock), Vundef)))) c;
K_vector gv;
memory_block shmd 32 md))
sha_final_epilog
(frame_ret_assert
(function_body_ret_assert tvoid
(PROP  ()
LOCAL ()
SEP  (K_vector gv;
data_at_ wsh t_struct_SHA256state_st c;
data_block shmd (SHA_256 msg) md))) emp).