// File: /workspace/github_c_makefile_star2_O3/mjosaarinen[P]brutus/crypto_aead/lakekeyakv2/SandyBridge/KeccakP-1600-times2-SIMD128.c
// Function: KeccakP1600times2_ExtractLanesAll
void KeccakP1600times2_ExtractLanesAll(const void *states, unsigned char *data, unsigned int laneCount, unsigned int laneOffset)
{
    const V128 *stateAsLanes = states;
    V128 lanes;
    unsigned int i;
    UINT64 *curData0 = (UINT64 *)data;
    UINT64 *curData1 = (UINT64 *)(data+laneOffset*SnP_laneLengthInBytes);

    #define Extr( argIndex )    lanes = LOAD128( stateAsLanes[argIndex] ),          \
                                STORE64L( curData0[argIndex], lanes ),              \
                                STORE64H( curData1[argIndex], lanes )

    #if defined(KeccakP1600times2_useSSE2)
    #define Extr2( argIndex )   lanes0 = LOAD128( stateAsLanes[argIndex] ),         \
                                lanes1 = LOAD128( stateAsLanes[(argIndex)+1] ),     \
                                lanes =  UNPACKL( lanes0, lanes1 ),                 \
                                lanes0 = UNPACKH( lanes0, lanes1 ),                 \
                                STORE128u( *(V128*)&curData0[argIndex], lanes ),    \
                                STORE128u( *(V128*)&curData1[argIndex], lanes0 )
    if ( laneCount >= 16 )  {
        V128 lanes0, lanes1;
        Extr2( 0 );
        Extr2( 2 );
        Extr2( 4 );
        Extr2( 6 );
        Extr2( 8 );
        Extr2( 10 );
        Extr2( 12 );
        Extr2( 14 );
        if ( laneCount >= 20 )  {
            Extr2( 16 );
            Extr2( 18 );
            for(i=20; i<laneCount; i++)
                Extr( i );
        }
        else {
            for(i=16; i<laneCount; i++)
                Extr( i );
        }
    }
    #undef  Extr2
    #else
    if ( laneCount >= 17 )  {
        Extr( 0 );
        Extr( 1 );
        Extr( 2 );
        Extr( 3 );
        Extr( 4 );
        Extr( 5 );
        Extr( 6 );
        Extr( 7 );
        Extr( 8 );
        Extr( 9 );
        Extr( 10 );
        Extr( 11 );
        Extr( 12 );
        Extr( 13 );
        Extr( 14 );
        Extr( 15 );
        Extr( 16 );
        if ( laneCount >= 21 )  {
            Extr( 17 );
            Extr( 18 );
            Extr( 19 );
            Extr( 20 );
            for(i=21; i<laneCount; i++)
                Extr( i );
        }
        else {
            for(i=17; i<laneCount; i++)
                Extr( i );
        }
    }
    #endif
    else {
        for(i=0; i<laneCount; i++)
            Extr( i );
    }
    #undef  Extr
}

// Assembly:
shll $0x3, %ecx
cmpl $0xf, %edx
jbe 0x133bc
vmovaps (%rdi), %xmm0
vmovaps 0x10(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, (%rsi)
vmovups %xmm0, (%rsi,%rcx)
vmovaps 0x20(%rdi), %xmm0
vmovaps 0x30(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x10(%rsi)
vmovups %xmm0, 0x10(%rsi,%rcx)
vmovaps 0x40(%rdi), %xmm0
vmovaps 0x50(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x20(%rsi)
vmovups %xmm0, 0x20(%rsi,%rcx)
vmovaps 0x60(%rdi), %xmm0
vmovaps 0x70(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x30(%rsi)
vmovups %xmm0, 0x30(%rsi,%rcx)
vmovaps 0x80(%rdi), %xmm0
vmovaps 0x90(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x40(%rsi)
vmovups %xmm0, 0x40(%rsi,%rcx)
vmovaps 0xa0(%rdi), %xmm0
vmovaps 0xb0(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x50(%rsi)
vmovups %xmm0, 0x50(%rsi,%rcx)
vmovaps 0xc0(%rdi), %xmm0
vmovaps 0xd0(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x60(%rsi)
vmovups %xmm0, 0x60(%rsi,%rcx)
vmovaps 0xe0(%rdi), %xmm0
vmovaps 0xf0(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x70(%rsi)
vmovups %xmm0, 0x70(%rsi,%rcx)
cmpl $0x13, %edx
jbe 0x133eb
vmovaps 0x100(%rdi), %xmm0
vmovaps 0x110(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x80(%rsi)
vmovups %xmm0, 0x80(%rsi,%rcx)
vmovaps 0x120(%rdi), %xmm0
vmovaps 0x130(%rdi), %xmm1
vmovlhps %xmm1, %xmm0, %xmm2     # xmm2 = xmm0[0],xmm1[0]
vunpckhpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[1],xmm1[1]
vmovups %xmm2, 0x90(%rsi)
vmovups %xmm0, 0x90(%rsi,%rcx)
cmpl $0x14, %edx
je 0x1341c
movl %edx, %eax
addq %rsi, %rcx
shlq $0x3, %rax
movl $0xa0, %edx
vmovsd (%rdi,%rdx,2), %xmm0
vmovsd 0x8(%rdi,%rdx,2), %xmm1
vmovsd %xmm0, (%rsi,%rdx)
vmovsd %xmm1, (%rcx,%rdx)
addq $0x8, %rdx
cmpq %rdx, %rax
jne 0x1339c
jmp 0x1341c
testl %edx, %edx
je 0x1341c
movl %edx, %eax
addq %rsi, %rcx
shlq $0x3, %rax
xorl %edx, %edx
vmovsd (%rdi,%rdx,2), %xmm0
vmovsd 0x8(%rdi,%rdx,2), %xmm1
vmovsd %xmm0, (%rsi,%rdx)
vmovsd %xmm1, (%rcx,%rdx)
addq $0x8, %rdx
cmpq %rdx, %rax
jne 0x133cb
jmp 0x1341c
cmpl $0x10, %edx
je 0x1341c
movl %edx, %eax
addq %rsi, %rcx
shlq $0x3, %rax
movl $0x80, %edx
vmovsd (%rdi,%rdx,2), %xmm0
vmovsd 0x8(%rdi,%rdx,2), %xmm1
vmovsd %xmm0, (%rsi,%rdx)
vmovsd %xmm1, (%rcx,%rdx)
addq $0x8, %rdx
cmpq %rdx, %rax
jne 0x133fe
retq