// File: /workspace/github_c_makefile_star2_O3/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 0x1829
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movq %rcx, 0x8(%rsp)
xorl %ebp, %ebp
movq %rbp, %rax
shlq $0x7, %rax
leaq (%rsp,%rax), %r13
addq $0x80, %r13
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)
xorb $0x10, 0x78(%r13)
movl $0x4, %r14d
movq %r13, %rdi
vzeroupper
callq 0x1c6a
decq %r14
jne 0x15fd
xorq %rbp, 0x68(%r13)
incq %rbp
cmpq $0x4, %rbp
jne 0x15b5
movq 0x8(%rsp), %rcx
cmpq $0x60, %rcx
jb 0x16cd
leaq -0x60(%rcx), %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
mulxq %rax, %rax, %rax
shrq $0x6, %rax
movq %rax, 0x18(%rsp)
incq %rax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
movq %rcx, 0x8(%rsp)
movl %ebp, %eax
andl $0x3, %eax
shll $0x7, %eax
leaq (%rsp,%rax), %r13
addq $0x80, %r13
xorb $0x2, 0x78(%r13)
movl $0x4, %r14d
movq %r13, %rdi
callq 0x1c6a
decq %r14
jne 0x1672
xorl %eax, %eax
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
cmpq $0xc, %rax
jne 0x1681
movq 0x8(%rsp), %rcx
addq $-0x60, %rcx
addq $0x60, %r15
addq $0x60, %r12
leaq 0x1(%rbp), %rax
cmpq 0x18(%rsp), %rbp
movq %rax, %rbp
jne 0x164f
movq %rcx, 0x8(%rsp)
movq 0x10(%rsp), %rax
andl $0x3, %eax
jmp 0x16cf
xorl %eax, %eax
shll $0x7, %eax
leaq (%rsp,%rax), %r13
addq $0x80, %r13
xorb $0x2, 0x78(%r13)
movl $0x4, %r14d
movq %r13, %rdi
callq 0x1c6a
decq %r14
jne 0x16e8
vmovups (%r13), %ymm0
vmovups 0x20(%r13), %ymm1
vmovups 0x40(%r13), %ymm2
leaq 0x20(%rsp), %rbp
vmovups %ymm2, 0x40(%rbp)
vmovups %ymm1, 0x20(%rbp)
vmovups %ymm0, (%rbp)
movq %rbp, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
vzeroupper
callq 0x10b0
xorb $0x1, 0x20(%rsp,%r14)
xorb $-0x80, 0x5f(%rbp)
xorl %eax, %eax
vmovups 0x20(%rsp,%rax,8), %ymm0
vxorps (%r13,%rax,8), %ymm0, %ymm1
vmovups %ymm1, 0x20(%rsp,%rax,8)
vmovups %ymm0, (%r13,%rax,8)
addq $0x4, %rax
cmpq $0xc, %rax
jne 0x173d
leaq 0x20(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
vzeroupper
callq 0x10b0
movq 0x268a(%rip), %rax      # 0x3e08
xorl %r15d, %r15d
movl $0x60, %edx
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)
leaq 0x80(%rsp), %r12
movq %r15, %rax
shlq $0x7, %rax
leaq (%rsp,%rax), %r14
addq $0x80, %r14
xorb $0x20, 0x78(%r14)
movl $0x4, %r13d
movq %r14, %rdi
vzeroupper
callq 0x1c6a
decq %r13
jne 0x17c9
xorl %eax, %eax
vmovups (%rbx,%rax,8), %ymm0
vxorps (%r12,%rax,8), %ymm0, %ymm0
vmovups %ymm0, (%rbx,%rax,8)
addq $0x4, %rax
cmpq $0x10, %rax
jne 0x17db
movq 0x260c(%rip), %rax      # 0x3e08
movl $0x80, %edx
movq %r14, %rdi
xorl %esi, %esi
vzeroupper
callq *%rax
incq %r15
subq $-0x80, %r12
cmpq $0x4, %r15
jne 0x17ac
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq