Local Open Scope logic.
Local Open Scope nat.
Definition rearrange_regs2c :=
Ssequence (Sset _h (Etempvar _g tuint))
(Ssequence (Sset _g (Etempvar _f tuint))
(Ssequence (Sset _f (Etempvar _e tuint))
(Ssequence
(Sset _e
(Ebinop Oadd (Etempvar _d tuint) (Etempvar _T1 tuint)
tuint))
(Ssequence (Sset _d (Etempvar _c tuint))
(Ssequence (Sset _c (Etempvar _b tuint))
(Ssequence (Sset _b (Etempvar _a tuint))
(Sset _a
(Ebinop Oadd (Etempvar _T1 tuint)
(Etempvar _T2 tuint) tuint)))))))).
Definition rearrange_regs2b :=
Ssequence
(Sset _T1
(Ebinop Oadd (Etempvar _T1 tuint)
(Ebinop Oadd
(Ebinop Oadd
(Ebinop Oadd (Etempvar _h tuint)
(Ebinop Oxor
(Ebinop Oxor
(Ebinop Oor
(Ebinop Oshl (Etempvar _e tuint)
(Econst_int (Int.repr 26) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _e tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 26) tint) tint) tuint)
tuint)
(Ebinop Oor
(Ebinop Oshl (Etempvar _e tuint)
(Econst_int (Int.repr 21) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _e tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 21) tint) tint) tuint)
tuint) tuint)
(Ebinop Oor
(Ebinop Oshl (Etempvar _e tuint)
(Econst_int (Int.repr 7) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _e tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 7) tint) tint) tuint)
tuint) tuint) tuint)
(Ebinop Oxor
(Ebinop Oand (Etempvar _e tuint) (Etempvar _f tuint) tuint)
(Ebinop Oand (Eunop Onotint (Etempvar _e tuint) tuint)
(Etempvar _g tuint) tuint) tuint) tuint)
(Etempvar _Ki tuint) tuint) tuint))
(Ssequence
(Sset _T2
(Ebinop Oadd
(Ebinop Oxor
(Ebinop Oxor
(Ebinop Oor
(Ebinop Oshl (Etempvar _a tuint)
(Econst_int (Int.repr 30) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _a tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 30) tint) tint) tuint) tuint)
(Ebinop Oor
(Ebinop Oshl (Etempvar _a tuint)
(Econst_int (Int.repr 19) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _a tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 19) tint) tint) tuint) tuint)
tuint)
(Ebinop Oor
(Ebinop Oshl (Etempvar _a tuint)
(Econst_int (Int.repr 10) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _a tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 10) tint) tint) tuint) tuint)
tuint)
(Ebinop Oxor
(Ebinop Oxor
(Ebinop Oand (Etempvar _a tuint) (Etempvar _b tuint) tuint)
(Ebinop Oand (Etempvar _a tuint) (Etempvar _c tuint) tuint)
tuint)
(Ebinop Oand (Etempvar _b tuint) (Etempvar _c tuint) tuint)
tuint) tuint))
rearrange_regs2c).
Definition bdo_loop2_body :=
(Ssequence
(Sset _s0
(Ederef
(Ebinop Oadd (Evar _X (tarray tuint 16))
(Ebinop Oand
(Ebinop Oadd (Etempvar _i tint)
(Econst_int (Int.repr 1) tint) tint)
(Econst_int (Int.repr 15) tint) tint) (tptr tuint)) tuint))
(Ssequence
(Sset _s0
(Ebinop Oxor
(Ebinop Oxor
(Ebinop Oor
(Ebinop Oshl (Etempvar _s0 tuint)
(Econst_int (Int.repr 25) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _s0 tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 25) tint) tint) tuint) tuint)
(Ebinop Oor
(Ebinop Oshl (Etempvar _s0 tuint)
(Econst_int (Int.repr 14) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _s0 tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 14) tint) tint) tuint) tuint)
tuint)
(Ebinop Oshr (Etempvar _s0 tuint)
(Econst_int (Int.repr 3) tint) tuint) tuint))
(Ssequence
(Sset _s1
(Ederef
(Ebinop Oadd (Evar _X (tarray tuint 16))
(Ebinop Oand
(Ebinop Oadd (Etempvar _i tint)
(Econst_int (Int.repr 14) tint) tint)
(Econst_int (Int.repr 15) tint) tint) (tptr tuint))
tuint))
(Ssequence
(Sset _s1
(Ebinop Oxor
(Ebinop Oxor
(Ebinop Oor
(Ebinop Oshl (Etempvar _s1 tuint)
(Econst_int (Int.repr 15) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _s1 tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 15) tint) tint) tuint)
tuint)
(Ebinop Oor
(Ebinop Oshl (Etempvar _s1 tuint)
(Econst_int (Int.repr 13) tint) tuint)
(Ebinop Oshr
(Ebinop Oand (Etempvar _s1 tuint)
(Econst_int (Int.repr (-1)) tuint) tuint)
(Ebinop Osub (Econst_int (Int.repr 32) tint)
(Econst_int (Int.repr 13) tint) tint) tuint)
tuint) tuint)
(Ebinop Oshr (Etempvar _s1 tuint)
(Econst_int (Int.repr 10) tint) tuint) tuint))
(Ssequence
(Sset _T1
(Ederef
(Ebinop Oadd (Evar _X (tarray tuint 16))
(Ebinop Oand (Etempvar _i tint)
(Econst_int (Int.repr 15) tint) tint)
(tptr tuint)) tuint))
(Ssequence
(Sset _t
(Ederef
(Ebinop Oadd (Evar _X (tarray tuint 16))
(Ebinop Oand
(Ebinop Oadd (Etempvar _i tint)
(Econst_int (Int.repr 9) tint) tint)
(Econst_int (Int.repr 15) tint) tint)
(tptr tuint)) tuint))
(Ssequence
(Sset _T1
(Ebinop Oadd (Etempvar _T1 tuint)
(Ebinop Oadd
(Ebinop Oadd (Etempvar _s0 tuint)
(Etempvar _s1 tuint) tuint)
(Etempvar _t tuint) tuint) tuint))
(Ssequence
(Sassign
(Ederef
(Ebinop Oadd (Evar _X (tarray tuint 16))
(Ebinop Oand (Etempvar _i tint)
(Econst_int (Int.repr 15) tint) tint)
(tptr tuint)) tuint) (Etempvar _T1 tuint))
(Ssequence
(Sset _Ki
(Ederef
(Ebinop Oadd
(Evar _K256 (tarray tuint 64))
(Etempvar _i tint) (tptr tuint)) tuint))
rearrange_regs2b))))))))).
Definition block_data_order_loop2 :=
nth 1 (loops (fn_body f_sha256_block_data_order)) Sskip.
Fixpoint Xarray' (b: list int) (i k: nat) : list int :=
match k with
| O => nil
| S k' => W (nthi b) (Z.of_nat i - 16 + (16-(Z.of_nat k)- Z.of_nat i) mod 16) ::
Xarray' b i k'
end.
Definition Xarray (b: list int) (i: nat) := Xarray' b i 16.
Hint Resolve Znth_land_is_int.
Global Opaque Xarray.
Require Export mc_reify.symexe_soundness.

Lemma bdo_loop2_body_proof:
forall (Espec : OracleKind)
(b : list int) (ctx : val) ( regs : list int) (i : nat) kv Xv
(Hregs: length regs = 8%nat)
(H : Zlength b = LBLOCKz)
(H0 : (LBLOCK <= i < c64)%nat),
semax Delta_loop1
(PROP  ()
LOCAL  (temp _ctx ctx; temp _i (Vint (Int.repr (Z.of_nat i)));
temp _a  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 0));
temp _b  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 1));
temp _c  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 2));
temp _d  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 3));
temp _e  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 4));
temp _f  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 5));
temp _g  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 6));
temp _h  (Vint (nthi (Round regs (nthi b) (Z.of_nat i - 1)) 7));
canon.var _X (tarray tuint LBLOCKz) Xv;
canon.var  _K256 (tarray tuint CBLOCKz) kv)
SEP  (`(K_vector kv);
`(data_at Tsh (tarray tuint LBLOCKz) (map Vint (Xarray b i)) Xv)))
bdo_loop2_body
(normal_ret_assert
(EX  i0 : nat,
PROP  (LBLOCK <= i0 <= c64)
LOCAL  (temp _ctx ctx; temp _i (Vint (Int.repr (Z.of_nat i0 - 1)));
temp _a  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 0));
temp _b  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 1));
temp _c  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 2));
temp _d  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 3));
temp _e  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 4));
temp _f  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 5));
temp _g  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 6));
temp _h  (Vint (nthi (Round regs (nthi b) (Z.of_nat i0 - 1)) 7));
canon.var _X (tarray tuint LBLOCKz) Xv;
canon.var  _K256 (tarray tuint CBLOCKz) kv)
SEP  (`(K_vector kv);
`(data_at Tsh (tarray tuint LBLOCKz) (map Vint (Xarray b i0)) Xv)))).