// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/lunarkeyakv2/Haswell/KeccakP-1600-times4-SIMD256.c
// Function: KeccakP1600times4_OverwriteLanesAll
void KeccakP1600times4_OverwriteLanesAll(void *states, const unsigned char *data, unsigned int laneCount, unsigned int laneOffset)
{
    V256 *stateAsLanes = states;
    unsigned int i;
    const UINT64 *curData0 = (const UINT64 *)data;
    const UINT64 *curData1 = (const UINT64 *)(data+laneOffset*SnP_laneLengthInBytes);
    const UINT64 *curData2 = (const UINT64 *)(data+laneOffset*2*SnP_laneLengthInBytes);
    const UINT64 *curData3 = (const UINT64 *)(data+laneOffset*3*SnP_laneLengthInBytes);
    V256    lanes0, lanes1, lanes2, lanes3, lanesL01, lanesL23, lanesH01, lanesH23;

    #define OverWr( argIndex )  STORE256(stateAsLanes[argIndex], LOAD4_64(curData3[argIndex], curData2[argIndex], curData1[argIndex], curData0[argIndex]))

    #define OverWr4( argIndex )     lanes0 = LOAD256u( curData0[argIndex]),\
                                    lanes1 = LOAD256u( curData1[argIndex]),\
                                    lanes2 = LOAD256u( curData2[argIndex]),\
                                    lanes3 = LOAD256u( curData3[argIndex]),\
                                    INTLEAVE(),\
                                    STORE256( stateAsLanes[argIndex+0], lanes0 ),\
                                    STORE256( stateAsLanes[argIndex+1], lanes1 ),\
                                    STORE256( stateAsLanes[argIndex+2], lanes2 ),\
                                    STORE256( stateAsLanes[argIndex+3], lanes3 )

    if ( laneCount >= 16 )  {
        OverWr4( 0 );
        OverWr4( 4 );
        OverWr4( 8 );
        OverWr4( 12 );
        if ( laneCount >= 20 )  {
            OverWr4( 16 );
            for(i=20; i<laneCount; i++)
                OverWr( i );
        }
        else {
            for(i=16; i<laneCount; i++)
                OverWr( i );
        }
    }
    else {
        for(i=0; i<laneCount; i++)
            OverWr( i );
    }
    #undef  OverWr
    #undef  OverWr4
}

// Assembly:
leal (,%rcx,8), %r10d
leaq (%rsi,%r10), %rax
imull $0x18, %ecx, %r11d
shll $0x4, %ecx
leaq (%rsi,%rcx), %r8
leaq (%rsi,%r11), %r9
cmpl $0xf, %edx
jbe 0x9025
vmovupd (%rsi), %ymm0
vmovupd (%rax), %ymm1
vmovupd (%r8), %ymm2
vmovupd (%r9), %ymm3
vperm2f128 $0x20, %ymm2, %ymm0, %ymm4 # ymm4 = ymm0[0,1],ymm2[0,1]
vperm2f128 $0x20, %ymm3, %ymm1, %ymm5 # ymm5 = ymm1[0,1],ymm3[0,1]
vperm2f128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vperm2f128 $0x31, %ymm3, %ymm1, %ymm1 # ymm1 = ymm1[2,3],ymm3[2,3]
vunpcklpd %ymm5, %ymm4, %ymm2 # ymm2 = ymm4[0],ymm5[0],ymm4[2],ymm5[2]
vunpckhpd %ymm5, %ymm4, %ymm3 # ymm3 = ymm4[1],ymm5[1],ymm4[3],ymm5[3]
vunpcklpd %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vunpckhpd %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vmovapd %ymm2, (%rdi)
vmovapd %ymm3, 0x20(%rdi)
vmovapd %ymm4, 0x40(%rdi)
vmovapd %ymm0, 0x60(%rdi)
vmovupd 0x20(%rsi), %ymm0
vmovupd 0x20(%rax), %ymm1
vmovupd 0x20(%r8), %ymm2
vmovupd 0x20(%r9), %ymm3
vperm2f128 $0x20, %ymm2, %ymm0, %ymm4 # ymm4 = ymm0[0,1],ymm2[0,1]
vperm2f128 $0x20, %ymm3, %ymm1, %ymm5 # ymm5 = ymm1[0,1],ymm3[0,1]
vperm2f128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vperm2f128 $0x31, %ymm3, %ymm1, %ymm1 # ymm1 = ymm1[2,3],ymm3[2,3]
vunpcklpd %ymm5, %ymm4, %ymm2 # ymm2 = ymm4[0],ymm5[0],ymm4[2],ymm5[2]
vunpckhpd %ymm5, %ymm4, %ymm3 # ymm3 = ymm4[1],ymm5[1],ymm4[3],ymm5[3]
vunpcklpd %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vunpckhpd %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vmovapd %ymm2, 0x80(%rdi)
vmovapd %ymm3, 0xa0(%rdi)
vmovapd %ymm4, 0xc0(%rdi)
vmovapd %ymm0, 0xe0(%rdi)
vmovupd 0x40(%rsi), %ymm0
vmovupd 0x40(%rax), %ymm1
vmovupd 0x40(%r8), %ymm2
vmovupd 0x40(%r9), %ymm3
vperm2f128 $0x20, %ymm2, %ymm0, %ymm4 # ymm4 = ymm0[0,1],ymm2[0,1]
vperm2f128 $0x20, %ymm3, %ymm1, %ymm5 # ymm5 = ymm1[0,1],ymm3[0,1]
vperm2f128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vperm2f128 $0x31, %ymm3, %ymm1, %ymm1 # ymm1 = ymm1[2,3],ymm3[2,3]
vunpcklpd %ymm5, %ymm4, %ymm2 # ymm2 = ymm4[0],ymm5[0],ymm4[2],ymm5[2]
vunpckhpd %ymm5, %ymm4, %ymm3 # ymm3 = ymm4[1],ymm5[1],ymm4[3],ymm5[3]
vunpcklpd %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vunpckhpd %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vmovapd %ymm2, 0x100(%rdi)
vmovapd %ymm3, 0x120(%rdi)
vmovapd %ymm4, 0x140(%rdi)
vmovapd %ymm0, 0x160(%rdi)
vmovupd 0x60(%rsi), %ymm0
vmovupd 0x60(%rax), %ymm1
vmovupd 0x60(%r8), %ymm2
vmovupd 0x60(%r9), %ymm3
vperm2f128 $0x20, %ymm2, %ymm0, %ymm4 # ymm4 = ymm0[0,1],ymm2[0,1]
vperm2f128 $0x20, %ymm3, %ymm1, %ymm5 # ymm5 = ymm1[0,1],ymm3[0,1]
vperm2f128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vperm2f128 $0x31, %ymm3, %ymm1, %ymm1 # ymm1 = ymm1[2,3],ymm3[2,3]
vunpcklpd %ymm5, %ymm4, %ymm2 # ymm2 = ymm4[0],ymm5[0],ymm4[2],ymm5[2]
vunpckhpd %ymm5, %ymm4, %ymm3 # ymm3 = ymm4[1],ymm5[1],ymm4[3],ymm5[3]
vunpcklpd %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vmovapd %ymm2, 0x180(%rdi)
vmovapd %ymm3, 0x1a0(%rdi)
vunpckhpd %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vmovapd %ymm4, 0x1c0(%rdi)
vmovapd %ymm0, 0x1e0(%rdi)
cmpl $0x13, %edx
jbe 0x9065
vmovupd 0x80(%rsi), %ymm0
vmovupd 0x80(%rsi,%r10), %ymm1
vmovupd 0x80(%rsi,%rcx), %ymm2
vmovupd 0x80(%rsi,%r11), %ymm3
vperm2f128 $0x20, %ymm2, %ymm0, %ymm4 # ymm4 = ymm0[0,1],ymm2[0,1]
vperm2f128 $0x20, %ymm3, %ymm1, %ymm5 # ymm5 = ymm1[0,1],ymm3[0,1]
vperm2f128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vperm2f128 $0x31, %ymm3, %ymm1, %ymm1 # ymm1 = ymm1[2,3],ymm3[2,3]
vunpcklpd %ymm5, %ymm4, %ymm2 # ymm2 = ymm4[0],ymm5[0],ymm4[2],ymm5[2]
vunpckhpd %ymm5, %ymm4, %ymm3 # ymm3 = ymm4[1],ymm5[1],ymm4[3],ymm5[3]
vunpcklpd %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vmovapd %ymm2, 0x200(%rdi)
vmovapd %ymm3, 0x220(%rdi)
vunpckhpd %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vmovapd %ymm4, 0x240(%rdi)
vmovapd %ymm0, 0x260(%rdi)
movl %edx, %ecx
leaq -0xa0(,%rcx,8), %rcx
movl $0xa0, %edx
addq %rdx, %r9
addq %rdx, %r8
addq %rdx, %rax
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x90be
vmovsd (%rax,%rdx), %xmm0
vmovsd 0xa0(%rsi,%rdx), %xmm1
vunpcklpd %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vmovsd (%r9,%rdx), %xmm1
vmovsd (%r8,%rdx), %xmm2
vunpcklpd %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vmovapd %xmm1, 0x290(%rdi,%rdx,4)
vmovapd %xmm0, 0x280(%rdi,%rdx,4)
addq $0x8, %rdx
jmp 0x8fe2
movl %edx, %ecx
shlq $0x3, %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x90be
vmovsd (%rax,%rdx), %xmm0
vmovsd (%rsi,%rdx), %xmm1
vunpcklpd %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vmovsd (%r9,%rdx), %xmm1
vmovsd (%r8,%rdx), %xmm2
vunpcklpd %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vmovapd %xmm1, 0x10(%rdi,%rdx,4)
vmovapd %xmm0, (%rdi,%rdx,4)
addq $0x8, %rdx
jmp 0x902d
movl %edx, %ecx
leaq -0x80(,%rcx,8), %rcx
movl $0x80, %edx
addq %rdx, %r9
addq %rdx, %r8
addq %rdx, %rax
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x90be
vmovsd (%rax,%rdx), %xmm0
vmovsd 0x80(%rsi,%rdx), %xmm1
vunpcklpd %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vmovsd (%r9,%rdx), %xmm1
vmovsd (%r8,%rdx), %xmm2
vunpcklpd %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vmovapd %xmm1, 0x210(%rdi,%rdx,4)
vmovapd %xmm0, 0x200(%rdi,%rdx,4)
addq $0x8, %rdx
jmp 0x907f
vzeroupper
retq