val scratch_b_blocks : rev_bytes: Prims.bool ->
    rev_blocks: Prims.bool ->
    scratch_in_b: Vale.X64.Memory.buffer128 ->
    scratch_len: Prims.int ->
    count: Prims.int ->
    heap_s: Vale.X64.InsBasic.vale_heap ->
    data: FStar.Seq.Base.seq Vale.X64.Decls.quad32
  -> Prims.logical
let scratch_b_blocks
    (rev_bytes:bool) (rev_blocks:bool) (scratch_in_b:buffer128) (scratch_len count:int) (heap_s:vale_heap)
    (data:seq quad32)
  =
  (forall (i:nat).{:pattern (index data i)}
    i < count /\ i < length data ==>
      buffer128_read scratch_in_b (index_opt_rev rev_blocks scratch_len (length data) i) heap_s ==
      quad32_opt_rev rev_bytes (index data i))
module Vale.AES.X64.AESopt2
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math    // For lemma_poly_bits64()
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.Arch.TypesNative
open Vale.X64.CPU_Features_s
open Vale.AES.X64.PolyOps

open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash
#reset-options "--z3rlimit 50"

unfold let va_subscript_FStar__Seq__Base__seq = Seq.index

let hkeys_b_powers (hkeys_b:buffer128) (heap0:vale_heap) (layout:vale_heap_layout) (ptr:int) (h:poly) =
  validSrcAddrs128 heap0 ptr hkeys_b 8 layout Secret /\
  of_quad32 (buffer128_read hkeys_b 0 heap0) == gf128_power h 1 /\
  of_quad32 (buffer128_read hkeys_b 1 heap0) == gf128_power h 2 /\
  of_quad32 (buffer128_read hkeys_b 3 heap0) == gf128_power h 3 /\
  of_quad32 (buffer128_read hkeys_b 4 heap0) == gf128_power h 4 /\
  of_quad32 (buffer128_read hkeys_b 6 heap0) == gf128_power h 5 /\
  of_quad32 (buffer128_read hkeys_b 7 heap0) == gf128_power h 6

let quad32_opt_rev (b:bool) (q:quad32) : quad32 =
  if b then reverse_bytes_quad32 q else q

let index_opt_rev (b:bool) (len n i:int) : int =
  if b then len - 1 - i else len - n + i
/
Vale.X64.State.fsti.checked Vale.X64.QuickCodes.fsti.checked Vale.X64.QuickCode.fst.checked Vale.X64.Memory.fsti.checked Vale.X64.Machine_s.fst.checked Vale.X64.InsVector.fsti.checked Vale.X64.InsMem.fsti.checked Vale.X64.InsBasic.fsti.checked Vale.X64.InsAes.fsti.checked Vale.X64.Flags.fsti.checked Vale.X64.Decls.fsti.checked Vale.X64.CPU_Features_s.fst.checked Vale.Poly1305.Math.fsti.checked Vale.Math.Poly2_s.fsti.checked Vale.Math.Poly2.Lemmas.fsti.checked Vale.Math.Poly2.Bits_s.fsti.checked Vale.Math.Poly2.Bits.fsti.checked Vale.Math.Poly2.fsti.checked Vale.Def.Words_s.fsti.checked Vale.Def.Types_s.fst.checked Vale.Def.Prop_s.fst.checked Vale.Def.Opaque_s.fsti.checked Vale.Arch.TypesNative.fsti.checked Vale.Arch.Types.fsti.checked Vale.Arch.HeapImpl.fsti.checked Vale.AES.X64.PolyOps.fsti.checked Vale.AES.GHash.fsti.checked Vale.AES.GF128_s.fsti.checked Vale.AES.GF128.fsti.checked Vale.AES.GCTR_s.fst.checked Vale.AES.GCTR.fsti.checked Vale.AES.GCM_helpers.fsti.checked Vale.AES.AES_s.fst.checked Vale.AES.AES_helpers.fsti.checked prims.fst.checked FStar.Seq.Base.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked
Vale.AES.X64.AESopt2.fsti

    rev_bytes: Prims.bool ->
    rev_blocks: Prims.bool ->
    scratch_in_b: Vale.X64.Memory.buffer128 ->
    scratch_len: Prims.int ->
    count: Prims.int ->
    heap_s: Vale.X64.InsBasic.vale_heap ->
    data: FStar.Seq.Base.seq Vale.X64.Decls.quad32
  -> Prims.logical
Prims.bool Vale.X64.Memory.buffer128 Prims.int Vale.X64.InsBasic.vale_heap FStar.Seq.Base.seq Vale.X64.Decls.quad32 Prims.l_Forall Prims.nat Prims.l_imp Prims.l_and Prims.b2t Prims.op_LessThan FStar.Seq.Base.length Prims.eq2 Vale.X64.Decls.buffer128_read Vale.AES.X64.AESopt2.index_opt_rev Vale.AES.X64.AESopt2.quad32_opt_rev FStar.Seq.Base.index Prims.logical
let scratch_b_blocks
      (rev_bytes rev_blocks: bool)
      (scratch_in_b: buffer128)
      (scratch_len count: int)
      (heap_s: vale_heap)
      (data: seq quad32)
     =
  
(forall (i: nat). {:pattern (index data i)}
    i < count /\ i < length data ==>
    buffer128_read scratch_in_b (index_opt_rev rev_blocks scratch_len (length data) i) heap_s ==
    quad32_opt_rev rev_bytes (index data i))