Local Open Scope logic.
Opaque Snuffle.Snuffle. Opaque prepare_data.
(*TODO: eliminate*)
Ltac canon_load_result ::= idtac.
Definition HTrue_inv1 l i ys xs : Prop :=
Zlength l = 16 /\ exists ints, l=map Vint ints /\
forall j, 0<=j<16 -> exists xj,
Znth j xs = Vint xj
/\ (j<i -> exists yj, Znth j ys = Vint yj /\
Znth j l = Vint (Int.add yj xj))
/\ (i<=j ->  Znth j l = Vint xj).
Definition htrue_loop1_statement:=
Sfor (Sset _i (Econst_int (Int.repr 0) tint))
(Ebinop Olt (Etempvar _i tint) (Econst_int (Int.repr 16) tint) tint)
(Ssequence
(Sset _t'17
(Ederef
(Ebinop Oadd (Evar _x (tarray tuint 16)) (Etempvar _i tint)
(tptr tuint)) tuint))
(Ssequence
(Sset _t'18
(Ederef
(Ebinop Oadd (Evar _y (tarray tuint 16)) (Etempvar _i tint)
(tptr tuint)) tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _x (tarray tuint 16)) (Etempvar _i tint)
(tptr tuint)) tuint)
(Ebinop Oadd (Etempvar _t'17 tuint) (Etempvar _t'18 tuint)
tuint))))
(Sset _i
(Ebinop Oadd (Etempvar _i tint) (Econst_int (Int.repr 1) tint) tint)).
Fixpoint hPosLoop3 (n:nat) (xlist: list int) (old: list val): list val :=
match n with
O => old
| S m => let j:= Z.of_nat m in
let s := hPosLoop3 m xlist old in
let five := Znth (5*j) xlist in
let six := Znth (6+j) xlist in
UpdateOut (UpdateOut s (4*j) five) (16+4*j) six
end.
Opaque Z.mul. Opaque Z.add.
Transparent Z.add. Transparent Z.mul.
Definition HTrue_loop3_statement :=
Sfor (Sset _i (Econst_int (Int.repr 0) tint))
(Ebinop Olt (Etempvar _i tint) (Econst_int (Int.repr 4) tint) tint)
(Ssequence
(Ssequence
(Sset _t'14
(Ederef
(Ebinop Oadd (Evar _x (tarray tuint 16))
(Ebinop Omul (Econst_int (Int.repr 5) tint)
(Etempvar _i tint) tint) (tptr tuint)) tuint))
(Scall None
(Evar _st32
(Tfunction (Tcons (tptr tuchar) (Tcons tuint Tnil)) tvoid
cc_default))
[Ebinop Oadd (Etempvar _out (tptr tuchar))
(Ebinop Omul (Econst_int (Int.repr 4) tint)
(Etempvar _i tint) tint) (tptr tuchar);
Etempvar _t'14 tuint]))
(Ssequence
(Sset _t'13
(Ederef
(Ebinop Oadd (Evar _x (tarray tuint 16))
(Ebinop Oadd (Econst_int (Int.repr 6) tint)
(Etempvar _i tint) tint) (tptr tuint)) tuint))
(Scall None
(Evar _st32
(Tfunction (Tcons (tptr tuchar) (Tcons tuint Tnil)) tvoid
cc_default))
[Ebinop Oadd
(Ebinop Oadd (Etempvar _out (tptr tuchar))
(Econst_int (Int.repr 16) tint) (tptr tuchar))
(Ebinop Omul (Econst_int (Int.repr 4) tint)
(Etempvar _i tint) tint) (tptr tuchar);
Etempvar _t'13 tuint])))
(Sset _i
(Ebinop Oadd (Etempvar _i tint) (Econst_int (Int.repr 1) tint) tint)).

Lemma HTrue_loop3 Espec (FR:mpred) t y x w nonce out c k h (OUT: list val) xs (*ys Nonce C K*):
@semax CompSpecs Espec
(func_tycontext f_core SalsaVarSpecs SalsaFunSpecs nil)
(PROP  ()
LOCAL  (lvar _t (tarray tuint 4) t;
lvar _y (tarray tuint 16) y; lvar _x (tarray tuint 16) x;
lvar _w (tarray tuint 16) w; temp _in nonce; temp _out out; temp _c c;
temp _k k; temp _h (Vint (Int.repr h)))
SEP  (FR; data_at Tsh (tarray tuchar 32) OUT out;
data_at Tsh (tarray tuint 16) (map Vint xs) x))
HTrue_loop3_statement
(normal_ret_assert (
PROP  ()
LOCAL  (lvar _t (tarray tuint 4) t;
lvar _y (tarray tuint 16) y; lvar _x (tarray tuint 16) x;
lvar _w (tarray tuint 16) w; temp _in nonce; temp _out out; temp _c c;
temp _k k; temp _h (Vint (Int.repr h)))
SEP (FR; data_at Tsh (tarray tuint 16) (map Vint xs) x;
data_at Tsh (tarray tuchar 32) (hPosLoop3 4 xs OUT) out))).