// File: /workspace/github_c_makefile_star2_O3/mjosaarinen[P]brutus/crypto_aead/lunarkeyakv2/compact/KeccakP-200-compact.c
// Function: KeccakP200_Permute_Nrounds
void KeccakP200_Permute_Nrounds(void *argState, unsigned int nr)
{
    tSmallUInt x, y;
    tKeccakLane temp;
    tKeccakLane BC[5];
    tKeccakLane *state;
    const tKeccakLane *rc;

    state = (tKeccakLane*)argState;
    rc = KeccakF200_RoundConstants + 18 - nr;
    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)] ^ ROL8(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[KeccakP200_PiLane[x]];
            state[KeccakP200_PiLane[x]] = ROL8( temp, KeccakP200_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 = *(rc++);
        state[0] ^= temp;
    }
    while( temp != 0x80 );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ecx
movq 0xcc43(%rip), %rax      # 0x12ff8
subq %rcx, %rax
addq $0x12, %rax
leaq 0x5(%rdi), %rcx
movq %rcx, -0x8(%rsp)
leaq 0xa(%rdi), %rdx
leaq 0xf(%rdi), %rsi
leaq 0x14(%rdi), %r8
movw $0x1f, %r9w
kmovd %r9d, %k1
movq 0xcbe6(%rip), %r9       # 0x12fc8
movq 0xcbff(%rip), %r10      # 0x12fe8
movq 0xcba0(%rip), %r11      # 0x12f90
vmovdqu8 (%rdi), %xmm0 {%k1} {z}
movq -0x8(%rsp), %rcx
vmovdqu8 (%rcx), %xmm1 {%k1} {z}
vmovdqu8 (%rdx), %xmm2 {%k1} {z}
vpternlogq $0x96, %xmm0, %xmm1, %xmm2
vmovdqu8 (%rsi), %xmm0 {%k1} {z}
vmovdqu8 (%r8), %xmm1 {%k1} {z}
vpternlogq $0x96, %xmm0, %xmm2, %xmm1
vmovdqu8 %xmm1, -0x10(%rsp) {%k1}
movq %rdi, %rbx
xorl %r14d, %r14d
movzbl 0x4(%r14,%r9), %r15d
movzbl 0x1(%r9,%r14), %r12d
incq %r14
movb -0x10(%rsp,%r12), %bpl
rolb %bpl
xorb -0x10(%rsp,%r15), %bpl
movq $-0x5, %r15
xorb %bpl, 0x5(%rbx,%r15)
addq $0x5, %r15
cmpq $0x14, %r15
jb 0x6452
incq %rbx
cmpq $0x5, %r14
jne 0x642f
movb 0x1(%rdi), %bpl
xorl %ebx, %ebx
movzbl (%r10,%rbx), %r14d
movzbl %bpl, %ebp
movb (%rdi,%r14), %r15b
movb (%r11,%rbx), %r12b
andb $0x7, %r12b
shlxl %r12d, %ebp, %r13d
movb $0x8, %cl
subb %r12b, %cl
shrxl %ecx, %ebp, %ecx
xorl %r13d, %ecx
movb %cl, (%rdi,%r14)
incq %rbx
movl %r15d, %ebp
cmpq $0x18, %rbx
jne 0x6470
movq %rdi, %rbx
xorl %r14d, %r14d
movl (%rdi,%r14), %ebp
movl %ebp, -0x10(%rsp)
movb 0x4(%rdi,%r14), %cl
movb %cl, -0xc(%rsp)
shrl $0x8, %ebp
xorl %r15d, %r15d
notb %bpl
movzbl 0x2(%r9,%r15), %ecx
movb -0x10(%rsp,%rcx), %cl
andb %cl, %bpl
xorb -0x10(%rsp,%r15), %bpl
movb %bpl, (%rbx,%r15)
leaq 0x1(%r15), %r12
movl %ecx, %ebp
movq %r12, %r15
cmpq $0x5, %r12
jne 0x64c4
leaq 0x5(%r14), %rcx
addq $0x5, %rbx
cmpq $0x14, %r14
movq %rcx, %r14
jb 0x64ad
movb (%rax), %cl
incq %rax
xorb %cl, (%rdi)
cmpb $-0x80, %cl
jne 0x63f0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq