// File: /workspace/github_c_makefile_star2_O3/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:
movl $0x18, %eax
subl %esi, %eax
cmpl $0x17, %eax
ja 0x6192
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movl %eax, %ecx
leaq 0x70(%rsp), %r9
leaq 0x4(%rdi), %rax
movq %rax, 0x10(%rsp)
vpmovsxwq 0xa21e(%rip), %ymm5 # 0x10040
vpmovsxbq 0xa21d(%rip), %ymm6 # 0x10048
movb $0x1, %al
kmovd %eax, %k2
vpxor %xmm7, %xmm7, %xmm7
movabsq $-0x3333333333333333, %r10 # imm = 0xCCCCCCCCCCCCCCCD
kmovw %k2, 0xe(%rsp)
movq %rcx, 0x18(%rsp)
xorl %eax, %eax
vpbroadcastq %rax, %ymm0
vpsllq $0x3, %ymm0, %ymm0
vpaddq %ymm5, %ymm0, %ymm1
vpaddq %ymm6, %ymm0, %ymm0
vpxor %xmm2, %xmm2, %xmm2
kxnorw %k0, %k0, %k1
vpgatherqd (%rbx,%ymm0), %xmm2 {%k1}
vpxor %xmm3, %xmm3, %xmm3
kmovq %k2, %k1
vpgatherqd (%rbx,%ymm1), %xmm3 {%k1}
vinserti128 $0x1, %xmm3, %ymm0, %ymm3
vpblendd $0xe0, %ymm7, %ymm3, %ymm3 # ymm3 = ymm3[0,1,2,3,4],ymm7[5,6,7]
vextracti128 $0x1, %ymm3, %xmm3
vpshufd $0xee, %xmm2, %xmm4     # xmm4 = xmm2[2,3,2,3]
vpternlogd $0x96, %xmm3, %xmm2, %xmm4
vpsrlq $0x20, %xmm4, %xmm2
vpxor %xmm2, %xmm4, %xmm2
vmovd %xmm2, 0x50(%rsp,%rax,8)
vpxor %xmm2, %xmm2, %xmm2
kxnorw %k0, %k0, %k1
vpgatherqd 0x4(%rbx,%ymm0), %xmm2 {%k1}
vpxor %xmm0, %xmm0, %xmm0
kmovq %k2, %k1
vpgatherqd 0x4(%rbx,%ymm1), %xmm0 {%k1}
vinserti128 $0x1, %xmm0, %ymm0, %ymm0
vpblendd $0xe0, %ymm7, %ymm0, %ymm0 # ymm0 = ymm0[0,1,2,3,4],ymm7[5,6,7]
vextracti128 $0x1, %ymm0, %xmm0
vpshufd $0xee, %xmm2, %xmm1     # xmm1 = xmm2[2,3,2,3]
vpternlogd $0x96, %xmm0, %xmm2, %xmm1
vpsrlq $0x20, %xmm1, %xmm0
vpxor %xmm0, %xmm1, %xmm0
vmovd %xmm0, 0x54(%rsp,%rax,8)
incq %rax
cmpq $0x5, %rax
jne 0x5e4c
movl $0x4, %edx
xorl %eax, %eax
mulxq %r10, %rcx, %rcx
addq %rcx, %rcx
andq $-0x8, %rcx
leaq (%rcx,%rcx,4), %rcx
movq %r9, %rsi
subq %rcx, %rsi
leaq 0x1(%rax), %rcx
cmpq $0x4, %rax
movl $0x0, %edi
cmovneq %rcx, %rdi
rorxl $0x1f, 0x54(%rsp,%rdi,8), %r8d
vmovq (%rsi,%rax,8), %xmm0
vmovd %r8d, %xmm1
vpinsrd $0x1, 0x50(%rsp,%rdi,8), %xmm1, %xmm1
vpxor %xmm1, %xmm0, %xmm0
vmovq %xmm0, 0x20(%rsp,%rax,8)
incq %rdx
movq %rcx, %rax
cmpq $0x5, %rcx
jne 0x5f0d
movq %rbx, %rax
xorl %ecx, %ecx
vmovq 0x20(%rsp,%rcx,8), %xmm0
xorl %edx, %edx
vmovq (%rax,%rdx), %xmm1
vpxor %xmm0, %xmm1, %xmm1
vmovq %xmm1, (%rax,%rdx)
addq $0x28, %rdx
cmpq $0xc8, %rdx
jne 0x5f71
incq %rcx
addq $0x8, %rax
cmpq $0x5, %rcx
jne 0x5f69
movq 0x10(%rsp), %r12
leaq 0xa41b(%rip), %r13      # 0x103c0
xorl %ebp, %ebp
movq %r12, %r14
xorl %r15d, %r15d
leaq -0x4(%r14), %rdx
movl -0x4(%r14), %edi
movl (%r14), %esi
movl (%r13,%r15), %r8d
movq %r14, %rcx
vzeroupper
callq 0x56e0
addq $0x14, %r15
addq $0x28, %r14
cmpq $0x64, %r15
jne 0x5fad
incq %rbp
addq $0x4, %r13
addq $0x8, %r12
cmpq $0x5, %rbp
jne 0x5fa7
leaq 0x50(%rsp), %r8
movq %r8, %rax
movq %rbx, %rcx
xorl %edx, %edx
xorl %r12d, %r12d
vpmovsxwq 0xa040(%rip), %ymm5 # 0x10040
vpmovsxbq 0xa03f(%rip), %ymm6 # 0x10048
kmovw 0xe(%rsp), %k2
vpxor %xmm7, %xmm7, %xmm7
movl $0xcccccccd, %r13d      # imm = 0xCCCCCCCD
xorl %esi, %esi
movq (%rcx,%rsi), %rdi
movq %rdi, (%rax,%rsi)
addq $0x28, %rsi
cmpq $0xc8, %rsi
jne 0x601b
incq %rdx
addq $0x8, %rcx
addq $0x8, %rax
cmpq $0x5, %rdx
jne 0x6019
xorl %eax, %eax
movq %r8, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl %eax, %edi
movl %edx, %r8d
xorl %r9d, %r9d
movl %edi, %r10d
imulq %r13, %r10
shrq $0x22, %r10
imull $0x32, %r10d, %r10d
movl %r8d, %r11d
subl %r10d, %r11d
movq (%rcx,%r9), %r10
movq %r10, (%rbx,%r11,4)
addq $0x28, %r9
addl $0x20, %r8d
addl $0x3, %edi
cmpq $0xc8, %r9
jne 0x6052
incq %rsi
addl $0x14, %edx
addl $0x2, %eax
addq $0x8, %rcx
cmpq $0x5, %rsi
jne 0x604a
xorl %eax, %eax
movl %eax, %ecx
imulq %r13, %rcx
shrq $0x22, %rcx
imull $-0x32, %ecx, %ecx
leal (%rax,%rax,4), %edx
leal (%rcx,%rdx,2), %ecx
shlq $0x2, %rcx
leaq (%rax,%rax,4), %rdx
xorl %esi, %esi
leaq (%rsi,%rdx), %r8
leaq 0x1(%rsi), %rdi
cmpq $0x5, %rdi
movl %edi, %r9d
cmovel %r12d, %r9d
addl %edx, %r9d
addl %r9d, %r9d
leal 0x2(%rsi), %r10d
movq %r10, %r11
imulq %r13, %r11
shrq $0x22, %r11
leal (%r11,%r11,4), %r11d
subl %r11d, %r10d
addl %edx, %r10d
addl %r10d, %r10d
leaq (%rbx,%r8,8), %r8
leaq (%rbx,%r9,4), %r9
leaq (%rbx,%r10,4), %r10
movb $0x1, %r11b
xorl %r14d, %r14d
movl (%r9,%r14,4), %ebp
andnl (%r10,%r14,4), %ebp, %ebp
xorl (%r8,%r14,4), %ebp
leaq (%rsp,%rsi,8), %r15
addq $0x50, %r15
movl %ebp, (%r15,%r14,4)
movl $0x1, %r14d
testb $0x1, %r11b
movl $0x0, %r11d
jne 0x60fc
movq %rdi, %rsi
cmpq $0x5, %rdi
jne 0x60b5
movq 0x70(%rsp), %rdx
movq %rdx, 0x20(%rbx,%rcx)
vmovdqu 0x50(%rsp), %ymm0
vmovdqu %ymm0, (%rbx,%rcx)
incq %rax
cmpq $0x5, %rax
jne 0x6098
movq 0x18(%rsp), %rcx
leaq 0xa1a1(%rip), %rax      # 0x10300
movq (%rax,%rcx,8), %rax
xorq %rax, (%rbx)
incq %rcx
cmpl $0x18, %ecx
leaq 0x70(%rsp), %r9
movabsq $-0x3333333333333333, %r10 # imm = 0xCCCCCCCCCCCCCCCD
jne 0x5e45
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq