// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/acorn128/ref/encrypt.c
// Function: acorn128_initialization
void acorn128_initialization(const unsigned char *key, const unsigned char *iv, unsigned char *state)
{
        int i,j;
        unsigned char m[1536], ks, tem;

        //initialize the state to 0
        for (j = 0; j <= 292; j++) state[j] = 0;

        //set the value of m
        for (j = 0; j <= 127; j++) m[j]     = ( key[j/8] >> (j & 7) ) & 1;
        for (j = 0; j <= 127; j++) m[j+128] = ( iv[j/8]  >> (j & 7) ) & 1;
        m[256] = 1;
        for (j = 257; j <= 1535; j++) m[j]  = 0;

        //run the cipher for 1536 steps
        for (i = 0; i < 1536; i++)
        {
             Encrypt_StateUpdate128(state, m[i], &tem, &ks, 1, 1);
        }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x618, %rsp            # imm = 0x618
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
movl $0x125, %edx            # imm = 0x125
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1030
vmovq 0xafa(%rip), %xmm3      # 0x2000
vpbroadcastb 0xb01(%rip), %xmm0 # 0x2010
vpbroadcastb 0xaf9(%rip), %xmm1 # 0x2011
vpbroadcastb 0xaf1(%rip), %xmm2 # 0x2012
vpbroadcastb (%r15), %xmm4
vpand %xmm0, %xmm3, %xmm5
vpmovzxbw %xmm5, %ymm5    # ymm5 = xmm5[0],zero,xmm5[1],zero,xmm5[2],zero,xmm5[3],zero,xmm5[4],zero,xmm5[5],zero,xmm5[6],zero,xmm5[7],zero,xmm5[8],zero,xmm5[9],zero,xmm5[10],zero,xmm5[11],zero,xmm5[12],zero,xmm5[13],zero,xmm5[14],zero,xmm5[15],zero
vpmovzxbw %xmm4, %ymm4    # ymm4 = xmm4[0],zero,xmm4[1],zero,xmm4[2],zero,xmm4[3],zero,xmm4[4],zero,xmm4[5],zero,xmm4[6],zero,xmm4[7],zero,xmm4[8],zero,xmm4[9],zero,xmm4[10],zero,xmm4[11],zero,xmm4[12],zero,xmm4[13],zero,xmm4[14],zero,xmm4[15],zero
vpsrlvw %ymm5, %ymm4, %ymm4
vpmovwb %ymm4, %xmm4
vpand %xmm1, %xmm4, %xmm4
vmovq %xmm4, 0x10(%rsp,%r12)
addq $0x8, %r12
vpaddb %xmm2, %xmm3, %xmm3
incq %r15
cmpq $0x80, %r12
jne 0x1521
vmovq 0xa99(%rip), %xmm3      # 0x2000
movl $0x80, %eax
vpbroadcastb (%r14), %xmm4
vpand %xmm0, %xmm3, %xmm5
vpmovzxbw %xmm5, %ymm5    # ymm5 = xmm5[0],zero,xmm5[1],zero,xmm5[2],zero,xmm5[3],zero,xmm5[4],zero,xmm5[5],zero,xmm5[6],zero,xmm5[7],zero,xmm5[8],zero,xmm5[9],zero,xmm5[10],zero,xmm5[11],zero,xmm5[12],zero,xmm5[13],zero,xmm5[14],zero,xmm5[15],zero
vpmovzxbw %xmm4, %ymm4    # ymm4 = xmm4[0],zero,xmm4[1],zero,xmm4[2],zero,xmm4[3],zero,xmm4[4],zero,xmm4[5],zero,xmm4[6],zero,xmm4[7],zero,xmm4[8],zero,xmm4[9],zero,xmm4[10],zero,xmm4[11],zero,xmm4[12],zero,xmm4[13],zero,xmm4[14],zero,xmm4[15],zero
vpsrlvw %ymm5, %ymm4, %ymm4
vpmovwb %ymm4, %xmm4
vpand %xmm1, %xmm4, %xmm4
vmovq %xmm4, 0x10(%rsp,%rax)
vpaddb %xmm2, %xmm3, %xmm3
incq %r14
addq $0x8, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x156c
leaq 0x111(%rsp), %rdi
movb $0x1, -0x1(%rdi)
xorl %r12d, %r12d
movl $0x4ff, %edx            # imm = 0x4FF
xorl %esi, %esi
vzeroupper
callq 0x1030
leaq 0xe(%rsp), %r14
leaq 0xf(%rsp), %r15
movzbl 0x10(%rsp,%r12), %esi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x1040
incq %r12
cmpq $0x600, %r12            # imm = 0x600
jne 0x15d0
addq $0x618, %rsp            # imm = 0x618
popq %rbx
popq %r12
popq %r14
popq %r15
retq