// File: /workspace/github_c_makefile_star2_O2/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
imull $0x18, %ecx, %eax
shll $0x4, %ecx
cmpl $0xf, %edx
jbe 0x93f8
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, (%rsi,%r8)
vmovdqu %ymm1, (%rsi,%rcx)
vmovdqu %ymm0, (%rsi,%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(%rsi,%r8)
vmovdqu %ymm1, 0x20(%rsi,%rcx)
vmovdqu %ymm0, 0x20(%rsi,%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(%rsi,%r8)
vmovdqu %ymm1, 0x40(%rsi,%rcx)
vmovdqu %ymm0, 0x40(%rsi,%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(%rsi,%r8)
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm1, 0x60(%rsi,%rcx)
vmovdqu %ymm0, 0x60(%rsi,%rax)
cmpl $0x13, %edx
jbe 0x9436
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
vperm2i128 $0x31, %ymm2, %ymm0, %ymm0 # ymm0 = ymm0[2,3],ymm2[2,3]
vmovdqu %ymm3, 0x80(%rsi)
leaq (%rsi,%r8), %r9
vmovdqu %ymm4, 0x80(%rsi,%r8)
leaq (%rsi,%rcx), %r8
vmovdqu %ymm1, 0x80(%rsi,%rcx)
leaq (%rsi,%rax), %rcx
vmovdqu %ymm0, 0x80(%rsi,%rax)
movl %edx, %eax
leaq -0x50(,%rax,4), %rax
movl $0xa0, %edx
addq %rdx, %r9
addq %rdx, %r8
addq %rdx, %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x949a
leal 0x50(%rdx), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, 0xa0(%rsi,%rdx,2)
leal 0x51(%rdx), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, (%r9,%rdx,2)
leal 0x52(%rdx), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, (%r8,%rdx,2)
leal 0x53(%rdx), %r10d
movq (%rdi,%r10,8), %r10
movq %r10, (%rcx,%rdx,2)
addq $0x4, %rdx
jmp 0x93b5
movl %edx, %edx
shlq $0x2, %rdx
xorl %r9d, %r9d
cmpq %r9, %rdx
je 0x949a
movq (%rdi,%r9,8), %r10
movq %r10, (%rsi)
movq 0x8(%rdi,%r9,8), %r10
movq %r10, (%rsi,%r8)
movq 0x10(%rdi,%r9,8), %r10
movq %r10, (%rsi,%rcx)
movq 0x18(%rdi,%r9,8), %r10
movq %r10, (%rsi,%rax)
addq $0x4, %r9
addq $0x8, %rsi
jmp 0x9401
movl %edx, %edx
leaq -0x80(,%rdx,8), %rdx
addq %rsi, %r8
movl $0x80, %r9d
addq %r9, %r8
addq %rsi, %rcx
addq %r9, %rcx
addq %rsi, %rax
addq %r9, %rax
xorl %r9d, %r9d
cmpq %r9, %rdx
je 0x949a
movq 0x200(%rdi,%r9,4), %r10
movq %r10, 0x80(%rsi,%r9)
movq 0x208(%rdi,%r9,4), %r10
movq %r10, (%r8,%r9)
movq 0x210(%rdi,%r9,4), %r10
movq %r10, (%rcx,%r9)
movq 0x218(%rdi,%r9,4), %r10
movq %r10, (%rax,%r9)
addq $0x8, %r9
jmp 0x945b
vzeroupper
retq