Local Open Scope logic.
Instance CompSpecs : compspecs.
Definition ThirtyTwoByte (q:SixteenByte * SixteenByte) (v:val) : mpred :=
match q with (q1, q2) =>
@data_at CompSpecs Tsh (Tarray tuchar 32 noattr) ((SixteenByte2ValList q1) ++ (SixteenByte2ValList q2)) v
end.
Definition QByte (q:QuadByte) (v:val) : mpred :=
data_at Tsh (Tarray tuchar 4 noattr) (QuadByte2ValList q) v.
Definition QuadChunks2ValList (l: list QuadByte) : list val :=
List.fold_right (fun q vals => QuadByte2ValList q ++ vals) nil l.
Definition flatten16 (B:SixteenByte) : list QuadByte :=
match B with (q0, q1, q2, q3) => [q0; q1; q2; q3] end.
destruct B as (((q0, q1), q2), q3). simpl.
rewrite SixteenByte2ValList_char, app_nil_r. trivial.
Qed.
destruct q as (((q0, q1), q2), q3). simpl. reflexivity. Qed.
destruct q as (((q0, q1), q2), q3). simpl. reflexivity. Qed.
destruct C as (((q0, q1), q2), q3). unfold SixteenByte2ValList.
repeat rewrite Zlength_map.  simpl.
repeat rewrite Zlength_app. repeat rewrite <- QuadByteByteList_ZLength.
reflexivity. Qed.
Definition SByte (q:SixteenByte) (v:val) : mpred :=
@data_at CompSpecs Tsh (Tarray tuchar 16 noattr) (SixteenByte2ValList q) v.

Lemma ThirtyTwoByte_split16 q v:
field_compatible (Tarray tuchar 32 noattr) [] v ->
ThirtyTwoByte q v =
(SByte (fst q) v * SByte (snd q) (offset_val 16 v))%logic.