// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x58, %rsp
movq %rdi, %r14
movl $0xfffffffd, %r13d      # imm = 0xFFFFFFFD
leaq 0x8(%rdi), %rax
movq %rax, -0x40(%rbp)
movb $0x1, %dl
xorl %eax, %eax
movq %rdi, -0x38(%rbp)
cmpl $0x18, %eax
je 0x44e1
movq %rdx, -0x48(%rbp)
movl %eax, -0x2c(%rbp)
xorl %ebx, %ebx
cmpq $0x28, %rbx
je 0x4325
leaq (%r14,%rbx), %rdi
callq 0x44f0
movq %rax, %r15
leaq (%r14,%rbx), %rdi
addq $0x28, %rdi
callq 0x44f0
movq %rax, %r12
xorq %r15, %r12
leaq (%r14,%rbx), %rdi
addq $0x50, %rdi
callq 0x44f0
movq %rax, %r15
leaq (%r14,%rbx), %rdi
addq $0x78, %rdi
callq 0x44f0
movq %rax, %r13
xorq %r15, %r13
xorq %r12, %r13
leaq (%r14,%rbx), %rdi
addq $0xa0, %rdi
callq 0x44f0
xorq %r13, %rax
movl $0xfffffffd, %r13d      # imm = 0xFFFFFFFD
movq %rax, -0x80(%rbp,%rbx)
addq $0x8, %rbx
jmp 0x42b6
movq %r14, %rbx
xorl %r14d, %r14d
cmpq $0x5, %r14
je 0x4384
testq %r14, %r14
leal 0x2(%r13,%r14), %eax
pushq $0x4
popq %rcx
cmoveq %rcx, %rax
incq %r14
cmpq $0x5, %r14
movl %r14d, %ecx
movl $0x0, %edx
cmoveq %rdx, %rcx
movq -0x80(%rbp,%rcx,8), %r15
rolq %r15
xorq -0x80(%rbp,%rax,8), %r15
xorl %r12d, %r12d
cmpq $0xc8, %r12
je 0x437e
leaq (%rbx,%r12), %rdi
movq %r15, %rsi
callq 0x4512
addq $0x28, %r12
jmp 0x4363
addq $0x8, %rbx
jmp 0x432b
movq -0x40(%rbp), %rdi
callq 0x44f0
movq %rax, %r15
xorl %ecx, %ecx
pushq $0x2
popq %rax
movl %eax, %r12d
pushq $0x1
popq %rax
cmpl $0x1a, %r12d
movq -0x38(%rbp), %rsi
je 0x440c
movl %ecx, %ebx
leal -0x1(%r12), %r13d
imull %r12d, %r13d
leal (%rbx,%rbx,2), %ecx
leal (%rcx,%rax,2), %eax
xorl %edx, %edx
pushq $0x5
popq %rcx
divl %ecx
movq %rdx, -0x58(%rbp)
leal (%rdx,%rdx,4), %eax
addl %ebx, %eax
leaq (%rsi,%rax,8), %r14
movq %r14, %rdi
callq 0x44f0
shrb %r13b
movq %r15, %rdx
movl %r13d, %ecx
shlq %cl, %rdx
movq %rax, -0x50(%rbp)
andb $0x3f, %r13b
negb %r13b
movl %r13d, %ecx
shrq %cl, %r15
xorq %rdx, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x452d
movq -0x58(%rbp), %rcx
incl %r12d
movq -0x50(%rbp), %r15
movl %ebx, %eax
jmp 0x439b
movq %rsi, %rbx
xorl %r14d, %r14d
movl $0xfffffffd, %r13d      # imm = 0xFFFFFFFD
cmpq $0x5, %r14
je 0x4490
xorl %r15d, %r15d
cmpq $0x28, %r15
je 0x443b
leaq (%rbx,%r15), %rdi
callq 0x44f0
movq %rax, -0x80(%rbp,%r15)
addq $0x8, %r15
jmp 0x4421
movq %rbx, %r15
xorl %eax, %eax
cmpq $0x5, %rax
je 0x4487
leaq 0x1(%rax), %r12
cmpq $0x5, %r12
movl $0x0, %ecx
cmovneq %r12, %rcx
movq -0x80(%rbp,%rcx,8), %rsi
notq %rsi
cmpq $0x3, %rax
pushq $0x2
popq %rcx
cmovael %r13d, %ecx
addl %eax, %ecx
andq -0x80(%rbp,%rcx,8), %rsi
xorq -0x80(%rbp,%rax,8), %rsi
movq %r15, %rdi
callq 0x452d
addq $0x8, %r15
movq %r12, %rax
jmp 0x4440
incq %r14
addq $0x28, %rbx
jmp 0x4418
xorl %r15d, %r15d
movq -0x38(%rbp), %r14
movq -0x48(%rbp), %rdx
cmpl $0x7, %r15d
je 0x44d7
leal (%rdx,%rdx), %eax
movzbl %al, %ecx
xorb $0x71, %al
testb %dl, %dl
movzbl %al, %ebx
cmovnsl %ecx, %ebx
testb $0x1, %dl
je 0x44d0
pushq $-0x1
popq %rax
movl %r15d, %ecx
shll %cl, %eax
notb %al
pushq $0x1
popq %rsi
movl %eax, %ecx
shlq %cl, %rsi
movq %r14, %rdi
callq 0x4512
incl %r15d
movl %ebx, %edx
jmp 0x449b
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x42a4
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq