// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/lakekeyakv2/generic32lc/KeccakP-800-opt32.c
// Function: KeccakP800_OverwriteBytes
void KeccakP800_OverwriteBytes(void *argState, const unsigned char *data, unsigned int offset, unsigned int length)
{
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
#ifdef KeccakP800_useLaneComplementing
    unsigned int sizeLeft = length;
    unsigned int lanePosition = offset/4;
    unsigned int offsetInLane = offset%4;
    const unsigned char *curData = data;
    UINT32 *state = (UINT32*)argState;

    if ((sizeLeft > 0) && (offsetInLane != 0)) {
        unsigned int bytesInLane = 4 - offsetInLane;
        unsigned char laneComplement = (unsigned char)KeccakP800LaneComplement[lanePosition];
        if (bytesInLane > sizeLeft)
            bytesInLane = sizeLeft;
        sizeLeft -= bytesInLane;
        do {
            *(((unsigned char *)&state[lanePosition] + offsetInLane)) = *curData++ ^ laneComplement;
            ++offsetInLane;
        }
        while ( --bytesInLane != 0);
        lanePosition++;
    }

    while(sizeLeft >= 4) {
        state[lanePosition] = READ32_UNALIGNED( curData ) ^ KeccakP800LaneComplement[lanePosition];
        sizeLeft -= 4;
        lanePosition++;
        curData += 4;
    }

    if (sizeLeft > 0) {
        unsigned char laneComplement = (unsigned char)KeccakP800LaneComplement[lanePosition];
        unsigned int i;
        for ( i = 0; i < sizeLeft; ++i ) {
            *((unsigned char *)&state[lanePosition] + i) = *curData++ ^ laneComplement;
        }
    }
#else
    memcpy((unsigned char*)argState+offset, data, length);
#endif
#else
#error "Not yet implemented"
#endif
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movl %ecx, -0x18(%rsp)
movl -0x18(%rsp), %eax
movl %eax, -0x1c(%rsp)
movl -0x14(%rsp), %eax
shrl $0x2, %eax
movl %eax, -0x20(%rsp)
movl -0x14(%rsp), %eax
andl $0x3, %eax
movl %eax, -0x24(%rsp)
movq -0x10(%rsp), %rax
movq %rax, -0x30(%rsp)
movq -0x8(%rsp), %rax
movq %rax, -0x38(%rsp)
cmpl $0x0, -0x1c(%rsp)
jbe 0xdb75
cmpl $0x0, -0x24(%rsp)
je 0xdb75
movl $0x4, %eax
subl -0x24(%rsp), %eax
movl %eax, -0x3c(%rsp)
movl -0x20(%rsp), %eax
movl %eax, %ecx
movq 0x124fc(%rip), %rax     # 0x1fff0
movl (%rax,%rcx,4), %eax
movb %al, -0x3d(%rsp)
movl -0x3c(%rsp), %eax
cmpl -0x1c(%rsp), %eax
jbe 0xdb0d
movl -0x1c(%rsp), %eax
movl %eax, -0x3c(%rsp)
movl -0x3c(%rsp), %ecx
movl -0x1c(%rsp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rsp)
movq -0x30(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rsp)
movzbl (%rax), %eax
movzbl -0x3d(%rsp), %ecx
xorl %ecx, %eax
movb %al, %dl
movq -0x38(%rsp), %rax
movl -0x20(%rsp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movl -0x24(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl -0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rsp)
movl -0x3c(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rsp)
cmpl $0x0, %eax
jne 0xdb1b
movl -0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rsp)
jmp 0xdb77
cmpl $0x4, -0x1c(%rsp)
jb 0xdbc7
movq -0x30(%rsp), %rax
movl (%rax), %edx
movl -0x20(%rsp), %eax
movl %eax, %ecx
movq 0x1245e(%rip), %rax     # 0x1fff0
xorl (%rax,%rcx,4), %edx
movq -0x38(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rsp), %eax
subl $0x4, %eax
movl %eax, -0x1c(%rsp)
movl -0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rsp)
movq -0x30(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rsp)
jmp 0xdb77
cmpl $0x0, -0x1c(%rsp)
jbe 0xdc37
movl -0x20(%rsp), %eax
movl %eax, %ecx
movq 0x12415(%rip), %rax     # 0x1fff0
movl (%rax,%rcx,4), %eax
movb %al, -0x3e(%rsp)
movl $0x0, -0x44(%rsp)
movl -0x44(%rsp), %eax
cmpl -0x1c(%rsp), %eax
jae 0xdc35
movq -0x30(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rsp)
movzbl (%rax), %eax
movzbl -0x3e(%rsp), %ecx
xorl %ecx, %eax
movb %al, %dl
movq -0x38(%rsp), %rax
movl -0x20(%rsp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movl -0x44(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl -0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rsp)
jmp 0xdbea
jmp 0xdc37
retq
nopl (%rax,%rax)