// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/norx6444v2/ref/norx.c
// Function: norx_encrypt_data
void norx_encrypt_data(norx_state_t state, unsigned char *out, const unsigned char * in, size_t inlen)
{
    if (inlen > 0)
    {
        size_t i;
        norx_state_t lane[NORX_P];

        /* Initialize states + branch */
        for (i = 0; i < NORX_P; ++i) {
            memcpy(lane[i], state, sizeof lane[i]);
            norx_branch(lane[i], i);
        }

        /* Parallel payload processing */
        for (i = 0; inlen >= BYTES(NORX_R); ++i) {
            norx_encrypt_block(lane[i%NORX_P], out, in);
            #if defined(NORX_DEBUG)
            printf("Encrypt block (lane: %lu)\n", i%NORX_P);
            norx_debug(lane[i%NORX_P], in, BYTES(NORX_R), out, BYTES(NORX_R));
            #endif
            inlen -= BYTES(NORX_R);
            out   += BYTES(NORX_R);
            in    += BYTES(NORX_R);
        }
        norx_encrypt_lastblock(lane[i%NORX_P], out, in, inlen);
        #if defined(NORX_DEBUG)
        printf("Encrypt lastblock (lane: %lu)\n", i%NORX_P);
        norx_debug(lane[i%NORX_P], in, inlen, out, inlen);
        #endif

        /* Merge */
        memset(state, 0, sizeof(norx_state_t));
        for (i = 0; i < NORX_P; ++i) {
            norx_merge(state, lane[i]);
            burn(lane[i], 0, sizeof(norx_state_t));
        }

        #if defined(NORX_DEBUG)
        printf("Encryption finalised\n");
        norx_debug(state, NULL, 0, NULL, 0);
        #endif
    }
}

// Assembly:
testq %rcx, %rcx
je 0x1466
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
xorl %ebp, %ebp
cmpq $0x4, %rbp
je 0x1380
vmovups (%rbx), %ymm0
vmovups 0x20(%rbx), %ymm1
vmovups 0x40(%rbx), %ymm2
vmovups 0x60(%rbx), %ymm3
vmovups %ymm3, 0x60(%r13)
vmovups %ymm2, 0x40(%r13)
vmovups %ymm1, 0x20(%r13)
vmovups %ymm0, (%r13)
movq %r13, %rdi
movq %rbp, %rsi
vzeroupper
callq 0x146a
incq %rbp
subq $-0x80, %r13
jmp 0x1338
xorl %ebp, %ebp
movl %ebp, %eax
andl $0x3, %eax
shll $0x7, %eax
leaq (%rsp,%rax), %r13
addq $0x60, %r13
cmpq $0x60, %r14
jb 0x13b7
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1489
addq $-0x60, %r14
addq $0x60, %r15
addq $0x60, %r12
incq %rbp
jmp 0x1382
vxorps %xmm0, %xmm0, %xmm0
movq %rsp, %rbp
vmovups %ymm0, 0x40(%rbp)
vmovups %ymm0, 0x20(%rbp)
vmovups %ymm0, (%rbp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
vzeroupper
callq 0x10c0
movb $0x1, (%rsp,%r14)
orb $-0x80, 0x5f(%rbp)
movq %r13, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x1489
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x10c0
vxorps %xmm0, %xmm0, %xmm0
vmovups %ymm0, 0x60(%rbx)
vmovups %ymm0, 0x40(%rbx)
vmovups %ymm0, 0x20(%rbx)
vmovups %ymm0, (%rbx)
xorl %r15d, %r15d
cmpq $0x200, %r15            # imm = 0x200
je 0x1455
leaq (%rsp,%r15), %r14
addq $0x60, %r14
movq %rbx, %rdi
movq %r14, %rsi
vzeroupper
callq 0x14c3
movq 0x29c5(%rip), %rax      # 0x3e08
movl $0x80, %edx
movq %r14, %rdi
xorl %esi, %esi
callq *%rax
subq $-0x80, %r15
jmp 0x141d
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq