// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
vpmovsxbq 0x86c2(%rip), %ymm0 # 0xe028
vpbroadcastq 0x86b1(%rip), %ymm1 # 0xe020
movq 0xd662(%rip), %rax      # 0x12fd8
movq 0xd62b(%rip), %rcx      # 0x12fa8
movq 0xd634(%rip), %r8       # 0x12fb8
movl $0x1, %r9d
xorl %r10d, %r10d
vpbroadcastq %r10, %ymm2
vpor %ymm0, %ymm2, %ymm2
vpcmpltuq %ymm1, %ymm2, %k1
vmovdqu64 (%rdi,%r10,8), %ymm2 {%k1} {z}
vmovdqu64 0x28(%rdi,%r10,8), %ymm3 {%k1} {z}
vmovdqu64 0x50(%rdi,%r10,8), %ymm4 {%k1} {z}
vmovdqu64 0x78(%rdi,%r10,8), %ymm5 {%k1} {z}
vmovdqu64 0xa0(%rdi,%r10,8), %ymm6 {%k1} {z}
vpternlogq $0x96, %ymm2, %ymm3, %ymm4
vpternlogq $0x96, %ymm5, %ymm4, %ymm6
vmovdqu64 %ymm6, -0x30(%rsp,%r10,8) {%k1}
addq $0x4, %r10
cmpq $0x8, %r10
jne 0x598d
movq %rdi, %r10
xorl %r11d, %r11d
movzbl 0x4(%r11,%rax), %r14d
movzbl 0x1(%rax,%r11), %ebx
incq %r11
rorxq $0x3f, -0x30(%rsp,%rbx,8), %rbx
xorq -0x30(%rsp,%r14,8), %rbx
movq $-0x5, %r14
xorq %rbx, 0x28(%r10,%r14,8)
addq $0x5, %r14
cmpq $0x14, %r14
jb 0x5a1a
addq $0x8, %r10
cmpq $0x5, %r11
jne 0x59f7
movq 0x8(%rdi), %r11
xorl %r10d, %r10d
movzbl (%rcx,%r10), %ebx
movb (%r8,%r10), %r14b
shlxq %r14, %r11, %r15
negb %r14b
shrxq %r14, %r11, %r11
movq (%rdi,%rbx,8), %r14
xorq %r15, %r11
movq %r11, (%rdi,%rbx,8)
incq %r10
movq %r14, %r11
cmpq $0x18, %r10
jne 0x5a3a
movq %rdi, %r10
xorl %r11d, %r11d
vmovdqu (%rdi,%r11,8), %ymm2
movq 0x8(%rdi,%r11,8), %rbx
vmovdqu %ymm2, -0x30(%rsp)
movq 0x20(%rdi,%r11,8), %r14
movq %r14, -0x10(%rsp)
xorl %r14d, %r14d
movzbl 0x2(%rax,%r14), %r15d
movq -0x30(%rsp,%r15,8), %r15
andnq %r15, %rbx, %rbx
xorq -0x30(%rsp,%r14,8), %rbx
movq %rbx, (%r10,%r14,8)
leaq 0x1(%r14), %r12
movq %r15, %rbx
movq %r12, %r14
cmpq $0x5, %r12
jne 0x5a8b
leaq 0x5(%r11), %rbx
addq $0x28, %r10
cmpq $0x14, %r11
movq %rbx, %r11
jb 0x5a6d
movzbl %dl, %edx
movl $0x1, %r11d
xorl %r10d, %r10d
movl %edx, %ebx
movl %edx, %ebp
addl %edx, %ebp
movl %ebp, %edx
xorl $0x71, %edx
testb %bl, %bl
cmovnsl %ebp, %edx
leal -0x1(%r11), %r14d
testb $0x1, %bl
shlxq %r14, %r9, %rbx
movl $0x0, %r14d
cmovneq %rbx, %r14
xorq %r14, %r10
leal (%r11,%r11), %ebx
cmpl $0x40, %r11d
movl %ebx, %r11d
jb 0x5ad1
xorq %r10, (%rdi)
decl %esi
jne 0x598a
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
vzeroupper
retq