// File: 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
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movb $0x1, -0x1d(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x18, -0xc(%rbp)
jae 0x8e1c
movl $0x0, -0x10(%rbp)
cmpl $0x5, -0x10(%rbp)
jae 0x8b30
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
addl $0x0, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
addl $0x5, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, %rcx
movq -0xc8(%rbp), %rax
xorq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
addl $0xa, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, %rcx
movq -0xc0(%rbp), %rax
xorq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
addl $0xf, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, %rcx
movq -0xb8(%rbp), %rax
xorq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
addl $0x14, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq -0xb0(%rbp), %rcx
xorq %rax, %rcx
movl -0x10(%rbp), %eax
movq %rcx, -0x50(%rbp,%rax,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x8a4b
movl $0x0, -0x10(%rbp)
cmpl $0x5, -0x10(%rbp)
jae 0x8be9
movl -0x10(%rbp), %eax
addl $0x4, %eax
movl $0x5, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %eax
movq -0x50(%rbp,%rax,8), %rax
movq %rax, -0xd0(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl $0x5, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %eax
movq -0x50(%rbp,%rax,8), %rcx
shlq %rcx
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl $0x5, %esi
xorl %edx, %edx
divl %esi
movq -0xd0(%rbp), %rax
movl %edx, %edx
movq -0x50(%rbp,%rdx,8), %rdx
shrq $0x3f, %rdx
xorq %rdx, %rcx
xorq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jae 0x8bd9
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
imull $0x5, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x8e80
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8ba9
jmp 0x8bdb
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x8b37
movl $0x1, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
imull $0x5, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, -0x60(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x18, -0x1c(%rbp)
jae 0x8cd1
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl -0x1c(%rbp), %ecx
addl $0x2, %ecx
imull %ecx, %eax
shrl %eax
andl $0x3f, %eax
movl %eax, -0x6c(%rbp)
movl -0x10(%rbp), %eax
shll %eax
imull $0x3, -0x14(%rbp), %ecx
addl %ecx, %eax
movl $0x5, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, -0x70(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
imull $0x5, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
imull $0x5, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x60(%rbp), %rsi
movl -0x6c(%rbp), %eax
movl %eax, %ecx
shlq %cl, %rsi
movq -0x60(%rbp), %rax
movl $0x40, %ecx
subl -0x6c(%rbp), %ecx
movl %ecx, %ecx
shrq %cl, %rax
xorq %rax, %rsi
callq 0x8ed0
movq -0x68(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8c1d
movl $0x0, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jae 0x8db8
movl $0x0, -0x10(%rbp)
cmpl $0x5, -0x10(%rbp)
jae 0x8d23
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
imull $0x5, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x8e30
movq %rax, %rcx
movl -0x10(%rbp), %eax
movq %rcx, -0xa0(%rbp,%rax,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x8ce9
movl $0x0, -0x10(%rbp)
cmpl $0x5, -0x10(%rbp)
jae 0x8da8
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
imull $0x5, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x10(%rbp), %eax
movq -0xa0(%rbp,%rax,8), %rsi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl $0x5, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %eax
movq -0xa0(%rbp,%rax,8), %rax
xorq $-0x1, %rax
movq %rax, -0xd8(%rbp)
movl -0x10(%rbp), %eax
addl $0x2, %eax
movl $0x5, %ecx
xorl %edx, %edx
divl %ecx
movq -0xd8(%rbp), %rax
movl %edx, %ecx
andq -0xa0(%rbp,%rcx,8), %rax
xorq %rax, %rsi
callq 0x8ed0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x8d2a
jmp 0x8daa
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8cd8
movl $0x0, -0x18(%rbp)
cmpl $0x7, -0x18(%rbp)
jae 0x8e0c
movl -0x18(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, -0xa4(%rbp)
leaq -0x1d(%rbp), %rdi
callq 0x89c0
cmpl $0x0, %eax
je 0x8dff
movq -0x8(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %ecx
movl $0x1, %esi
shlq %cl, %rsi
callq 0x8e80
jmp 0x8e01
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x8dbf
jmp 0x8e0e
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8a3a
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)