// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/lunarkeyakv2/Haswell/KeccakP-1600-times4-SIMD256.c
// Function: KeccakP1600times4_ExtractLanesAll
void KeccakP1600times4_ExtractLanesAll(const void *states, unsigned char *data, unsigned int laneCount, unsigned int laneOffset)
{
    UINT64 *curData0 = (UINT64 *)data;
    UINT64 *curData1 = (UINT64 *)(data+laneOffset*1*SnP_laneLengthInBytes);
    UINT64 *curData2 = (UINT64 *)(data+laneOffset*2*SnP_laneLengthInBytes);
    UINT64 *curData3 = (UINT64 *)(data+laneOffset*3*SnP_laneLengthInBytes);

    const V256 *stateAsLanes = (const V256 *)states;
    const UINT64 *stateAsLanes64 = (const UINT64*)states;
    V256    lanes0, lanes1, lanes2, lanes3, lanesL01, lanesL23, lanesH01, lanesH23;
    unsigned int i;

    #define Extr( argIndex )    curData0[argIndex] = stateAsLanes64[4*(argIndex)],      \
                                curData1[argIndex] = stateAsLanes64[4*(argIndex)+1],    \
                                curData2[argIndex] = stateAsLanes64[4*(argIndex)+2],    \
                                curData3[argIndex] = stateAsLanes64[4*(argIndex)+3]

    #define Extr4( argIndex )   lanes0 = LOAD256( stateAsLanes[argIndex+0] ),           \
                                lanes1 = LOAD256( stateAsLanes[argIndex+1] ),           \
                                lanes2 = LOAD256( stateAsLanes[argIndex+2] ),           \
                                lanes3 = LOAD256( stateAsLanes[argIndex+3] ),           \
                                UNINTLEAVE(),                                           \
                                STORE256u( curData0[argIndex], lanes0 ),                \
                                STORE256u( curData1[argIndex], lanes1 ),                \
                                STORE256u( curData2[argIndex], lanes2 ),                \
                                STORE256u( curData3[argIndex], lanes3 )

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

// Assembly:
leal (,%rcx,8), %r8d
shll $0x4, %ecx
leal (%r8,%r8,2), %eax
cmpl $0xf, %edx
jbe 0x94fb
addq %rsi, %r8
addq %rsi, %rcx
addq %rsi, %rax
vmovdqa (%rdi), %ymm0
vmovdqa 0x20(%rdi), %ymm1
vmovdqa 0x40(%rdi), %ymm2
vmovdqa 0x60(%rdi), %ymm3
vpunpcklqdq %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vpunpckhqdq %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vpunpcklqdq %ymm3, %ymm2, %ymm1 # ymm1 = ymm2[0],ymm3[0],ymm2[2],ymm3[2]
vpunpckhqdq %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[1],ymm3[1],ymm2[3],ymm3[3]
vinserti128 $0x1, %xmm1, %ymm4, %ymm3
vperm2i128 $0x31, %ymm1, %ymm4, %ymm1 # ymm1 = ymm4[2,3],ymm1[2,3]
vinserti128 $0x1, %xmm2, %ymm0, %ymm4
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm3, (%rsi)
vmovdqu %ymm4, (%r8)
vmovdqu %ymm1, (%rcx)
vmovdqu %ymm0, (%rax)
vmovdqa 0x80(%rdi), %ymm0
vmovdqa 0xa0(%rdi), %ymm1
vmovdqa 0xc0(%rdi), %ymm2
vmovdqa 0xe0(%rdi), %ymm3
vpunpcklqdq %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vpunpckhqdq %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vpunpcklqdq %ymm3, %ymm2, %ymm1 # ymm1 = ymm2[0],ymm3[0],ymm2[2],ymm3[2]
vpunpckhqdq %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[1],ymm3[1],ymm2[3],ymm3[3]
vinserti128 $0x1, %xmm1, %ymm4, %ymm3
vperm2i128 $0x31, %ymm1, %ymm4, %ymm1 # ymm1 = ymm4[2,3],ymm1[2,3]
vinserti128 $0x1, %xmm2, %ymm0, %ymm4
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm3, 0x20(%rsi)
vmovdqu %ymm4, 0x20(%r8)
vmovdqu %ymm1, 0x20(%rcx)
vmovdqu %ymm0, 0x20(%rax)
vmovdqa 0x100(%rdi), %ymm0
vmovdqa 0x120(%rdi), %ymm1
vmovdqa 0x140(%rdi), %ymm2
vmovdqa 0x160(%rdi), %ymm3
vpunpcklqdq %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vpunpckhqdq %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vpunpcklqdq %ymm3, %ymm2, %ymm1 # ymm1 = ymm2[0],ymm3[0],ymm2[2],ymm3[2]
vpunpckhqdq %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[1],ymm3[1],ymm2[3],ymm3[3]
vinserti128 $0x1, %xmm1, %ymm4, %ymm3
vperm2i128 $0x31, %ymm1, %ymm4, %ymm1 # ymm1 = ymm4[2,3],ymm1[2,3]
vinserti128 $0x1, %xmm2, %ymm0, %ymm4
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm3, 0x40(%rsi)
vmovdqu %ymm4, 0x40(%r8)
vmovdqu %ymm1, 0x40(%rcx)
vmovdqu %ymm0, 0x40(%rax)
vmovdqa 0x180(%rdi), %ymm0
vmovdqa 0x1a0(%rdi), %ymm1
vmovdqa 0x1c0(%rdi), %ymm2
vmovdqa 0x1e0(%rdi), %ymm3
vpunpcklqdq %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vpunpckhqdq %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vpunpcklqdq %ymm3, %ymm2, %ymm1 # ymm1 = ymm2[0],ymm3[0],ymm2[2],ymm3[2]
vpunpckhqdq %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[1],ymm3[1],ymm2[3],ymm3[3]
vinserti128 $0x1, %xmm1, %ymm4, %ymm3
vperm2i128 $0x31, %ymm1, %ymm4, %ymm1 # ymm1 = ymm4[2,3],ymm1[2,3]
vinserti128 $0x1, %xmm2, %ymm0, %ymm4
vmovdqu %ymm3, 0x60(%rsi)
vmovdqu %ymm4, 0x60(%r8)
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm1, 0x60(%rcx)
vmovdqu %ymm0, 0x60(%rax)
cmpl $0x13, %edx
jbe 0x9539
vmovdqa 0x200(%rdi), %ymm0
vmovdqa 0x220(%rdi), %ymm1
vmovdqa 0x240(%rdi), %ymm2
vmovdqa 0x260(%rdi), %ymm3
vpunpcklqdq %ymm1, %ymm0, %ymm4 # ymm4 = ymm0[0],ymm1[0],ymm0[2],ymm1[2]
vpunpckhqdq %ymm1, %ymm0, %ymm0 # ymm0 = ymm0[1],ymm1[1],ymm0[3],ymm1[3]
vpunpcklqdq %ymm3, %ymm2, %ymm1 # ymm1 = ymm2[0],ymm3[0],ymm2[2],ymm3[2]
vpunpckhqdq %ymm3, %ymm2, %ymm2 # ymm2 = ymm2[1],ymm3[1],ymm2[3],ymm3[3]
vinserti128 $0x1, %xmm1, %ymm4, %ymm3
vperm2i128 $0x31, %ymm1, %ymm4, %ymm1 # ymm1 = ymm4[2,3],ymm1[2,3]
vinserti128 $0x1, %xmm2, %ymm0, %ymm4
vmovdqu %ymm3, 0x80(%rsi)
vmovdqu %ymm4, 0x80(%r8)
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm1, 0x80(%rcx)
vmovdqu %ymm0, 0x80(%rax)
cmpl $0x14, %edx
je 0x9576
movl %edx, %edx
movl $0xa0, %r9d
addq %r9, %r8
addq %r9, %rcx
addq %r9, %rax
addq $-0x14, %rdx
xorl %r9d, %r9d
leal 0x50(%r9), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, 0xa0(%rsi,%r9,2)
leal 0x51(%r9), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, (%r8,%r9,2)
leal 0x52(%r9), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, (%rcx,%r9,2)
leal 0x53(%r9), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, (%rax,%r9,2)
addq $0x4, %r9
decq %rdx
jne 0x94bc
jmp 0x9576
testl %edx, %edx
je 0x9576
movl %edx, %edx
shlq $0x5, %rdx
xorl %r9d, %r9d
movq (%rdi,%r9), %r10
movq %r10, (%rsi)
movq 0x8(%rdi,%r9), %r10
movq %r10, (%rsi,%r8)
movq 0x10(%rdi,%r9), %r10
movq %r10, (%rsi,%rcx)
movq 0x18(%rdi,%r9), %r10
movq %r10, (%rsi,%rax)
addq $0x8, %rsi
addq $0x20, %r9
cmpq %r9, %rdx
jne 0x9508
jmp 0x9576
cmpl $0x10, %edx
je 0x9576
movl %edx, %edx
shlq $0x3, %rdx
movl $0x80, %r9d
movq (%rdi,%r9,4), %r10
movq %r10, (%rsi,%r9)
movq 0x8(%rdi,%r9,4), %r10
movq %r10, (%r8,%r9)
movq 0x10(%rdi,%r9,4), %r10
movq %r10, (%rcx,%r9)
movq 0x18(%rdi,%r9,4), %r10
movq %r10, (%rax,%r9)
addq $0x8, %r9
cmpq %r9, %rdx
jne 0x954a
vzeroupper
retq