// File: /workspace/github_c_makefile_star2_O0/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:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movq -0x8(%rsp), %rax
movq %rax, -0x40(%rsp)
movb $0x1, -0x41(%rsp)
movl $0x16, %eax
subl -0xc(%rsp), %eax
movl %eax, -0x14(%rsp)
cmpl $0x0, -0x14(%rsp)
je 0x8755
movl $0x1, -0x10(%rsp)
cmpl $0x80, -0x10(%rsp)
jae 0x8746
movzbl -0x41(%rsp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x872d
movzbl -0x41(%rsp), %eax
shll %eax
xorl $0x71, %eax
movb %al, -0x41(%rsp)
jmp 0x8738
movzbl -0x41(%rsp), %eax
shll %eax
movb %al, -0x41(%rsp)
jmp 0x873a
movl -0x10(%rsp), %eax
shll %eax
movl %eax, -0x10(%rsp)
jmp 0x8704
jmp 0x8748
movl -0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x86f5
jmp 0x8757
movl $0x0, -0x10(%rsp)
cmpl $0x5, -0x10(%rsp)
jae 0x87cb
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %edx
addl $0x5, %edx
movl %edx, %edx
xorl (%rax,%rdx,4), %ecx
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %edx
addl $0xa, %edx
movl %edx, %edx
xorl (%rax,%rdx,4), %ecx
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %edx
addl $0xf, %edx
movl %edx, %edx
xorl (%rax,%rdx,4), %ecx
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %edx
addl $0x14, %edx
movl %edx, %edx
xorl (%rax,%rdx,4), %ecx
movl -0x10(%rsp), %eax
movl %ecx, -0x38(%rsp,%rax,4)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
jmp 0x875f
movl $0x0, -0x10(%rsp)
cmpl $0x5, -0x10(%rsp)
jae 0x8880
movl -0x10(%rsp), %eax
addl $0x4, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x107b0(%rip), %rax     # 0x18fa0
movzbl (%rax,%rcx), %eax
movl -0x38(%rsp,%rax,4), %eax
movl -0x10(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x10796(%rip), %rcx     # 0x18fa0
movzbl (%rcx,%rdx), %ecx
movl -0x38(%rsp,%rcx,4), %ecx
shll %ecx
movl -0x10(%rsp), %edx
addl $0x1, %edx
movl %edx, %edx
movl %edx, %esi
movq 0x1077a(%rip), %rdx     # 0x18fa0
movzbl (%rdx,%rsi), %edx
movl -0x38(%rsp,%rdx,4), %edx
shrl $0x1f, %edx
xorl %edx, %ecx
xorl %ecx, %eax
movl %eax, -0x18(%rsp)
movl $0x0, -0x14(%rsp)
cmpl $0x19, -0x14(%rsp)
jae 0x886e
movl -0x18(%rsp), %edx
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl -0x10(%rsp), %ecx
movl %ecx, %ecx
xorl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rsp), %eax
addl $0x5, %eax
movl %eax, -0x14(%rsp)
jmp 0x8841
jmp 0x8870
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
jmp 0x87d3
movq -0x40(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x18(%rsp)
movl $0x0, -0x10(%rsp)
cmpl $0x18, -0x10(%rsp)
jae 0x8924
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %ecx
movl %ecx, %edx
movq 0x1072f(%rip), %rcx     # 0x18fe0
movzbl (%rcx,%rdx), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rsp)
movl -0x18(%rsp), %edx
movl -0x10(%rsp), %eax
movl %eax, %ecx
movq 0x10723(%rip), %rax     # 0x18ff0
movzbl (%rax,%rcx), %ecx
shll %cl, %edx
movl -0x18(%rsp), %eax
movl -0x10(%rsp), %ecx
movl %ecx, %esi
movq 0x1070c(%rip), %rcx     # 0x18ff0
movzbl (%rcx,%rsi), %esi
movl $0x20, %ecx
subl %esi, %ecx
shrl %cl, %eax
xorl %eax, %edx
movq -0x40(%rsp), %rax
movl -0x10(%rsp), %ecx
movl %ecx, %esi
movq 0x106db(%rip), %rcx     # 0x18fe0
movzbl (%rcx,%rsi), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
jmp 0x8894
movl $0x0, -0x14(%rsp)
cmpl $0x19, -0x14(%rsp)
jae 0x8a21
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rsp)
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rsp)
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rsp)
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rsp)
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rsp)
movl $0x0, -0x10(%rsp)
cmpl $0x5, -0x10(%rsp)
jae 0x8a0f
movl -0x10(%rsp), %eax
movl -0x38(%rsp,%rax,4), %edx
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x105d7(%rip), %rax     # 0x18fa0
movzbl (%rax,%rcx), %eax
movl -0x38(%rsp,%rax,4), %eax
xorl $-0x1, %eax
movl -0x10(%rsp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movl %ecx, %esi
movq 0x105ba(%rip), %rcx     # 0x18fa0
movzbl (%rcx,%rsi), %ecx
andl -0x38(%rsp,%rcx,4), %eax
xorl %eax, %edx
movq -0x40(%rsp), %rax
movl -0x14(%rsp), %ecx
addl -0x10(%rsp), %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
jmp 0x89a8
jmp 0x8a11
movl -0x14(%rsp), %eax
addl $0x5, %eax
movl %eax, -0x14(%rsp)
jmp 0x892c
movl $0x0, -0x18(%rsp)
movl $0x1, -0x10(%rsp)
cmpl $0x80, -0x10(%rsp)
jae 0x8a96
movl -0x10(%rsp), %eax
cmpq $0x20, %rax
ja 0x8a5e
movzbl -0x41(%rsp), %eax
andl $0x1, %eax
movl -0x10(%rsp), %ecx
subl $0x1, %ecx
shll %cl, %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movzbl -0x41(%rsp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x8a7d
movzbl -0x41(%rsp), %eax
shll %eax
xorl $0x71, %eax
movb %al, -0x41(%rsp)
jmp 0x8a88
movzbl -0x41(%rsp), %eax
shll %eax
movb %al, -0x41(%rsp)
jmp 0x8a8a
movl -0x10(%rsp), %eax
shll %eax
movl %eax, -0x10(%rsp)
jmp 0x8a31
movl -0x18(%rsp), %ecx
movq -0x40(%rsp), %rax
xorl (%rax), %ecx
movl %ecx, (%rax)
movl -0xc(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rsp)
cmpl $0x0, %eax
jne 0x8757
retq
nopl (%rax,%rax)