// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/oceankeyakv2/KnightsLanding/KeccakP-1600-times8-SIMD512.c
// Function: KeccakP1600times8_ExtractLanesAll
void KeccakP1600times8_ExtractLanesAll(const void *states, unsigned char *data, unsigned int laneCount, unsigned int laneOffset)
{
    const V512 *stateAsLanes = states;
    UINT64 *dataAsLanes = (UINT64 *)data;
    unsigned int i;
	V256 index;

    #define Extr( argIndex )  STORE_SCATTER8_64(dataAsLanes+argIndex, index, stateAsLanes[argIndex])
    index = LOAD8_32(7*laneOffset, 6*laneOffset, 5*laneOffset, 4*laneOffset, 3*laneOffset, 2*laneOffset, 1*laneOffset, 0*laneOffset);
    if ( laneCount >= 16 )  {
        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 );
        if ( laneCount >= 20 )  {
	        Extr( 16 );
    	    Extr( 17 );
	        Extr( 18 );
    	    Extr( 19 );
            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
}

// Assembly:
vpbroadcastd %ecx, %xmm0
vpmulld 0x189e9(%rip), %xmm0, %xmm1 # 0x2f4c0
vpmulld 0x189f0(%rip), %xmm0, %xmm2 # 0x2f4d0
movb $0x2, %al
kmovd %eax, %k1
vpexpandd %ymm0, %ymm0 {%k1} {z}
vpmovsxbq 0x18a2b(%rip), %ymm3 # 0x2f520
vpermi2q %ymm0, %ymm2, %ymm3
vpmovsxbq 0x18a20(%rip), %ymm0 # 0x2f524
vpermi2q %ymm1, %ymm3, %ymm0
cmpl $0xf, %edx
jbe 0x16cc2
vmovdqa64 (%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rsi,%ymm0,8) {%k1}
vmovdqa64 0x40(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x8(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x80(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x10(%rsi,%ymm0,8) {%k1}
vmovdqa64 0xc0(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x18(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x100(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x20(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x140(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x28(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x180(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x30(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x1c0(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x38(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x200(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x40(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x240(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x48(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x280(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x50(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x2c0(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x58(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x300(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x60(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x340(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x68(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x380(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x70(%rsi,%ymm0,8) {%k1}
kxnorw %k0, %k0, %k1
vmovdqa64 0x3c0(%rdi), %zmm1
vpscatterdq %zmm1, 0x78(%rsi,%ymm0,8) {%k1}
cmpl $0x13, %edx
jbe 0x16ceb
vmovdqa64 0x400(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x80(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x440(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x88(%rsi,%ymm0,8) {%k1}
vmovdqa64 0x480(%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, 0x90(%rsi,%ymm0,8) {%k1}
kxnorw %k0, %k0, %k1
vmovdqa64 0x4c0(%rdi), %zmm1
vpscatterdq %zmm1, 0x98(%rsi,%ymm0,8) {%k1}
movl %edx, %eax
shlq $0x3, %rax
movl $0xa0, %ecx
cmpq %rcx, %rax
je 0x16d17
leaq (%rsi,%rcx), %rdx
vmovdqa64 (%rdi,%rcx,8), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rdx,%ymm0,8) {%k1}
addq $0x8, %rcx
jmp 0x16ca1
movl %edx, %eax
shlq $0x3, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x16d17
leaq (%rsi,%rcx), %rdx
vmovdqa64 (%rdi,%rcx,8), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rdx,%ymm0,8) {%k1}
addq $0x8, %rcx
jmp 0x16cca
movl %edx, %eax
shlq $0x3, %rax
movl $0x80, %ecx
cmpq %rcx, %rax
je 0x16d17
leaq (%rsi,%rcx), %rdx
vmovdqa64 (%rdi,%rcx,8), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rdx,%ymm0,8) {%k1}
addq $0x8, %rcx
jmp 0x16cf6
vzeroupper
retq