// File: /workspace/github_c_makefile_star2_O1/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 0x1a7a7(%rip), %xmm0, %xmm1 # 0x314c0
vpmulld 0x1a7ae(%rip), %xmm0, %xmm2 # 0x314d0
movb $0x2, %al
kmovd %eax, %k1
vpexpandd %ymm0, %ymm0 {%k1} {z}
vpmovsxbq 0x1a7e9(%rip), %ymm3 # 0x31520
vpermi2q %ymm0, %ymm2, %ymm3
vpmovsxbq 0x1a7de(%rip), %ymm0 # 0x31524
vpermi2q %ymm1, %ymm3, %ymm0
cmpl $0xf, %edx
jbe 0x16f15
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 0x16f42
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}
cmpl $0x14, %edx
je 0x16f76
movl %edx, %eax
addq $0xa0, %rsi
addq $0x500, %rdi            # imm = 0x500
addq $-0x14, %rax
vmovdqa64 (%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rsi,%ymm0,8) {%k1}
addq $0x8, %rsi
addq $0x40, %rdi
decq %rax
jne 0x16ef5
jmp 0x16f76
testl %edx, %edx
je 0x16f76
movl %edx, %eax
shlq $0x3, %rax
xorl %ecx, %ecx
leaq (%rsi,%rcx), %rdx
vmovdqa64 (%rdi,%rcx,8), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rdx,%ymm0,8) {%k1}
addq $0x8, %rcx
cmpq %rcx, %rax
jne 0x16f21
jmp 0x16f76
cmpl $0x10, %edx
je 0x16f76
movl %edx, %eax
subq $-0x80, %rsi
addq $0x400, %rdi            # imm = 0x400
addq $-0x10, %rax
vmovdqa64 (%rdi), %zmm1
kxnorw %k0, %k0, %k1
vpscatterdq %zmm1, (%rsi,%ymm0,8) {%k1}
addq $0x8, %rsi
addq $0x40, %rdi
decq %rax
jne 0x16f58
vzeroupper
retq