// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/norx6444v2/ref/norx.c
// Function: norx_decrypt_data
void norx_decrypt_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_decrypt_block(lane[i%NORX_P], out, in);
            #if defined(NORX_DEBUG)
            printf("Decrypt 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_decrypt_lastblock(lane[i%NORX_P], out, in, inlen);
        #if defined(NORX_DEBUG)
        printf("Decrypt 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("Decryption finalised\n");
        norx_debug(state, NULL, 0, NULL, 0);
        #endif
    }
}

// Assembly:
testq %rcx, %rcx
je 0x16bf
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 0x156b
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 0x1523
xorl %ebp, %ebp
movl %ebp, %eax
andl $0x3, %eax
shll $0x7, %eax
leaq (%rsp,%rax), %r13
addq $0x60, %r13
cmpq $0x60, %r14
jb 0x15c3
xorb $0x2, 0x78(%r13)
movq %r13, %rdi
callq 0x1989
xorl %eax, %eax
cmpq $0xc, %rax
je 0x15b2
movq (%r12,%rax,8), %rcx
movq (%r13,%rax,8), %rdx
xorq %rcx, %rdx
movq %rdx, (%r15,%rax,8)
movq %rcx, (%r13,%rax,8)
incq %rax
jmp 0x1592
addq $-0x60, %r14
addq $0x60, %r15
addq $0x60, %r12
incq %rbp
jmp 0x156d
xorb $0x2, 0x78(%r13)
movq %r13, %rdi
callq 0x1989
movzbl %bpl, %ebp
andl $0x3, %ebp
shll $0x7, %ebp
leaq (%rsp,%rbp), %rax
addq $0x60, %rax
xorl %ecx, %ecx
cmpq $0xc, %rcx
je 0x15f7
movq (%rax,%rcx,8), %rdx
movq %rdx, (%rsp,%rcx,8)
incq %rcx
jmp 0x15e4
movq %rsp, %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x10c0
xorb $0x1, (%rsp,%r14)
xorb $-0x80, 0x5f(%r13)
leaq (%rsp,%rbp), %rax
addq $0x60, %rax
xorl %ecx, %ecx
cmpq $0xc, %rcx
je 0x163a
movq (%rsp,%rcx,8), %rdx
movq (%rax,%rcx,8), %rsi
xorq %rdx, %rsi
movq %rsi, (%rsp,%rcx,8)
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x161c
movq %rsp, %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x10c0
movq 0x27b6(%rip), %rax      # 0x3e08
xorl %r15d, %r15d
pushq $0x60
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq *%rax
vxorps %xmm0, %xmm0, %xmm0
vmovups %ymm0, 0x60(%rbx)
vmovups %ymm0, 0x40(%rbx)
vmovups %ymm0, 0x20(%rbx)
vmovups %ymm0, (%rbx)
cmpq $0x200, %r15            # imm = 0x200
je 0x16ae
leaq (%rsp,%r15), %r14
addq $0x60, %r14
movq %rbx, %rdi
movq %r14, %rsi
vzeroupper
callq 0x14c3
movq 0x276c(%rip), %rax      # 0x3e08
movl $0x80, %edx
movq %r14, %rdi
xorl %esi, %esi
callq *%rax
subq $-0x80, %r15
jmp 0x1676
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq