// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/lunarkeyakv2/reference32bits/KeccakP-1600-reference32BI.c
// Function: KeccakP1600_PermutationOnWords
void KeccakP1600_PermutationOnWords(UINT32 *state, unsigned int nrRounds)
{
    unsigned int i;

#ifdef KeccakReference
    displayStateAs32bitWords(3, "Same, with lanes as pairs of 32-bit words (bit interleaving)", state);
#endif

    for(i=(maxNrRounds-nrRounds); i<maxNrRounds; i++) {
#ifdef KeccakReference
        displayRoundNumber(3, i);
#endif

        theta(state);
#ifdef KeccakReference
        displayStateAs32bitWords(3, "After theta", state);
#endif

        rho(state);
#ifdef KeccakReference
        displayStateAs32bitWords(3, "After rho", state);
#endif

        pi(state);
#ifdef KeccakReference
        displayStateAs32bitWords(3, "After pi", state);
#endif

        chi(state);
#ifdef KeccakReference
        displayStateAs32bitWords(3, "After chi", state);
#endif

        iota(state, i);
#ifdef KeccakReference
        displayStateAs32bitWords(3, "After iota", state);
#endif
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
pushq $0x18
popq %rcx
subl %esi, %ecx
leaq 0x4(%rdi), %rax
movq %rax, 0x8(%rsp)
pushq $0x5
popq %r11
pushq $0x5
popq %r15
cmpq $0x17, %rcx
ja 0x6131
movq %rcx, 0x10(%rsp)
movq %rbx, %rax
xorl %ecx, %ecx
cmpq $0x5, %rcx
je 0x5e64
movq %rax, %rdx
xorl %esi, %esi
cmpq $0x2, %rsi
je 0x5e5b
xorl %edi, %edi
movq $-0xc8, %r8
testq %r8, %r8
je 0x5e46
xorl 0xc8(%rdx,%r8), %edi
addq $0x28, %r8
jmp 0x5e33
leaq (%rsp,%rcx,8), %r8
addq $0x50, %r8
movl %edi, (%r8,%rsi,4)
incq %rsi
addq $0x4, %rdx
jmp 0x5e24
incq %rcx
addq $0x8, %rax
jmp 0x5e19
pushq $0x4
popq %rcx
leaq 0x70(%rsp), %rsi
leaq 0x20(%rsp), %rdi
xorl %r8d, %r8d
movq %rcx, %rax
xorl %edx, %edx
divq %r11
cmpq $0x5, %r8
je 0x5edb
imulq $-0x28, %rax, %rdx
addq %rsi, %rdx
leaq 0x1(%r8), %rax
cmpq $0x5, %rax
movq %rax, %r9
movl $0x0, %r10d
cmoveq %r10, %r9
movl 0x50(%rsp,%r9,8), %r10d
rorxl $0x1f, 0x54(%rsp,%r9,8), %r9d
movl %r9d, 0x20(%rsp,%r8,8)
movl %r10d, 0x24(%rsp,%r8,8)
xorl %r8d, %r8d
cmpq $0x2, %r8
je 0x5ecb
movl (%rdx,%r8,4), %r9d
xorl %r9d, (%rdi,%r8,4)
incq %r8
jmp 0x5eb8
addq $0x8, %rdi
addq $0x8, %rsi
incq %rcx
movq %rax, %r8
jmp 0x5e74
leaq 0x20(%rsp), %rax
movq %rbx, %rcx
xorl %edx, %edx
cmpq $0x5, %rdx
je 0x5f22
movq %rcx, %rsi
xorl %edi, %edi
cmpq $0x5, %rdi
je 0x5f15
xorl %r8d, %r8d
cmpq $0x2, %r8
je 0x5f0c
movl (%rax,%r8,4), %r9d
xorl %r9d, (%rsi,%r8,4)
incq %r8
jmp 0x5ef9
incq %rdi
addq $0x28, %rsi
jmp 0x5ef0
incq %rdx
addq $0x8, %rcx
addq $0x8, %rax
jmp 0x5ee5
movq 0x8(%rsp), %r14
leaq 0x9442(%rip), %r13      # 0xf370
xorl %ebp, %ebp
cmpq $0x5, %rbp
je 0x5f76
movq %r14, (%rsp)
xorl %r12d, %r12d
cmpq $0x64, %r12
je 0x5f65
leaq -0x4(%r14), %rdx
movl -0x4(%r14), %edi
movl (%r14), %esi
movl (%r13,%r12), %r8d
movq %r14, %rcx
callq 0x5710
addq $0x14, %r12
addq $0x28, %r14
jmp 0x5f3d
incq %rbp
addq $0x4, %r13
movq (%rsp), %r14
addq $0x8, %r14
jmp 0x5f30
leaq 0x50(%rsp), %rax
movq %rbx, %rcx
xorl %edx, %edx
cmpq $0x5, %rdx
je 0x5fc5
movq %rax, %rsi
movq %rcx, %rdi
xorl %r8d, %r8d
cmpq $0x5, %r8
je 0x5fb8
xorl %r9d, %r9d
cmpq $0x2, %r9
je 0x5fab
movl (%rdi,%r9,4), %r10d
movl %r10d, (%rsi,%r9,4)
incq %r9
jmp 0x5f98
incq %r8
addq $0x28, %rdi
addq $0x28, %rsi
jmp 0x5f8f
incq %rdx
addq $0x8, %rcx
addq $0x8, %rax
jmp 0x5f80
xorl %esi, %esi
xorl %edi, %edi
leaq 0x50(%rsp), %r8
xorl %r9d, %r9d
cmpq $0x5, %r9
je 0x602e
movl %esi, %ecx
movl %edi, %r10d
movq %r8, %r11
xorl %r14d, %r14d
movl %ecx, %eax
xorl %edx, %edx
divl %r15d
cmpq $0x5, %r14
je 0x601f
imull $0x32, %eax, %eax
movl %r10d, %edx
subl %eax, %edx
leaq (%rbx,%rdx,4), %rax
xorl %edx, %edx
cmpq $0x2, %rdx
je 0x600f
movl (%r11,%rdx,4), %ebp
movl %ebp, (%rax,%rdx,4)
incq %rdx
jmp 0x5ffd
incq %r14
addq $0x28, %r11
addl $0x20, %r10d
addl $0x3, %ecx
jmp 0x5fe2
incq %r9
addq $0x8, %r8
addl $0x14, %edi
addl $0x2, %esi
jmp 0x5fd1
xorl %ecx, %ecx
xorl %edi, %edi
pushq $0x4
popq %r14
movq %rbx, %r9
xorl %esi, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %r15d
cmpq $0x5, %rsi
je 0x6112
movq %rsi, 0x18(%rsp)
movq %rcx, (%rsp)
imull $0x19, %eax, %eax
movl %edi, %ecx
subl %eax, %ecx
leaq (%rbx,%rcx,8), %r11
pushq $0x2
popq %rsi
movl %r14d, %r12d
leaq 0x50(%rsp), %r13
movq %r9, %r10
xorl %ecx, %ecx
movl %esi, %eax
xorl %edx, %edx
divl %r15d
cmpq $0x5, %rcx
je 0x60d8
imull $0xa, %eax, %eax
movl %r14d, %edx
subl %eax, %edx
leaq (%rbx,%rdx,4), %rax
incq %rcx
cmpq $0x5, %rcx
movl %ecx, %edx
movl $0x0, %r8d
cmovel %r8d, %edx
addl %edi, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq (%rbx,%rdx,8), %rdx
xorl %ebp, %ebp
cmpq $0x2, %rbp
je 0x60c8
movl (%rdx,%rbp,4), %r8d
andnl (%rax,%rbp,4), %r8d, %r8d
xorl (%r9,%rbp,4), %r8d
movl %r8d, (%r13,%rbp,4)
incq %rbp
jmp 0x60aa
addq $0x8, %r9
addq $0x8, %r13
addl $0x2, %r14d
incl %esi
jmp 0x6070
xorl %eax, %eax
movl %r12d, %r14d
movq %r10, %r9
movq 0x18(%rsp), %rsi
cmpq $0x5, %rax
je 0x60f9
movq 0x50(%rsp,%rax,8), %rcx
movq %rcx, (%r11,%rax,8)
incq %rax
jmp 0x60e5
incq %rsi
addq $0x28, %r9
addl $0xa, %r14d
addl $0x5, %edi
movq (%rsp), %rcx
incl %ecx
jmp 0x603b
movq 0x10(%rsp), %rcx
leaq 0x9192(%rip), %rax      # 0xf2b0
movq (%rax,%rcx,8), %rax
xorq %rax, (%rbx)
incq %rcx
pushq $0x5
popq %r11
jmp 0x5e05
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq