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

    #define OverWr( argIndex )  stateAsLanes[argIndex] = LOAD_GATHER8_64(index, dataAsLanes+argIndex)
    index = LOAD8_32(7*laneOffset, 6*laneOffset, 5*laneOffset, 4*laneOffset, 3*laneOffset, 2*laneOffset, 1*laneOffset, 0*laneOffset);
    if ( laneCount >= 16 )  {
        OverWr( 0 );
        OverWr( 1 );
        OverWr( 2 );
        OverWr( 3 );
        OverWr( 4 );
        OverWr( 5 );
        OverWr( 6 );
        OverWr( 7 );
        OverWr( 8 );
        OverWr( 9 );
        OverWr( 10 );
        OverWr( 11 );
        OverWr( 12 );
        OverWr( 13 );
        OverWr( 14 );
        OverWr( 15 );
        if ( laneCount >= 20 )  {
	        OverWr( 16 );
    	    OverWr( 17 );
	        OverWr( 18 );
    	    OverWr( 19 );
            for(i=20; i<laneCount; i++)
                OverWr( i );
        }
        else {
            for(i=16; i<laneCount; i++)
                OverWr( i );
        }
    }
    else {
        for(i=0; i<laneCount; i++)
            OverWr( i );
    }
    #undef  OverWr
}

// Assembly:
vpbroadcastd %ecx, %xmm0
vpmulld 0x19b66(%rip), %xmm0, %xmm1 # 0x304c0
vpmulld 0x19b6d(%rip), %xmm0, %xmm2 # 0x304d0
movb $0x2, %al
kmovd %eax, %k1
vpexpandd %ymm0, %ymm0 {%k1} {z}
vpmovsxbq 0x19ba8(%rip), %ymm3 # 0x30520
vpermi2q %ymm0, %ymm2, %ymm3
vpmovsxbq 0x19b9d(%rip), %ymm0 # 0x30524
vpermi2q %ymm1, %ymm3, %ymm0
cmpl $0xf, %edx
jbe 0x16baa
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq (%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, (%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x8(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x40(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x10(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x80(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x18(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0xc0(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x20(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x100(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x28(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x140(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x30(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x180(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x38(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x1c0(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x40(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x200(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x48(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x240(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x50(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x280(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x58(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x2c0(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x60(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x300(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x68(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x340(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq 0x70(%rsi,%ymm0,8), %zmm1 {%k1}
kxnorw %k0, %k0, %k1
vmovdqa64 %zmm1, 0x380(%rdi)
vpxor %xmm2, %xmm2, %xmm2
vpgatherdq 0x78(%rsi,%ymm0,8), %zmm2 {%k1}
vpxor %xmm1, %xmm1, %xmm1
vmovdqa64 %zmm2, 0x3c0(%rdi)
cmpl $0x13, %edx
jbe 0x16bdb
kxnorw %k0, %k0, %k1
vpxor %xmm2, %xmm2, %xmm2
vpgatherdq 0x80(%rsi,%ymm0,8), %zmm2 {%k1}
vmovdqa64 %zmm2, 0x400(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm2, %xmm2, %xmm2
vpgatherdq 0x88(%rsi,%ymm0,8), %zmm2 {%k1}
vmovdqa64 %zmm2, 0x440(%rdi)
kxnorw %k0, %k0, %k1
vpxor %xmm2, %xmm2, %xmm2
vpgatherdq 0x90(%rsi,%ymm0,8), %zmm2 {%k1}
vmovdqa64 %zmm2, 0x480(%rdi)
kxnorw %k0, %k0, %k1
vpgatherdq 0x98(%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, 0x4c0(%rdi)
cmpl $0x14, %edx
je 0x16c13
movl %edx, %eax
addq $0xa0, %rsi
addq $0x500, %rdi            # imm = 0x500
addq $-0x14, %rax
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq (%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, (%rdi)
addq $0x8, %rsi
addq $0x40, %rdi
decq %rax
jne 0x16b86
jmp 0x16c13
testl %edx, %edx
je 0x16c13
movl %edx, %eax
shlq $0x3, %rax
xorl %ecx, %ecx
leaq (%rsi,%rcx), %rdx
kxnorw %k0, %k0, %k1
vpxor %xmm1, %xmm1, %xmm1
vpgatherdq (%rdx,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, (%rdi,%rcx,8)
addq $0x8, %rcx
cmpq %rcx, %rax
jne 0x16bb6
jmp 0x16c13
cmpl $0x10, %edx
je 0x16c13
movl %edx, %eax
subq $-0x80, %rsi
addq $0x400, %rdi            # imm = 0x400
addq $-0x10, %rax
vpxor %xmm1, %xmm1, %xmm1
kxnorw %k0, %k0, %k1
vpgatherdq (%rsi,%ymm0,8), %zmm1 {%k1}
vmovdqa64 %zmm1, (%rdi)
addq $0x8, %rsi
addq $0x40, %rdi
decq %rax
jne 0x16bf1
vzeroupper
retq