Definition fcore_result h data l :=
  match Snuffle20 (prepare_data data)
  with None => False
     | Some x =>
             if Int.eq (Int.repr h) Int.zero
             then l=QuadChunks2ValList (map littleendian_invert x)
             else match data with ((Nonce, C), K) =>
                    match Nonce with (N1, N2, N3, N4) =>
                    match C with (C1, C2, C3, C4) =>
                    l = QuadByte2ValList (littleendian_invert (Int.sub (Znth 0 x)  (littleendian C1))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 5 x)  (littleendian C2))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 10 x) (littleendian C3))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 15 x) (littleendian C4))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 6 x)  (littleendian N1))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 7 x)  (littleendian N2))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 8 x)  (littleendian N3))) ++
                    QuadByte2ValList (littleendian_invert (Int.sub (Znth 9 x)  (littleendian N4)))
                    end end end
  end.Definition OutLen h := if Int.eq (Int.repr h) Int.zero then 64 else 32.Definition fcorePOST_SEP h data d l out :=
  CoreInSEP data d *
  data_at Tsh (tarray tuchar (OutLen h)) l out.Definition bigendian64 (b c:QuadByte): int64 :=
  match b, c with (b0, b1, b2, b3), (c0, c1, c2, c3) =>
  Int64.repr
   (       Byte.unsigned c3 +
    2^8  * Byte.unsigned c2 +
    2^16 * Byte.unsigned c1 +
    2^24 * Byte.unsigned c0 +
    2^32 * Byte.unsigned b3 +
    2^40 * Byte.unsigned b2 +
    2^48 * Byte.unsigned b1 +
    2^56 * Byte.unsigned b0
    )
  end.Definition bigendian64_invert (w:int64) : QuadByte * QuadByte:=
    let w3 := Int64.unsigned w in
  let b3 := w3 / (2^56) in 
    let w2 := Z.modulo w3 (2^56) in
  let b2 := w2 / (2^48) in 
    let w1 := Z.modulo w2 (2^48) in
  let b1 := w1 / (2^40) in 
    let w0 := Z.modulo w1 (2^40) in
  let b0 := w0 / (2^32) in 
    let u3 := Z.modulo w0 (2^32) in
  let c3 := u3 / (2^24) in 
    let u2 := Z.modulo u3 (2^24) in
  let c2 := u2 / (2^16) in 
    let u1 := Z.modulo u2 (2^16) in
  let c1 := u1 / (2^8) in
    let c0 := Z.modulo u1 (2^8) in
  ((Byte.repr b3, Byte.repr b2, Byte.repr b1, Byte.repr b0), 
   (Byte.repr c3, Byte.repr c2, Byte.repr c1, Byte.repr c0)).

Lemma bigendian64_inv: forall b c: QuadByte, bigendian64_invert (bigendian64 b c) = (b,c).