val va_wp_Load_one_lsb (dst: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
    : Type0
let va_wp_Load_one_lsb (dst:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
  Type0 =
  (va_is_dst_xmm dst va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_dst:va_value_xmm)
    (va_x_r11:nat64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64
    rR11 va_x_r11 (va_upd_operand_xmm dst va_x_dst va_s0)) in va_get_ok va_sM /\ va_eval_xmm va_sM
    dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 ==> va_k va_sM (())))
val va_wp_Load_one_lsb (dst: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
    : Type0
let va_wp_Load_one_lsb (dst: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
    : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\
  (forall (va_x_dst: va_value_xmm) (va_x_r11: nat64) (va_x_efl: Vale.X64.Flags.t).
      let va_sM =
        va_upd_flags va_x_efl (va_upd_reg64 rR11 va_x_r11 (va_upd_operand_xmm dst va_x_dst va_s0))
      in
      va_get_ok va_sM /\
      va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 ==>
      va_k va_sM (())))
Vale.AES.X64.AESopt.fsti.checked
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.Transformers.Transform.fsti.checked Vale.Math.Poly2_s.fsti.checked Vale.Math.Poly2.Bits_s.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.X64.AESopt2.fsti.checked Vale.AES.X64.AESGCM_expected_code.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 Vale.AES.AES_common_s.fst.checked prims.fst.checked FStar.Seq.Base.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.Mul.fst.checked
Vale.AES.X64.AESopt.fsti
Vale.X64.Decls.va_operand_xmm Vale.X64.Decls.va_state Prims.unit Prims.l_and Vale.X64.Decls.va_is_dst_xmm Prims.b2t Vale.X64.Decls.va_get_ok Vale.X64.CPU_Features_s.sse_enabled Prims.l_Forall Vale.X64.Decls.va_value_xmm Vale.X64.Memory.nat64 Vale.X64.Flags.t Prims.l_imp Prims.eq2 Vale.Def.Words_s.four Vale.Def.Types_s.nat32 Vale.X64.Decls.va_eval_xmm Vale.Def.Words_s.Mkfour Vale.X64.State.vale_state Vale.X64.Decls.va_upd_flags Vale.X64.Decls.va_upd_reg64 Vale.X64.Machine_s.rR11 Vale.X64.Decls.va_upd_operand_xmm
module Vale.AES.X64.AESopt
open FStar.Mul
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.Math.Poly2_s
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash
open Vale.AES.X64.PolyOps
open Vale.AES.X64.AESopt2
open Vale.AES.X64.AESGCM_expected_code
open Vale.Transformers.Transform
open FStar.Mul
let aes_reqs0
  (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
  (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
  =
  aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\
  alg = AES_128 /\
  //(alg = AES_128 || alg = AES_256) /\
  is_aes_key_LE alg key /\
  length(round_keys) == nr(alg) + 1 /\
  round_keys == key_to_round_keys_LE alg key /\
  validSrcAddrsOffset128 heap0 key_ptr keys_b 8 (nr alg + 1 - 8) layout Secret /\
  buffer128_as_seq heap0 keys_b == round_keys

let aes_reqs_offset
  (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
  (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
  =
  aesni_enabled /\ avx_enabled /\ pclmulqdq_enabled /\
  (alg = AES_128 || alg = AES_256) /\
  is_aes_key_LE alg key /\
  length(round_keys) == nr(alg) + 1 /\
  round_keys == key_to_round_keys_LE alg key /\
  validSrcAddrsOffset128 heap0 key_ptr keys_b 8 (nr alg + 1 - 8) layout Secret /\
  s128 heap0 keys_b == round_keys

let six_of (a:Type0) = a & a & a & a & a & a
let quad32_6 = six_of quad32

unfold let make_six_of (#a:Type0) (f:(n:nat{n < 6}) -> GTot a) : GTot (six_of a) =
  (f 0, f 1, f 2, f 3, f 4, f 5)
unfold let map_six_of (#a #b:Type0) (x:six_of a) (f:a -> GTot b) : GTot (six_of b) =
  let (x0, x1, x2, x3, x4, x5) = x in
  (f x0, f x1, f x2, f x3, f x4, f x5)
unfold let map2_six_of (#a #b #c:Type0) (x:six_of a) (y:six_of b) (f:a -> b -> GTot c) : GTot (six_of c) =
  let (x0, x1, x2, x3, x4, x5) = x in
  let (y0, y1, y2, y3, y4, y5) = y in
  (f x0 y0, f x1 y1, f x2 y2, f x3 y3, f x4 y4, f x5 y5)

let rounds_opaque_6 (init:quad32_6) (round_keys:seq quad32) (rnd:nat{rnd < length round_keys}) : GTot quad32_6 =
  map_six_of init (fun x -> eval_rounds x round_keys rnd)

let xor_reverse_inc32lite_6 (n i0:int) (ctr_BE rndkey:quad32) : GTot quad32_6 =
  make_six_of (fun i ->
    let r = reverse_bytes_quad32 (inc32lite ctr_BE (i0 + i)) in
    if i < n then quad32_xor r rndkey else r)

//let scratch_reqs (scratch_b:buffer128) (count:nat) (heap3:vale_heap) (s:seq quad32) (z3:quad32) : prop0 =
//  count * 6 + 6 <= length s /\ (
//    let data = slice s (count * 6) (count * 6 + 6) in
//    z3 == reverse_bytes_quad32 (index data 5) /\
//    scratch_b_blocks true true scratch_b 8 5 heap3 data)

let scratch_reqs (scratch_b:buffer128) (count:nat) (heap3:vale_heap) (s:seq quad32) (z3:quad32) : prop0 =
  count * 6 + 6 <= length s /\ (
    let data = slice s (count * 6) (count * 6 + 6) in
    z3 == reverse_bytes_quad32 (index data 5) /\
    buffer128_read scratch_b 3 heap3 == reverse_bytes_quad32 (index data 4) /\
    buffer128_read scratch_b 4 heap3 == reverse_bytes_quad32 (index data 3) /\
    buffer128_read scratch_b 5 heap3 == reverse_bytes_quad32 (index data 2) /\
    buffer128_read scratch_b 6 heap3 == reverse_bytes_quad32 (index data 1) /\
    buffer128_read scratch_b 7 heap3 == reverse_bytes_quad32 (index data 0))
//-- Load_two_lsb

val va_code_Load_two_lsb : dst:va_operand_xmm -> Tot va_code

val va_codegen_success_Load_two_lsb : dst:va_operand_xmm -> Tot va_pbool

val va_lemma_Load_two_lsb : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm
  -> Ghost (va_state & va_fuel)
  (requires (va_require_total va_b0 (va_code_Load_two_lsb dst) va_s0 /\ va_is_dst_xmm dst va_s0 /\
    va_get_ok va_s0 /\ sse_enabled))
  (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
    va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 2 0 0 0 /\ va_state_eq
    va_sM (va_update_flags va_sM (va_update_reg64 rR11 va_sM (va_update_ok va_sM
    (va_update_operand_xmm dst va_sM va_s0))))))
[@ va_qattr]
let va_wp_Load_two_lsb (dst:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
  Type0 =
  (va_is_dst_xmm dst va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ (forall (va_x_dst:va_value_xmm)
    (va_x_r11:nat64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64
    rR11 va_x_r11 (va_upd_operand_xmm dst va_x_dst va_s0)) in va_get_ok va_sM /\ va_eval_xmm va_sM
    dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 2 0 0 0 ==> va_k va_sM (())))

val va_wpProof_Load_two_lsb : dst:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit ->
  Type0)
  -> Ghost (va_state & va_fuel & unit)
  (requires (va_t_require va_s0 /\ va_wp_Load_two_lsb dst va_s0 va_k))
  (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Load_two_lsb dst) ([va_Mod_flags;
    va_Mod_reg64 rR11; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Load_two_lsb (dst:va_operand_xmm) : (va_quickCode unit (va_code_Load_two_lsb dst)) =
  (va_QProc (va_code_Load_two_lsb dst) ([va_Mod_flags; va_Mod_reg64 rR11; va_mod_xmm dst])
    (va_wp_Load_two_lsb dst) (va_wpProof_Load_two_lsb dst))
//--
//-- Load_one_lsb

val va_code_Load_one_lsb : dst:va_operand_xmm -> Tot va_code

val va_codegen_success_Load_one_lsb : dst:va_operand_xmm -> Tot va_pbool

val va_lemma_Load_one_lsb : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm
  -> Ghost (va_state & va_fuel)
  (requires (va_require_total va_b0 (va_code_Load_one_lsb dst) va_s0 /\ va_is_dst_xmm dst va_s0 /\
    va_get_ok va_s0 /\ sse_enabled))
  (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
    va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\ va_state_eq
    va_sM (va_update_flags va_sM (va_update_reg64 rR11 va_sM (va_update_ok va_sM
    (va_update_operand_xmm dst va_sM va_s0))))))
[@ va_qattr]
let va_wp_Load_one_lsb (dst:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
val va_wp_Load_one_lsb (dst: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
    : Type0

    dst: Vale.X64.Decls.va_operand_xmm ->
    va_s0: Vale.X64.Decls.va_state ->
    va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
  -> Type0