// File: /workspace/github_c_makefile_star2_O3/mjosaarinen[P]brutus/crypto_aead/aezv4/aesni/encrypt.c
// Function: aez_setup
void aez_setup(unsigned char *key, unsigned keylen, aez_ctx_t *ctx) {
    block tmp;
    if (keylen==48) {
        ctx->I[0] = loadu(key);
        ctx->J[0] = loadu(key+16);
        ctx->L    = loadu(key+32);
    } else {
        blake2b(ctx, 48, 0, 0, key, keylen);    /* Puts IJL into ctx */
        ctx->J[0] = ctx->I[1];                  /* Rearrange.        */
        ctx->L    = ctx->I[2];
    }
    /* Fill ctx with J doublings */
    ctx->I[1] = bswap16(tmp = double_block(bswap16(ctx->I[0])));
    ctx->I[2] = bswap16(tmp = double_block(tmp));
    ctx->J[1] = bswap16(tmp = double_block(bswap16(ctx->J[0])));
    ctx->J[2] = bswap16(tmp = double_block(tmp));
    ctx->delta3_cache = zero;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe0, %rsp
movq %rdx, %rbx
movq %rdi, %r14
cmpl $0x30, %esi
jne 0x120e
vmovdqu (%r14), %xmm1
vmovdqa %xmm1, (%rbx)
vmovdqu 0x10(%r14), %xmm0
vmovdqa %xmm0, 0x30(%rbx)
vmovups 0x20(%r14), %xmm2
jmp 0x147d
vmovups 0x2eda(%rip), %ymm0     # 0x40f0
vmovups %ymm0, 0x80(%rsp)
vmovdqu 0x2ee9(%rip), %ymm0     # 0x4110
vmovdqu %ymm0, 0xa0(%rsp)
movabsq $0x6a09e667f2bdc938, %rax # imm = 0x6A09E667F2BDC938
movq %rax, 0x80(%rsp)
vpxor %xmm6, %xmm6, %xmm6
vmovdqa %xmm6, 0xc0(%rsp)
movq $0x0, 0xd0(%rsp)
movq $0x30, 0xd8(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqu %ymm0, (%rsp)
vmovdqu %ymm0, 0x20(%rsp)
vmovdqu %ymm0, 0x40(%rsp)
vmovdqu %ymm0, 0x60(%rsp)
testl %esi, %esi
je 0x1314
movl %esi, %r12d
xorl %r13d, %r13d
movq %rsp, %r15
movq 0xd0(%rsp), %rax
cmpq $0x80, %rax
jne 0x12d4
movq 0xc0(%rsp), %rax
subq $-0x80, %rax
movq %rax, 0xc0(%rsp)
jb 0x12c1
incq 0xc8(%rsp)
movq %r15, %rdi
xorl %esi, %esi
vzeroupper
callq 0x31b6
xorl %eax, %eax
vpxor %xmm6, %xmm6, %xmm6
movb (%r14,%r13), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0xd0(%rsp)
movb %cl, (%rsp,%rax)
incq %r13
cmpq %r13, %r12
jne 0x1293
movq 0xd0(%rsp), %rcx
addq %rcx, 0xc0(%rsp)
jae 0x1309
incq 0xc8(%rsp)
cmpq $0x7f, %rcx
jbe 0x1316
jmp 0x13d7
xorl %ecx, %ecx
movl $0x83, %eax
subl %ecx, %eax
andl $0xfc, %eax
movq %rcx, %rdx
xorq $0x7f, %rdx
vpbroadcastq %rcx, %ymm0
vpaddq 0x2cc9(%rip), %ymm0, %ymm0 # 0x4000
vpbroadcastq %rdx, %ymm1
addq %rsp, %rcx
xorl %edx, %edx
vpmovsxbq 0x2d55(%rip), %ymm2 # 0x40a0
vpcmpeqd %ymm3, %ymm3, %ymm3
vpbroadcastq 0x2cc8(%rip), %ymm4 # 0x4020
vpbroadcastq %rdx, %ymm5
vpor %ymm2, %ymm5, %ymm5
vpcmpleuq %ymm1, %ymm5, %k1
vpsubq %ymm3, %ymm0, %ymm5
kmovd %k1, %esi
testb $0x1, %sil
je 0x1380
vmovq %xmm5, 0xd0(%rsp)
kmovd %k1, %esi
testb $0x2, %sil
je 0x1395
vpextrq $0x1, %xmm5, 0xd0(%rsp)
kmovd %k1, %esi
vextracti128 $0x1, %ymm5, %xmm5
testb $0x4, %sil
je 0x13ae
vmovq %xmm5, 0xd0(%rsp)
kmovd %k1, %esi
testb $0x8, %sil
je 0x13c3
vpextrq $0x1, %xmm5, 0xd0(%rsp)
vmovdqu8 %xmm6, (%rcx,%rdx) {%k1}
addq $0x4, %rdx
vpaddq %ymm4, %ymm0, %ymm0
cmpq %rdx, %rax
jne 0x1358
movq %rsp, %r14
movq %r14, %rdi
movl $0x1, %esi
vzeroupper
callq 0x31b6
movq 0xd8(%r14), %rdx
testq %rdx, %rdx
je 0x146a
leaq 0x80(%rsp), %rax
leaq 0x3(%rdx), %rcx
andq $-0x4, %rcx
decq %rdx
vpmovsxbq 0x2c8e(%rip), %ymm0 # 0x40a0
vpbroadcastq %rdx, %ymm1
xorl %edx, %edx
vpbroadcastq 0x2c05(%rip), %ymm2 # 0x4028
vpbroadcastq 0x2bf4(%rip), %ymm3 # 0x4020
vpcmpleuq %ymm1, %ymm0, %k1
vpsrlq $0x3, %ymm0, %ymm4
kmovq %k1, %k2
vpxor %xmm5, %xmm5, %xmm5
vpgatherqq (%rax,%ymm4,8), %ymm5 {%k2}
vpsllq $0x3, %ymm0, %ymm4
vpand %ymm2, %ymm4, %ymm4
vpsrlvq %ymm4, %ymm5, %ymm4
vpmovqb %ymm4, (%rbx,%rdx) {%k1}
addq $0x4, %rdx
vpaddq %ymm3, %ymm0, %ymm0
cmpq %rdx, %rcx
jne 0x142c
vmovdqa (%rbx), %xmm1
vmovdqa 0x10(%rbx), %xmm0
vmovaps 0x20(%rbx), %xmm2
vmovdqa %xmm0, 0x30(%rbx)
vmovaps %xmm2, 0x60(%rbx)
vmovdqa 0x2ba6(%rip), %xmm2     # 0x4030
vpshufb %xmm2, %xmm1, %xmm1
vpshufd $0x93, %xmm1, %xmm3     # xmm3 = xmm1[3,0,1,2]
vpsrad $0x1f, %xmm3, %xmm3
vpshufd $0x93, 0x2b9e(%rip), %xmm4 # xmm4 = mem[3,0,1,2]
vpaddd %xmm1, %xmm1, %xmm1
vpternlogd $0x6c, %xmm4, %xmm1, %xmm3
vpshufb %xmm2, %xmm3, %xmm5
vmovdqa %xmm5, 0x10(%rbx)
vpshufd $0x93, %xmm1, %xmm1     # xmm1 = xmm1[3,0,1,2]
vpsrad $0x1f, %xmm1, %xmm1
vpaddd %xmm3, %xmm3, %xmm3
vpternlogd $0x78, %xmm4, %xmm1, %xmm3
vpshufb %xmm2, %xmm3, %xmm1
vmovdqa %xmm1, 0x20(%rbx)
vpshufb %xmm2, %xmm0, %xmm0
vpshufd $0x93, %xmm0, %xmm1     # xmm1 = xmm0[3,0,1,2]
vpsrad $0x1f, %xmm1, %xmm1
vpaddd %xmm0, %xmm0, %xmm0
vpternlogd $0x6c, %xmm4, %xmm0, %xmm1
vpshufb %xmm2, %xmm1, %xmm3
vmovdqa %xmm3, 0x40(%rbx)
vpshufd $0x93, %xmm0, %xmm0     # xmm0 = xmm0[3,0,1,2]
vpsrad $0x1f, %xmm0, %xmm0
vpaddd %xmm1, %xmm1, %xmm1
vpternlogd $0x78, %xmm4, %xmm0, %xmm1
vpshufb %xmm2, %xmm1, %xmm0
vmovdqa %xmm0, 0x50(%rbx)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa %xmm0, 0x70(%rbx)
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
vzeroupper
retq