// File: /workspace/github_c_makefile_star2_O1/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
vpmovsxbq 0x86c7(%rip), %ymm0 # 0xe028
vpbroadcastq 0x86b6(%rip), %ymm1 # 0xe020
leaq 0x8(%rdi), %rax
movq 0xd663(%rip), %rcx      # 0x12fd8
movq 0xd62c(%rip), %r8       # 0x12fa8
movq 0xd635(%rip), %r9       # 0x12fb8
leaq -0x28(%rsp), %r10
movl $0x1, %r11d
xorl %ebx, %ebx
vpbroadcastq %rbx, %ymm2
vpor %ymm0, %ymm2, %ymm2
vpcmpltuq %ymm1, %ymm2, %k1
vmovdqu64 (%rdi,%rbx,8), %ymm2 {%k1} {z}
vmovdqu64 0x28(%rdi,%rbx,8), %ymm3 {%k1} {z}
vmovdqu64 0x50(%rdi,%rbx,8), %ymm4 {%k1} {z}
vmovdqu64 0x78(%rdi,%rbx,8), %ymm5 {%k1} {z}
vmovdqu64 0xa0(%rdi,%rbx,8), %ymm6 {%k1} {z}
vpternlogq $0x96, %ymm2, %ymm3, %ymm4
vpternlogq $0x96, %ymm5, %ymm4, %ymm6
vmovdqu64 %ymm6, -0x28(%rsp,%rbx,8) {%k1}
addq $0x4, %rbx
cmpq $0x8, %rbx
jne 0x5990
movq %rdi, %rbx
xorl %r14d, %r14d
movzbl 0x4(%r14,%rcx), %r12d
movzbl 0x1(%rcx,%r14), %r15d
incq %r14
rorxq $0x3f, -0x28(%rsp,%r15,8), %r15
xorq -0x28(%rsp,%r12,8), %r15
movq $-0x5, %r12
xorq %r15, 0x28(%rbx,%r12,8)
addq $0x5, %r12
cmpq $0x14, %r12
jb 0x5a1d
addq $0x8, %rbx
cmpq $0x5, %r14
jne 0x59fa
xorl %ebx, %ebx
movq %rax, %r14
movq (%r14), %r14
movzbl (%r8,%rbx), %r15d
movq (%rdi,%r15,8), %r12
movq %r12, -0x28(%rsp)
movb (%r9,%rbx), %r12b
shlxq %r12, %r14, %r13
negb %r12b
shrxq %r12, %r14, %r14
xorq %r13, %r14
movq %r14, (%rdi,%r15,8)
incq %rbx
movq %r10, %r14
cmpq $0x18, %rbx
jne 0x5a3b
movq %rdi, %rbx
xorl %r14d, %r14d
vmovdqu (%rdi,%r14,8), %ymm2
vmovdqu %ymm2, -0x28(%rsp)
movq 0x20(%rdi,%r14,8), %r15
movq %r15, -0x8(%rsp)
xorl %r15d, %r15d
movzbl 0x1(%rcx,%r15), %r12d
movq -0x28(%rsp,%r12,8), %r12
movzbl 0x2(%rcx,%r15), %r13d
andnq -0x28(%rsp,%r13,8), %r12, %r12
xorq -0x28(%rsp,%r15,8), %r12
movq %r12, (%rbx,%r15,8)
leaq 0x1(%r15), %r12
movq %r12, %r15
cmpq $0x5, %r12
jne 0x5a8f
leaq 0x5(%r14), %r15
addq $0x28, %rbx
cmpq $0x14, %r14
movq %r15, %r14
jb 0x5a76
movzbl %dl, %edx
movl $0x1, %r14d
xorl %ebx, %ebx
movl %edx, %ebp
movl %edx, %r15d
addl %edx, %r15d
movl %r15d, %edx
xorl $0x71, %edx
testb %bpl, %bpl
cmovnsl %r15d, %edx
leal -0x1(%r14), %r15d
testb $0x1, %bpl
shlxq %r15, %r11, %r15
movl $0x0, %r12d
cmovneq %r15, %r12
xorq %r12, %rbx
leal (%r14,%r14), %ebp
cmpl $0x40, %r14d
movl %ebp, %r14d
jb 0x5ad9
xorq %rbx, (%rdi)
decl %esi
jne 0x598e
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq