// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/minalpherv11/avx2/MinalpherMode.cpp
// Function: tweak_update(long long vector[4]&, long long vector[4]&, int&)
static inline void tweak_update(__m256i& TWEAK, __m256i& xTWEAK, int& cnt)
{
  if ((cnt % 16) == 0)
  {
    __m256i ymmFB = _mm256_load_si256((__m256i*)FB);
    __m256i zero = _mm256_setzero_si256();

    xTWEAK = _mm256_and_si256(_mm256_cmpgt_epi8(zero, TWEAK), ymmFB);
    xTWEAK = _mm256_xor_si256(xTWEAK, _mm256_add_epi8(TWEAK, TWEAK));
  }
  cnt++;

  __m256i tmp = _mm256_permute2x128_si256(xTWEAK, TWEAK, 0x03);
  xTWEAK = _mm256_alignr_epi8(TWEAK, xTWEAK, 1);
  TWEAK  = _mm256_alignr_epi8(tmp, TWEAK, 1);

  __m256i ymmFBY = _mm256_load_si256((__m256i*)FBY);
  ymmFBY = _mm256_shuffle_epi8(xTWEAK, ymmFBY);
  ymmFBY = _mm256_permute2x128_si256(ymmFBY, ymmFBY, 0x0F);
  TWEAK  = _mm256_xor_si256(TWEAK, ymmFBY);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $-0x20, %rsp
subq $0x280, %rsp            # imm = 0x280
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq 0x88(%rsp), %rax
movl (%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x3c443
leaq 0x5ce7(%rip), %rax      # 0x42000
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
vmovdqa (%rax), %ymm0
vmovdqa %ymm0, 0x60(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa %ymm0, 0xa0(%rsp)
vmovdqa 0xa0(%rsp), %ymm0
vmovdqa %ymm0, 0x40(%rsp)
vmovdqa 0x40(%rsp), %ymm1
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm0
vmovdqa %ymm1, 0x1c0(%rsp)
vmovdqa %ymm0, 0x1a0(%rsp)
vmovdqa 0x1c0(%rsp), %ymm0
vmovdqa 0x1a0(%rsp), %ymm1
vpcmpgtb %ymm1, %ymm0, %k0
vpmovm2b %k0, %ymm1
vmovdqa 0x60(%rsp), %ymm0
vmovdqa %ymm1, 0x180(%rsp)
vmovdqa %ymm0, 0x160(%rsp)
vmovdqa 0x180(%rsp), %ymm0
vpand 0x160(%rsp), %ymm0, %ymm0
movq 0x90(%rsp), %rax
vmovdqa %ymm0, (%rax)
movq 0x90(%rsp), %rax
vmovdqa (%rax), %ymm1
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm2
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm0
vmovdqa %ymm2, 0x200(%rsp)
vmovdqa %ymm0, 0x1e0(%rsp)
vmovdqa 0x200(%rsp), %ymm0
vmovdqa 0x1e0(%rsp), %ymm2
vpaddb %ymm2, %ymm0, %ymm0
vmovdqa %ymm1, 0x140(%rsp)
vmovdqa %ymm0, 0x120(%rsp)
vmovdqa 0x140(%rsp), %ymm0
vpxor 0x120(%rsp), %ymm0, %ymm0
movq 0x90(%rsp), %rax
vmovdqa %ymm0, (%rax)
movq 0x88(%rsp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movq 0x90(%rsp), %rax
vmovdqa (%rax), %ymm1
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm0
vperm2i128 $0x21, %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm1[0,1]
vmovdqa %ymm0, 0x20(%rsp)
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm0
movq 0x90(%rsp), %rax
vmovdqa (%rax), %ymm1
vpalignr $0x1, %ymm1, %ymm0, %ymm0 # ymm0 = ymm1[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],ymm0[0],ymm1[17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],ymm0[16]
vmovdqa %ymm0, (%rax)
vmovdqa 0x20(%rsp), %ymm0
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm1
vpalignr $0x1, %ymm1, %ymm0, %ymm0 # ymm0 = ymm1[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],ymm0[0],ymm1[17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],ymm0[16]
vmovdqa %ymm0, (%rax)
leaq 0x5bc6(%rip), %rax      # 0x42080
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
vmovdqa (%rax), %ymm0
vmovdqa %ymm0, (%rsp)
movq 0x90(%rsp), %rax
vmovdqa (%rax), %ymm1
vmovdqa (%rsp), %ymm0
vmovdqa %ymm1, 0x240(%rsp)
vmovdqa %ymm0, 0x220(%rsp)
vmovdqa 0x240(%rsp), %ymm0
vmovdqa 0x220(%rsp), %ymm1
vpshufb %ymm1, %ymm0, %ymm0
vmovdqa %ymm0, (%rsp)
vmovdqa (%rsp), %ymm1
vperm2i128 $0x28, %ymm1, %ymm0, %ymm0 # ymm0 = zero,zero,ymm1[0,1]
vmovdqa %ymm0, (%rsp)
movq 0x98(%rsp), %rax
vmovdqa (%rax), %ymm1
vmovdqa (%rsp), %ymm0
vmovdqa %ymm1, 0x100(%rsp)
vmovdqa %ymm0, 0xe0(%rsp)
vmovdqa 0x100(%rsp), %ymm0
vpxor 0xe0(%rsp), %ymm0, %ymm0
movq 0x98(%rsp), %rax
vmovdqa %ymm0, (%rax)
movq %rbp, %rsp
popq %rbp
vzeroupper
retq
nopl (%rax,%rax)