// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/lunarkeyakv2/compact/KeccakP-1600-compact64.c
// Function: KeccakP1600_Permute_Nrounds
void KeccakP1600_Permute_Nrounds(void *argState, UINT8 rounds, UINT8 LFSRinitialState)
{
    tSmallUInt x, y, round;
    tKeccakLane        temp;
    tKeccakLane        BC[5];
    tKeccakLane     *state;
    UINT8           LFSRstate;

    state = (tKeccakLane*)argState;
    LFSRstate = LFSRinitialState;
    round = rounds;
    do
    {
        /* Theta */
        for ( x = 0; x < 5; ++x )
        {
            BC[x] = state[x] ^ state[5 + x] ^ state[10 + x] ^ state[15 + x] ^ state[20 + x];
        }
        for ( x = 0; x < 5; ++x )
        {
            temp = BC[MOD5(x+4)] ^ ROL64(BC[MOD5(x+1)], 1);
            for ( y = 0; y < 25; y += 5 )
            {
                state[y + x] ^= temp;
            }
        }

        /* Rho Pi */
        temp = state[1];
        for ( x = 0; x < 24; ++x )
        {
            BC[0] = state[KeccakP1600_PiLane[x]];
            state[KeccakP1600_PiLane[x]] = ROL64( temp, KeccakP1600_RotationConstants[x] );
            temp = BC[0];
        }

        /*    Chi */
        for ( y = 0; y < 25; y += 5 )
        {
#if defined(UNROLL_CHILOOP)
            BC[0] = state[y + 0];
            BC[1] = state[y + 1];
            BC[2] = state[y + 2];
            BC[3] = state[y + 3];
            BC[4] = state[y + 4];
#else
            for ( x = 0; x < 5; ++x )
            {
                BC[x] = state[y + x];
            }
#endif
            for ( x = 0; x < 5; ++x )
            {
                state[y + x] = BC[x] ^((~BC[MOD5(x+1)]) & BC[MOD5(x+2)]);
            }
        }

        /*    Iota */
        state[0] ^= KeccakF1600_GetNextRoundConstant(&LFSRstate);
    }
    while( --round != 0 );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x8(%rdi), %rax
movq 0xd60b(%rip), %rcx      # 0x12fd8
movl $0x1, %r8d
movabsq $0x1, %r9
movq 0xd5c4(%rip), %r10      # 0x12fa8
movq 0xd5cd(%rip), %r11      # 0x12fb8
leaq -0x28(%rsp), %rbx
xorl %r14d, %r14d
cmpq $0x5, %r14
je 0x5a1e
movq 0x28(%rdi,%r14,8), %r15
xorq (%rdi,%r14,8), %r15
xorq 0x50(%rdi,%r14,8), %r15
xorq 0x78(%rdi,%r14,8), %r15
xorq 0xa0(%rdi,%r14,8), %r15
movq %r15, -0x28(%rsp,%r14,8)
incq %r14
jmp 0x59f3
movq %rdi, %r14
xorl %r15d, %r15d
cmpq $0x5, %r15
je 0x5a5f
movzbl 0x4(%r15,%rcx), %r13d
movzbl 0x1(%rcx,%r15), %r12d
incq %r15
rorxq $0x3f, -0x28(%rsp,%r12,8), %r12
xorq -0x28(%rsp,%r13,8), %r12
xorl %r13d, %r13d
cmpq $0x18, %r13
ja 0x5a59
xorq %r12, (%r14,%r13,8)
addq $0x5, %r13
jmp 0x5a49
addq $0x8, %r14
jmp 0x5a24
xorl %r14d, %r14d
movq %rax, %r15
cmpq $0x18, %r14
je 0x5a9c
movq (%r15), %r15
movzbl (%r10,%r14), %r12d
movq (%rdi,%r12,8), %r13
movq %r13, -0x28(%rsp)
movb (%r11,%r14), %r13b
shlxq %r13, %r15, %rbp
negb %r13b
shrxq %r13, %r15, %r15
xorq %rbp, %r15
movq %r15, (%rdi,%r12,8)
incq %r14
movq %rbx, %r15
jmp 0x5a65
movq %rdi, %r14
xorl %r15d, %r15d
cmpq $0x18, %r15
ja 0x5af7
vmovups (%rdi,%r15,8), %ymm0
vmovups %ymm0, -0x28(%rsp)
movq 0x20(%rdi,%r15,8), %r12
movq %r12, -0x8(%rsp)
xorl %r12d, %r12d
cmpq $0x5, %r12
je 0x5aed
movzbl 0x1(%rcx,%r12), %r13d
movq -0x28(%rsp,%r13,8), %r13
movzbl 0x2(%rcx,%r12), %ebp
andnq -0x28(%rsp,%rbp,8), %r13, %r13
xorq -0x28(%rsp,%r12,8), %r13
movq %r13, (%r14,%r12,8)
incq %r12
jmp 0x5ac1
addq $0x5, %r15
addq $0x28, %r14
jmp 0x5aa2
movzbl %dl, %edx
xorl %r14d, %r14d
movl %r8d, %r15d
cmpl $0x7f, %r15d
ja 0x5b38
movl %edx, %ebp
addl %edx, %ebp
movl %ebp, %r12d
xorl $0x71, %r12d
testb %dl, %dl
cmovnsl %ebp, %r12d
leal -0x1(%r15), %r13d
testb $0x1, %dl
shlxq %r13, %r9, %rdx
movl $0x0, %r13d
cmovneq %rdx, %r13
xorq %r13, %r14
addl %r15d, %r15d
movl %r12d, %edx
jmp 0x5b00
xorq %r14, (%rdi)
decl %esi
jne 0x59f0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq