// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/scream10v3/sse/scream.c
// Function: LBox16P
static void LBox16P(v16qi *X) {
  int j;
  static const v16qi tables[8] = 
    {
      {0x00, 0x6d, 0xe0, 0x8d, 0x24, 0x49, 0xc4, 0xa9, 0xa5, 0xc8, 0x45, 0x28, 0x81, 0xec, 0x61, 0x0c, },
      {0x00, 0xd7, 0x3a, 0xed, 0xe5, 0x32, 0xdf, 0x08, 0xfe, 0x29, 0xc4, 0x13, 0x1b, 0xcc, 0x21, 0xf6, },
      {0x00, 0x5c, 0xa9, 0xf5, 0xb3, 0xef, 0x1a, 0x46, 0xc1, 0x9d, 0x68, 0x34, 0x72, 0x2e, 0xdb, 0x87, },
      {0x00, 0x38, 0x52, 0x6a, 0x7b, 0x43, 0x29, 0x11, 0x96, 0xae, 0xc4, 0xfc, 0xed, 0xd5, 0xbf, 0x87, },
      {0x00, 0x12, 0x6f, 0x7d, 0x1b, 0x09, 0x74, 0x66, 0xb1, 0xa3, 0xde, 0xcc, 0xaa, 0xb8, 0xc5, 0xd7, },
      {0x00, 0x67, 0x7a, 0x1d, 0x70, 0x17, 0x0a, 0x6d, 0x8a, 0xed, 0xf0, 0x97, 0xfa, 0x9d, 0x80, 0xe7, },
      {0x00, 0x4b, 0xaf, 0xe4, 0x33, 0x78, 0x9c, 0xd7, 0x74, 0x3f, 0xdb, 0x90, 0x47, 0x0c, 0xe8, 0xa3, },
      {0x00, 0x46, 0xf1, 0xb7, 0xa1, 0xe7, 0x50, 0x16, 0x7f, 0x39, 0x8e, 0xc8, 0xde, 0x98, 0x2f, 0x69, },
    };

  for (j=0; j<8; j+=2) {

    // Evaluate 2 series LBoxes in parallel, with 16-bit input
    // (X[4*j], X[4*j+2]) and (X[4*j+1], X[4*j+3]) ie (A,B) and (C,D)

#define A (X[j])
#define B (X[j+8])
#define C (X[j+1])
#define D (X[j+9])

    v16qi in[4] = {A, B, C, D};
    v16qi t0, t1;

    /* READ macro forces reload from memory */
#define READ(t,x)                                                       \
    __asm("movdqa %[tbl],%[data]\n":                                    \
          [data] "=x" (x):                                              \
          [tbl] "m" (t));                             
    
    v16qi table;

    READ(tables[0], table);

    t0 = shift_right(in[0]) & V(0xf);
    t1 = shift_right(in[2]) & V(0xf);

    A  = __builtin_ia32_pshufb128(table, t0);
    C  = __builtin_ia32_pshufb128(table, t1);

    READ(tables[1], table);

    B  = __builtin_ia32_pshufb128(table, t0);
    D  = __builtin_ia32_pshufb128(table, t1);

    READ(tables[2], table);

    in[0] &= V(0xf);
    in[2] &= V(0xf);

    A ^= __builtin_ia32_pshufb128(table, in[0]);
    C ^= __builtin_ia32_pshufb128(table, in[2]);

    READ(tables[3], table);

    B ^= __builtin_ia32_pshufb128(table, in[0]);
    D ^= __builtin_ia32_pshufb128(table, in[2]);

    READ(tables[4], table);

    t0 = shift_right(in[1]) & V(0xf);
    t1 = shift_right(in[3]) & V(0xf);

    A ^= __builtin_ia32_pshufb128(table, t0);
    C ^= __builtin_ia32_pshufb128(table, t1);

    READ(tables[5], table);

    B ^= __builtin_ia32_pshufb128(table, t0);
    D ^= __builtin_ia32_pshufb128(table, t1);

    READ(tables[6], table);

    in[1] &= V(0xf);
    in[3] &= V(0xf);

    A ^= __builtin_ia32_pshufb128(table, in[1]);
    C ^= __builtin_ia32_pshufb128(table, in[3]);

    READ(tables[7], table);

    B ^= __builtin_ia32_pshufb128(table, in[1]);
    D ^= __builtin_ia32_pshufb128(table, in[3]);

#undef READ
#undef A
#undef B
#undef C
#undef D
  }
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movl $0x0, 0x8c(%rsp)
cmpl $0x8, 0x8c(%rsp)
jge 0x337b
movq 0x90(%rsp), %rax
movslq 0x8c(%rsp), %rcx
shlq $0x4, %rcx
vmovdqa (%rax,%rcx), %xmm0
vmovdqa %xmm0, 0x40(%rsp)
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x80(%rax,%rcx), %xmm0
vmovdqa %xmm0, 0x50(%rsp)
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x10(%rax,%rcx), %xmm0
vmovdqa %xmm0, 0x60(%rsp)
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x90(%rax,%rcx), %xmm0
vmovdqa %xmm0, 0x70(%rsp)
movdqa 0x897b(%rip), %xmm0     # 0xb840
vmovaps %xmm0, 0x10(%rsp)
vmovdqa 0x40(%rsp), %xmm0
vpsrld $0x4, %xmm0, %xmm1
vmovdqa 0x8122(%rip), %xmm0     # 0xb000
vmovaps %xmm0, -0x80(%rsp)
vmovdqa %xmm0, (%rsp)
vmovdqa (%rsp), %xmm2
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x30(%rsp)
vmovdqa 0x60(%rsp), %xmm1
vpsrld $0x4, %xmm1, %xmm1
vmovdqa %xmm0, -0x10(%rsp)
vmovdqa -0x10(%rsp), %xmm2
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x20(%rsp)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x30(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm1
movq 0x90(%rsp), %rax
movslq 0x8c(%rsp), %rcx
shlq $0x4, %rcx
vmovdqa %xmm1, (%rax,%rcx)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x20(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm1
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa %xmm1, 0x10(%rax,%rcx)
movdqa 0x88da(%rip), %xmm1     # 0xb850
vmovaps %xmm1, 0x10(%rsp)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x30(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm1
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa %xmm1, 0x80(%rax,%rcx)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x20(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm1
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa %xmm1, 0x90(%rax,%rcx)
movdqa 0x8880(%rip), %xmm1     # 0xb860
vmovaps %xmm1, 0x10(%rsp)
vmovdqa %xmm0, -0x20(%rsp)
vmovdqa -0x20(%rsp), %xmm2
vmovdqa 0x40(%rsp), %xmm1
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x40(%rsp)
vmovdqa %xmm0, -0x30(%rsp)
vmovdqa -0x30(%rsp), %xmm2
vmovdqa 0x60(%rsp), %xmm1
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x60(%rsp)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x40(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rax
movslq 0x8c(%rsp), %rcx
shlq $0x4, %rcx
vmovdqa (%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, (%rax,%rcx)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x60(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x10(%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x10(%rax,%rcx)
movdqa 0x87e2(%rip), %xmm1     # 0xb870
vmovaps %xmm1, 0x10(%rsp)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x40(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x80(%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x80(%rax,%rcx)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x60(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x90(%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x90(%rax,%rcx)
movdqa 0x876e(%rip), %xmm1     # 0xb880
vmovaps %xmm1, 0x10(%rsp)
vmovdqa 0x50(%rsp), %xmm1
vpsrld $0x4, %xmm1, %xmm1
vmovdqa %xmm0, -0x40(%rsp)
vmovdqa -0x40(%rsp), %xmm2
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x30(%rsp)
vmovdqa 0x70(%rsp), %xmm1
vpsrld $0x4, %xmm1, %xmm1
vmovdqa %xmm0, -0x50(%rsp)
vmovdqa -0x50(%rsp), %xmm2
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x20(%rsp)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x30(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rax
movslq 0x8c(%rsp), %rcx
shlq $0x4, %rcx
vmovdqa (%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, (%rax,%rcx)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x20(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x10(%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x10(%rax,%rcx)
movdqa 0x86c6(%rip), %xmm1     # 0xb890
vmovaps %xmm1, 0x10(%rsp)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x30(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x80(%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x80(%rax,%rcx)
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x20(%rsp), %xmm2
vpshufb %xmm2, %xmm1, %xmm2
movq 0x90(%rsp), %rcx
movslq 0x8c(%rsp), %rax
shlq $0x4, %rax
vmovdqa 0x90(%rax,%rcx), %xmm1
vpxor %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x90(%rax,%rcx)
movdqa 0x8652(%rip), %xmm1     # 0xb8a0
vmovaps %xmm1, 0x10(%rsp)
vmovdqa %xmm0, -0x60(%rsp)
vmovdqa -0x60(%rsp), %xmm2
vmovdqa 0x50(%rsp), %xmm1
vpand %xmm2, %xmm1, %xmm1
vmovdqa %xmm1, 0x50(%rsp)
vmovdqa %xmm0, -0x70(%rsp)
vmovdqa -0x70(%rsp), %xmm0
vpand 0x70(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, 0x70(%rsp)
vmovdqa 0x10(%rsp), %xmm0
vmovdqa 0x50(%rsp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
movq 0x90(%rsp), %rax
movslq 0x8c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vpxor (%rax), %xmm0, %xmm0
vmovdqa %xmm0, (%rax)
vmovdqa 0x10(%rsp), %xmm0
vmovdqa 0x70(%rsp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
movq 0x90(%rsp), %rax
movl 0x8c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vpxor (%rax), %xmm0, %xmm0
vmovdqa %xmm0, (%rax)
movdqa 0x85bb(%rip), %xmm0     # 0xb8b0
vmovdqa %xmm0, 0x10(%rsp)
vmovdqa 0x10(%rsp), %xmm0
vmovdqa 0x50(%rsp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
movq 0x90(%rsp), %rax
movl 0x8c(%rsp), %ecx
addl $0x8, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vpxor (%rax), %xmm0, %xmm0
vmovdqa %xmm0, (%rax)
vmovdqa 0x10(%rsp), %xmm0
vmovdqa 0x70(%rsp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
movq 0x90(%rsp), %rax
movl 0x8c(%rsp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vpxor (%rax), %xmm0, %xmm0
vmovdqa %xmm0, (%rax)
movl 0x8c(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x8c(%rsp)
jmp 0x2e2a
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)