// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/lunarkeyakv2/compact/KeccakP-800-compact.c
// Function: KeccakP800_Permute_Nrounds
void KeccakP800_Permute_Nrounds(void *argState, tSmallUInt nr)
{
    tSmallUInt x, y;
    tKeccakLane temp;
    tKeccakLane BC[5];
    tKeccakLane *state;
    UINT8       LFSRstate;

    state = (tKeccakLane*)argState;
    LFSRstate = 0x01;
    for ( y = (tSmallUInt)(cKeccakNumberOfRounds - nr); y != 0; --y )
    {
        for( x = 1; x < 128; x <<= 1 )
        {
            if ((LFSRstate & 0x80) != 0)
                /* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
                LFSRstate = (LFSRstate << 1) ^ 0x71;
            else
                LFSRstate <<= 1;
        }
    }

    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)] ^ ROL32(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[KeccakP800_PiLane[x]];
            state[KeccakP800_PiLane[x]] = ROL32( temp, KeccakP800_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 */
        temp = 0;
        for( x = 1; x < 128; x <<= 1 )
        {
            if ( x <= (sizeof(tKeccakLane)*8) )
                temp ^= (tKeccakLane)(LFSRstate & 1) << (x - 1);

            if ((LFSRstate & 0x80) != 0)
                /* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
                LFSRstate = (LFSRstate << 1) ^ 0x71;
            else
                LFSRstate <<= 1;
        }
        state[0] ^= temp;
    }
    while( --nr != 0 );
}

// Assembly:
movb $0x1, %al
cmpl $0x16, %esi
je 0x6c58
movl $0x16, %ecx
subl %esi, %ecx
movb $0x1, %al
movl $0x1, %edx
leal (%rax,%rax), %r8d
movzbl %r8b, %r9d
xorb $0x71, %r8b
testb %al, %al
movzbl %r8b, %eax
cmovnsl %r9d, %eax
leal (%rdx,%rdx), %r8d
cmpl $0x40, %edx
movl %r8d, %edx
jb 0x6c32
decl %ecx
jne 0x6c2d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x4(%rdi), %rcx
leaq 0x14(%rdi), %rdx
movq %rdx, -0x8(%rsp)
leaq 0x28(%rdi), %rdx
movq %rdx, -0x10(%rsp)
leaq 0x3c(%rdi), %r9
leaq 0x50(%rdi), %r10
movb $0x1f, %dl
kmovd %edx, %k1
movq 0xc313(%rip), %r11      # 0x12fa0
movq 0xc34c(%rip), %rbx      # 0x12fe0
movq 0xc355(%rip), %r14      # 0x12ff0
leaq -0x28(%rsp), %r15
vmovdqu32 (%rdi), %ymm0 {%k1} {z}
movq -0x8(%rsp), %rdx
vmovdqu32 (%rdx), %ymm1 {%k1} {z}
movq -0x10(%rsp), %rdx
vmovdqu32 (%rdx), %ymm2 {%k1} {z}
vpternlogd $0x96, %ymm0, %ymm1, %ymm2
vmovdqu32 (%r9), %ymm0 {%k1} {z}
vmovdqu32 (%r10), %ymm1 {%k1} {z}
vpternlogd $0x96, %ymm0, %ymm2, %ymm1
vmovdqu32 %ymm1, -0x28(%rsp) {%k1}
movq %rdi, %r12
xorl %r13d, %r13d
movzbl 0x4(%r13,%r11), %edx
movzbl 0x1(%r11,%r13), %ebp
incq %r13
rorxl $0x1f, -0x28(%rsp,%rbp,4), %ebp
xorl -0x28(%rsp,%rdx,4), %ebp
movq $-0x5, %rdx
xorl %ebp, 0x14(%r12,%rdx,4)
addq $0x5, %rdx
cmpq $0x14, %rdx
jb 0x6d09
addq $0x4, %r12
cmpq $0x5, %r13
jne 0x6ce7
xorl %r12d, %r12d
movq %rcx, %rdx
movl (%rdx), %edx
movzbl (%rbx,%r12), %r13d
movl (%rdi,%r13,4), %ebp
movl %ebp, -0x28(%rsp)
movb (%r14,%r12), %bpl
shlxl %ebp, %edx, %r8d
negb %bpl
shrxl %ebp, %edx, %edx
xorl %r8d, %edx
movl %edx, (%rdi,%r13,4)
incq %r12
movq %r15, %rdx
cmpq $0x18, %r12
jne 0x6d28
movq %rdi, %r12
xorl %r13d, %r13d
vmovdqu (%rdi,%r13,4), %xmm0
vmovdqa %xmm0, -0x28(%rsp)
movl 0x10(%rdi,%r13,4), %edx
movl %edx, -0x18(%rsp)
xorl %ebp, %ebp
movzbl 0x1(%r11,%rbp), %edx
movl -0x28(%rsp,%rdx,4), %edx
movzbl 0x2(%r11,%rbp), %r8d
andnl -0x28(%rsp,%r8,4), %edx, %edx
xorl -0x28(%rsp,%rbp,4), %edx
movl %edx, (%r12,%rbp,4)
leaq 0x1(%rbp), %rdx
movq %rdx, %rbp
cmpq $0x5, %rdx
jne 0x6d78
leaq 0x5(%r13), %rdx
addq $0x14, %r12
cmpq $0x14, %r13
movq %rdx, %r13
jb 0x6d61
movl $0x1, %r12d
xorl %ebp, %ebp
cmpl $0x20, %r12d
ja 0x6dd7
movl %eax, %edx
andb $0x1, %dl
movzbl %dl, %edx
leal -0x1(%r12), %r8d
shlxl %r8d, %edx, %edx
xorl %edx, %ebp
leal (%rax,%rax), %edx
movzbl %dl, %r8d
xorb $0x71, %dl
testb %al, %al
movzbl %dl, %eax
cmovnsl %r8d, %eax
leal (%r12,%r12), %edx
cmpl $0x40, %r12d
movl %edx, %r12d
jb 0x6dbd
xorl %ebp, (%rdi)
decl %esi
jne 0x6ca0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq