// File: /workspace/github_c_makefile_star2_O1/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 0x1208
vmovups (%r14), %xmm0
vmovaps %xmm0, (%rbx)
vmovups 0x10(%r14), %xmm0
vmovaps %xmm0, 0x30(%rbx)
jmp 0x1483
vmovups 0x2ee0(%rip), %ymm0     # 0x40f0
vmovups %ymm0, 0x80(%rsp)
vmovdqu 0x2eef(%rip), %ymm0     # 0x4110
xorl $0x1010030, 0x80(%rsp) # imm = 0x1010030
vmovdqu %ymm0, 0xa0(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa %xmm0, 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 0x12ef
movl %esi, %r12d
xorl %r13d, %r13d
movq %rsp, %r15
movq 0xd0(%rsp), %rax
cmpq $0x80, %rax
jne 0x12cc
movq 0xc0(%rsp), %rcx
subq $-0x80, %rcx
movq %rcx, 0xc0(%rsp)
cmpq %rax, %rcx
jae 0x12b3
incq 0xc8(%rsp)
movq %r15, %rdi
xorl %esi, %esi
vzeroupper
callq 0x3229
movq $0x0, 0xd0(%rsp)
movb (%r14,%r13), %al
movq 0xd0(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0xd0(%rsp)
movb %al, (%rsp,%rcx)
incq %r13
cmpq %r13, %r12
jne 0x1282
movq 0xd0(%rsp), %rcx
addq %rcx, 0xc0(%rsp)
jae 0x1309
incq 0xc8(%rsp)
cmpq $0x7f, %rcx
ja 0x13e3
movl $0x83, %eax
subl %ecx, %eax
andl $0xfc, %eax
movl $0x7f, %edx
subq %rcx, %rdx
vpbroadcastq %rcx, %ymm0
vpaddq 0x2ccb(%rip), %ymm0, %ymm0 # 0x4000
vpbroadcastq %rdx, %ymm1
addq %rsp, %rcx
xorl %edx, %edx
vpmovsxbq 0x2d57(%rip), %ymm2 # 0x40a0
vpcmpeqd %ymm3, %ymm3, %ymm3
vpxor %xmm4, %xmm4, %xmm4
vpbroadcastq 0x2cc6(%rip), %ymm5 # 0x4020
vpbroadcastq %rdx, %ymm6
vpor %ymm2, %ymm6, %ymm6
vpcmpleuq %ymm1, %ymm6, %k1
vpsubq %ymm3, %ymm0, %ymm6
kmovd %k1, %esi
testb $0x1, %sil
je 0x1382
vmovq %xmm6, 0xd0(%rsp)
kmovd %k1, %esi
testb $0x2, %sil
je 0x1397
vpextrq $0x1, %xmm6, 0xd0(%rsp)
kmovd %k1, %esi
testb $0x4, %sil
je 0x13b0
vextracti128 $0x1, %ymm6, %xmm7
vmovq %xmm7, 0xd0(%rsp)
kmovd %k1, %esi
testb $0x8, %sil
je 0x13cb
vextracti128 $0x1, %ymm6, %xmm6
vpextrq $0x1, %xmm6, 0xd0(%rsp)
vmovdqu8 %xmm4, (%rcx,%rdx) {%k1}
addq $0x4, %rdx
vpaddq %ymm5, %ymm0, %ymm0
cmpq %rdx, %rax
jne 0x135a
movq %rsp, %r14
movq %r14, %rdi
movl $0x1, %esi
vzeroupper
callq 0x3229
movq 0xd8(%r14), %rdx
testq %rdx, %rdx
je 0x1476
leaq 0x80(%rsp), %rax
leaq 0x3(%rdx), %rcx
andq $-0x4, %rcx
decq %rdx
vpmovsxbq 0x2c82(%rip), %ymm0 # 0x40a0
vpbroadcastq %rdx, %ymm1
xorl %edx, %edx
vpbroadcastq 0x2bf9(%rip), %ymm2 # 0x4028
vpbroadcastq 0x2be8(%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 0x1438
vmovaps 0x10(%rbx), %xmm0
vmovaps %xmm0, 0x30(%rbx)
movq %rbx, %r14
vmovups 0x20(%r14), %xmm0
vmovaps %xmm0, 0x60(%rbx)
vmovdqa (%rbx), %xmm0
vmovdqa 0x30(%rbx), %xmm1
vmovdqa 0x2b91(%rip), %xmm2     # 0x4030
vpshufb %xmm2, %xmm0, %xmm0
vpshufd $0x93, %xmm0, %xmm3     # xmm3 = xmm0[3,0,1,2]
vpsrad $0x1f, %xmm3, %xmm3
vpshufd $0x93, 0x2b89(%rip), %xmm4 # xmm4 = mem[3,0,1,2]
vpaddd %xmm0, %xmm0, %xmm0
vpternlogd $0x6c, %xmm4, %xmm0, %xmm3
vpshufb %xmm2, %xmm3, %xmm5
vmovdqa %xmm5, 0x10(%rbx)
vpshufd $0x93, %xmm0, %xmm0     # xmm0 = xmm0[3,0,1,2]
vpsrad $0x1f, %xmm0, %xmm0
vpaddd %xmm3, %xmm3, %xmm3
vpternlogd $0x78, %xmm4, %xmm0, %xmm3
vpshufb %xmm2, %xmm3, %xmm0
vmovdqa %xmm0, 0x20(%rbx)
vpshufb %xmm2, %xmm1, %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