// File: /workspace/github_cpp_makefile_star2_O1/adamjanovsky[P]PA193_test_parser_monero/src/keccak/Keccak-readable-and-compact.c
// Function: KeccakF1600_StatePermute
void KeccakF1600_StatePermute(void *state)
{
    unsigned int round, x, y, j, t;
    UINT8 LFSRstate = 0x01;
    
    for(round=0; round<24; round++) {
        {   /* === θ step (see [Keccak Reference, Section 2.3.2]) === */
            tKeccakLane C[5], D;
            
            /* Compute the parity of the columns */
            for(x=0; x<5; x++)
                C[x] = readLane(x, 0) ^ readLane(x, 1) ^ readLane(x, 2) ^ readLane(x, 3) ^ readLane(x, 4);
            for(x=0; x<5; x++) {
                /* Compute the θ effect for a given column */
                D = C[(x+4)%5] ^ ROL64(C[(x+1)%5], 1);
                /* Add the θ effect to the whole column */
                for (y=0; y<5; y++)
                    XORLane(x, y, D);
            }
        }
        
        {   /* === ρ and π steps (see [Keccak Reference, Sections 2.3.3 and 2.3.4]) === */
            tKeccakLane current, temp;
            /* Start at coordinates (1 0) */
            x = 1; y = 0;
            current = readLane(x, y);
            /* Iterate over ((0 1)(2 3))^t * (1 0) for 0 ≤ t ≤ 23 */
            for(t=0; t<24; t++) {
                /* Compute the rotation constant r = (t+1)(t+2)/2 */
                unsigned int r = ((t+1)*(t+2)/2)%64;
                /* Compute ((0 1)(2 3)) * (x y) */
                unsigned int Y = (2*x+3*y)%5; x = y; y = Y;
                /* Swap current and state(x,y), and rotate */
                temp = readLane(x, y);
                writeLane(x, y, ROL64(current, r));
                current = temp;
            }
        }
        
        {   /* === χ step (see [Keccak Reference, Section 2.3.1]) === */
            tKeccakLane temp[5];
            for(y=0; y<5; y++) {
                /* Take a copy of the plane */
                for(x=0; x<5; x++)
                    temp[x] = readLane(x, y);
                /* Compute χ on the plane */
                for(x=0; x<5; x++)
                    writeLane(x, y, temp[x] ^((~temp[(x+1)%5]) & temp[(x+2)%5]));
            }
        }
        
        {   /* === ι step (see [Keccak Reference, Section 2.3.5]) === */
            for(j=0; j<7; j++) {
                unsigned int bitPosition = (1<<j)-1; /* 2^j-1 */
                if (LFSR86540(&LFSRstate))
                    XORLane(0, 0, (tKeccakLane)1<<bitPosition);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movb $0x1, %r10b
xorl %esi, %esi
movl $0xcccccccd, %r8d       # imm = 0xCCCCCCCD
xorl %r9d, %r9d
movq %rdi, %rax
xorl %ecx, %ecx
movl $0x8, %edx
xorl %r11d, %r11d
movq %r11, %rbx
shlq $0x8, %rbx
movzbl -0x1(%rax,%rdx), %r11d
orq %rbx, %r11
decq %rdx
jne 0x4b65
movl $0x2f, %ebx
xorl %edx, %edx
movq %rdx, %r14
shlq $0x8, %r14
movzbl (%rax,%rbx), %edx
orq %r14, %rdx
decq %rbx
cmpq $0x27, %rbx
jne 0x4b81
movl $0x57, %r14d
xorl %ebx, %ebx
movq %rbx, %r15
shlq $0x8, %r15
movzbl (%rax,%r14), %ebx
orq %r15, %rbx
decq %r14
cmpq $0x4f, %r14
jne 0x4ba0
xorq %r11, %rdx
movl $0x7f, %r14d
xorl %r11d, %r11d
movq %r11, %r15
shlq $0x8, %r15
movzbl (%rax,%r14), %r11d
orq %r15, %r11
decq %r14
cmpq $0x77, %r14
jne 0x4bc4
xorq %rbx, %rdx
movl $0xa7, %ebx
xorl %r14d, %r14d
movq %r14, %r15
shlq $0x8, %r15
movzbl (%rax,%rbx), %r14d
orq %r15, %r14
decq %rbx
cmpq $0x9f, %rbx
jne 0x4be7
xorq %r11, %rdx
xorq %r14, %rdx
movq %rdx, -0x50(%rbp,%rcx,8)
incq %rcx
addq $0x8, %rax
cmpq $0x5, %rcx
jne 0x4b5d
movq %rdi, %rax
xorl %ecx, %ecx
leal 0x4(%rcx), %r11d
movq %r11, %rdx
imulq %r8, %rdx
shrq $0x22, %rdx
leal (%rdx,%rdx,4), %edx
subl %edx, %r11d
incq %rcx
cmpq $0x5, %rcx
movl %ecx, %edx
cmoveq %rsi, %rdx
movq -0x50(%rbp,%rdx,8), %rdx
rolq %rdx
xorq -0x50(%rbp,%r11,8), %rdx
movq %rax, %r11
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %rdx, %r15
xorb %r15b, (%r11,%r14)
shrq $0x8, %r15
incq %r14
cmpq $0x8, %r14
jne 0x4c5d
incq %rbx
addq $0x28, %r11
cmpq $0x5, %rbx
jne 0x4c57
addq $0x8, %rax
cmpq $0x5, %rcx
jne 0x4c23
movl $0xf, %ecx
xorl %eax, %eax
movq %rax, %rdx
shlq $0x8, %rdx
movzbl (%rdi,%rcx), %eax
orq %rdx, %rax
decq %rcx
cmpq $0x7, %rcx
jne 0x4c8c
xorl %edx, %edx
movl $0x1, %r14d
xorl %r11d, %r11d
movl %r11d, %ecx
leal 0x1(%rcx), %r11d
addl $0x2, %ecx
imull %r11d, %ecx
shrl %ecx
leal (%rdx,%rdx,2), %ebx
leal (%rbx,%r14,2), %ebx
movq %rbx, %r14
imulq %r8, %r14
shrq $0x22, %r14
leal (%r14,%r14,4), %r14d
subl %r14d, %ebx
leal (%rbx,%rbx,4), %r14d
addl %edx, %r14d
leaq (%rdi,%r14,8), %r14
movl $0x8, %r12d
xorl %r15d, %r15d
movq %r15, %r13
shlq $0x8, %r13
movzbl -0x1(%r14,%r12), %r15d
orq %r13, %r15
decq %r12
jne 0x4ceb
movq %rax, %r12
shlq %cl, %r12
andb $0x3f, %cl
negb %cl
shrq %cl, %rax
xorq %r12, %rax
xorl %ecx, %ecx
movb %al, (%r14,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x8, %rcx
jne 0x4d13
movl %edx, %r14d
movl %ebx, %edx
movq %r15, %rax
cmpl $0x18, %r11d
jne 0x4cae
movq %rdi, %rax
xorl %ecx, %ecx
movq %rax, %rdx
xorl %r11d, %r11d
movl $0x8, %ebx
xorl %r14d, %r14d
movq %r14, %r15
shlq $0x8, %r15
movzbl -0x1(%rdx,%rbx), %r14d
orq %r15, %r14
decq %rbx
jne 0x4d49
movq %r14, -0x50(%rbp,%r11,8)
incq %r11
addq $0x8, %rdx
cmpq $0x5, %r11
jne 0x4d41
movq %rax, %rdx
xorl %r11d, %r11d
movq %r11, %r14
incq %r11
cmpq $0x5, %r11
movl %r11d, %ebx
cmoveq %rsi, %rbx
movq -0x50(%rbp,%rbx,8), %rbx
notq %rbx
leal 0x2(%r14), %r15d
movq %r15, %r12
imulq %r8, %r12
shrq $0x22, %r12
leal (%r12,%r12,4), %r12d
subl %r12d, %r15d
andq -0x50(%rbp,%r15,8), %rbx
xorq -0x50(%rbp,%r14,8), %rbx
xorl %r14d, %r14d
movb %bl, (%rdx,%r14)
shrq $0x8, %rbx
incq %r14
cmpq $0x8, %r14
jne 0x4db2
addq $0x8, %rdx
cmpq $0x5, %r11
jne 0x4d76
incq %rcx
addq $0x28, %rax
cmpq $0x5, %rcx
jne 0x4d3b
xorl %eax, %eax
movl %r10d, %ecx
leal (%rcx,%rcx), %edx
movzbl %dl, %r11d
xorb $0x71, %dl
testb %r10b, %r10b
movzbl %dl, %r10d
cmovnsl %r11d, %r10d
testb $0x1, %cl
je 0x4e26
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %eax, %ecx
shll %cl, %edx
notb %dl
movl $0x1, %r11d
movl %edx, %ecx
shlq %cl, %r11
xorl %ecx, %ecx
xorb %r11b, (%rdi,%rcx)
shrq $0x8, %r11
incq %rcx
cmpq $0x8, %rcx
jne 0x4e15
incl %eax
cmpl $0x7, %eax
jne 0x4de0
incl %r9d
cmpl $0x18, %r9d
jne 0x4b58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq