// File: /workspace/github_c_makefile_star2_O3/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), %r8d
leaq (%r8,%rsi), %rax
shll $0x4, %ecx
addq %rsi, %rcx
leal (%r8,%r8,2), %r8d
addq %rsi, %r8
cmpl $0xf, %edx
jbe 0x9171
vmovupd (%rsi), %ymm0
vmovupd (%rax), %ymm1
vmovupd (%rcx), %ymm2
vmovupd (%r8), %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(%rcx), %ymm2
vmovupd 0x20(%r8), %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(%rcx), %ymm2
vmovupd 0x40(%r8), %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(%rcx), %ymm2
vmovupd 0x60(%r8), %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 0x91ba
vmovupd 0x80(%rsi), %ymm0
vmovupd 0x80(%rax), %ymm1
vmovupd 0x80(%rcx), %ymm2
vmovupd 0x80(%r8), %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)
cmpl $0x14, %edx
je 0x9218
movl %edx, %edx
movl $0xa0, %r9d
addq %r9, %r8
addq %r9, %rcx
addq %r9, %rax
addq $-0x14, %rdx
xorl %r9d, %r9d
vmovsd (%rax,%r9), %xmm0
vmovsd 0xa0(%rsi,%r9), %xmm1
vunpcklpd %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vmovsd (%r8,%r9), %xmm1
vmovsd (%rcx,%r9), %xmm2
vunpcklpd %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vmovapd %xmm1, 0x290(%rdi,%r9,4)
vmovapd %xmm0, 0x280(%rdi,%r9,4)
addq $0x8, %r9
decq %rdx
jne 0x912b
jmp 0x9218
testl %edx, %edx
je 0x9218
movl %edx, %edx
shlq $0x3, %rdx
xorl %r9d, %r9d
vmovsd (%rax,%r9), %xmm0
vmovsd (%rsi,%r9), %xmm1
vunpcklpd %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vmovsd (%r8,%r9), %xmm1
vmovsd (%rcx,%r9), %xmm2
vunpcklpd %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vmovapd %xmm1, 0x10(%rdi,%r9,4)
vmovapd %xmm0, (%rdi,%r9,4)
addq $0x8, %r9
cmpq %r9, %rdx
jne 0x9182
jmp 0x9218
cmpl $0x10, %edx
je 0x9218
movl %edx, %edx
movl $0x80, %r9d
addq %r9, %r8
addq %r9, %rcx
addq %r9, %rax
addq $-0x10, %rdx
xorl %r9d, %r9d
vmovsd (%rax,%r9), %xmm0
vmovsd 0x80(%rsi,%r9), %xmm1
vunpcklpd %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vmovsd (%r8,%r9), %xmm1
vmovsd (%rcx,%r9), %xmm2
vunpcklpd %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vmovapd %xmm1, 0x210(%rdi,%r9,4)
vmovapd %xmm0, 0x200(%rdi,%r9,4)
addq $0x8, %r9
decq %rdx
jne 0x91d7
vzeroupper
retq