// File: /workspace/github_c_makefile_star2_O1/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 0x64b1
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
movl %eax, %ecx
leaq 0x90(%rsp), %r9
leaq 0x4(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x70(%rsp), %r15
vpbroadcastq %rdi, %ymm7
vpmovsxwq 0xa009(%rip), %ymm8 # 0x100c0
vpmovsxbq 0x9fdc(%rip), %ymm9 # 0x1009c
movb $0x1, %al
kmovd %eax, %k3
vpxor %xmm10, %xmm10, %xmm10
movabsq $-0x3333333333333333, %r10 # imm = 0xCCCCCCCCCCCCCCCD
vmovdqu %ymm7, 0x50(%rsp)
kmovw %k3, 0xe(%rsp)
movq %rcx, 0x18(%rsp)
movq %r15, %rax
xorl %ecx, %ecx
vpbroadcastq %rcx, %ymm0
vpsllq $0x3, %ymm0, %ymm0
vpaddq %ymm7, %ymm0, %ymm1
vpaddq %ymm1, %ymm8, %ymm0
vpaddq %ymm1, %ymm9, %ymm1
xorl %edx, %edx
movl $0x0, (%rax,%rdx,4)
vpbroadcastq %rdx, %ymm2
vpsllq $0x2, %ymm2, %ymm2
vpaddq %ymm2, %ymm1, %ymm3
vpaddq %ymm2, %ymm0, %ymm2
kmovq %k3, %k1
vpxor %xmm4, %xmm4, %xmm4
vpgatherqd (,%ymm2), %xmm4 {%k1}
vpxor %xmm2, %xmm2, %xmm2
kxnorw %k0, %k0, %k1
vpgatherqd (,%ymm3), %xmm2 {%k1}
vinserti128 $0x1, %xmm4, %ymm0, %ymm3
vpblendd $0xe0, %ymm10, %ymm3, %ymm3 # ymm3 = ymm3[0,1,2,3,4],ymm10[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, (%rax,%rdx,4)
incq %rdx
cmpq $0x1, %rdx
je 0x6104
incq %rcx
addq $0x8, %rax
cmpq $0x5, %rcx
jne 0x60eb
movl $0x4, %edx
xorl %eax, %eax
leaq 0x1(%rax), %rcx
mulxq %r10, %rsi, %rsi
addq %rsi, %rsi
andq $-0x8, %rsi
leaq (%rsi,%rsi,4), %rsi
movq %r9, %rdi
subq %rsi, %rdi
cmpq $0x4, %rax
movl $0x0, %esi
cmovneq %rcx, %rsi
movl 0x70(%rsp,%rsi,8), %r8d
rorxl $0x1f, 0x74(%rsp,%rsi,8), %esi
movl %esi, 0x20(%rsp,%rax,8)
movl %r8d, 0x24(%rsp,%rax,8)
movq (%rdi,%rax,8), %rsi
xorq %rsi, 0x20(%rsp,%rax,8)
incq %rdx
movq %rcx, %rax
cmpq $0x5, %rcx
jne 0x6192
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 0x61f1
incq %rcx
addq $0x8, %rax
cmpq $0x5, %rcx
jne 0x61e9
movq 0x10(%rsp), %r12
leaq 0xa22b(%rip), %r13      # 0x10450
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 0x56c0
addq $0x14, %r15
addq $0x28, %r14
cmpq $0x64, %r15
jne 0x622d
incq %rbp
addq $0x4, %r13
addq $0x8, %r12
cmpq $0x5, %rbp
jne 0x6227
leaq 0x70(%rsp), %r15
movq %r15, %rax
movq %rbx, %rcx
xorl %edx, %edx
xorl %r12d, %r12d
vmovdqu 0x50(%rsp), %ymm7
vpmovsxwq 0x9e3a(%rip), %ymm8 # 0x100c0
vpmovsxbq 0x9e0d(%rip), %ymm9 # 0x1009c
kmovw 0xe(%rsp), %k3
vpxor %xmm10, %xmm10, %xmm10
vpmovsxbq 0x9dfd(%rip), %ymm11 # 0x100a0
vpbroadcastq 0x9e04(%rip), %ymm12 # 0x100b0
vpbroadcastd 0x9ddf(%rip), %xmm13 # 0x10094
vpmovsxbd 0x9de6(%rip), %xmm14 # 0x100a4
vpbroadcastd 0x9dd1(%rip), %xmm15 # 0x10098
vpbroadcastq 0x9de7(%rip), %ymm16 # 0x100b8
movl $0xcccccccd, %r13d      # imm = 0xCCCCCCCD
xorl %esi, %esi
movq (%rcx,%rsi), %rdi
movq %rdi, (%rax,%rsi)
addq $0x28, %rsi
cmpq $0xc8, %rsi
jne 0x62d9
incq %rdx
addq $0x8, %rcx
addq $0x8, %rax
cmpq $0x5, %rdx
jne 0x62d7
xorl %eax, %eax
leaq (%rax,%rax), %rcx
leaq (,%rax,4), %rdx
leaq (%rdx,%rdx,4), %rdx
vpbroadcastq %rdx, %ymm0
vpbroadcastq %rcx, %ymm1
leaq (%rsp,%rax,8), %rcx
addq $0x70, %rcx
movl $0x8, %edx
vmovdqa %ymm11, %ymm2
vpcmpltuq %ymm12, %ymm2, %k1
vpsllq $0x5, %ymm2, %ymm3
vpaddq %ymm3, %ymm0, %ymm4
vpmovqd %ymm4, %xmm4
vpaddq %ymm2, %ymm2, %ymm5
vpaddq %ymm2, %ymm5, %ymm5
vpaddq %ymm5, %ymm1, %ymm5
vpmovqd %ymm5, %xmm5
vpmuludq %xmm5, %xmm13, %xmm6
vpsrlq $0x20, %xmm5, %xmm5
vpmuludq %xmm5, %xmm13, %xmm5
vpermt2d %xmm5, %xmm14, %xmm6
vpsrld $0x2, %xmm6, %xmm5
vpmulld %xmm15, %xmm5, %xmm5
vpaddd %xmm4, %xmm5, %xmm4
vpsllq $0x3, %ymm2, %ymm5
vpaddq %ymm5, %ymm3, %ymm3
vpxor %xmm5, %xmm5, %xmm5
kmovq %k1, %k2
vpgatherqq (%rcx,%ymm3), %ymm5 {%k2}
vpmovzxdq %xmm4, %ymm3    # ymm3 = xmm4[0],zero,xmm4[1],zero,xmm4[2],zero,xmm4[3],zero
vpscatterqq %ymm5, (%rbx,%ymm3,4) {%k1}
vpaddq %ymm16, %ymm2, %ymm2
addq $-0x4, %rdx
jne 0x632e
incq %rax
cmpq $0x5, %rax
jne 0x6301
movl $0x4, %eax
movq %rbx, %rcx
xorl %edx, %edx
movl %edx, %esi
imulq %r13, %rsi
shrq $0x22, %rsi
imull $-0x32, %esi, %esi
leal (%rdx,%rdx,4), %edi
leal (%rsi,%rdi,2), %esi
shlq $0x2, %rsi
leaq (%rdx,%rdx,4), %rdi
movl $0x1, %r8d
movl $0x2, %r9d
movl %eax, %r10d
movl %r9d, %r11d
imulq %r13, %r11
shrq $0x22, %r11
addl %r11d, %r11d
leal (%r11,%r11,4), %r11d
movl %r10d, %r14d
subl %r11d, %r14d
cmpq $0x5, %r8
movl %r8d, %r11d
cmovel %r12d, %r11d
addl %edi, %r11d
vmovq -0x8(%rcx,%r8,8), %xmm0
addl %r11d, %r11d
vmovq (%rbx,%r11,4), %xmm1
vmovq (%rbx,%r14,4), %xmm2
vpternlogq $0x9c, %xmm1, %xmm0, %xmm2
vmovq %xmm2, 0x68(%rsp,%r8,8)
incq %r8
addl $0x2, %r10d
incl %r9d
cmpq $0x6, %r8
jne 0x63e9
movq 0x90(%rsp), %rdi
movq %rdi, 0x20(%rbx,%rsi)
vmovdqu 0x70(%rsp), %ymm0
vmovdqu %ymm0, (%rbx,%rsi)
incq %rdx
addl $0xa, %eax
addq $0x28, %rcx
cmpq $0x5, %rdx
jne 0x63bf
movq 0x18(%rsp), %rcx
leaq 0x9f15(%rip), %rax      # 0x10390
movq (%rax,%rcx,8), %rax
xorq %rax, (%rbx)
incq %rcx
cmpl $0x18, %ecx
leaq 0x90(%rsp), %r9
movabsq $-0x3333333333333333, %r10 # imm = 0xCCCCCCCCCCCCCCCD
jne 0x60e1
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq