// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/lakekeyakv2/SandyBridge/KeccakP-1600-times2-SIMD128.c
// Function: KeccakP1600times2_ExtractAndAddBytes
void KeccakP1600times2_ExtractAndAddBytes(const void *states, unsigned int instanceIndex,  const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
{
    unsigned int sizeLeft = length;
    unsigned int lanePosition = offset/SnP_laneLengthInBytes;
    unsigned int offsetInLane = offset%SnP_laneLengthInBytes;
    const unsigned char *curInput = input;
    unsigned char *curOutput = output;
    const UINT64 *statesAsLanes = states;

    if ((sizeLeft > 0) && (offsetInLane != 0)) {
        unsigned int bytesInLane = SnP_laneLengthInBytes - offsetInLane;
        UINT64 lane = statesAsLanes[laneIndex(instanceIndex, lanePosition)] >> (8 * offsetInLane);
        if (bytesInLane > sizeLeft)
            bytesInLane = sizeLeft;
        sizeLeft -= bytesInLane;
        do {
            *(curOutput++) = *(curInput++) ^ (unsigned char)lane;
            lane >>= 8;
        } while ( --bytesInLane != 0);
        lanePosition++;
    }

    while(sizeLeft >= SnP_laneLengthInBytes) {
        *((UINT64*)curOutput) = *((UINT64*)curInput) ^ statesAsLanes[laneIndex(instanceIndex, lanePosition)];
        sizeLeft -= SnP_laneLengthInBytes;
        lanePosition++;
        curInput += SnP_laneLengthInBytes;
        curOutput += SnP_laneLengthInBytes;
    }

    if (sizeLeft != 0) {
        UINT64 lane = statesAsLanes[laneIndex(instanceIndex, lanePosition)];
        do {
            *(curOutput++) = *(curInput++) ^ (unsigned char)lane;
            lane >>= 8;
        } while ( --sizeLeft != 0);
    }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movq %rdx, -0x18(%rsp)
movq %rcx, -0x20(%rsp)
movl %r8d, -0x24(%rsp)
movl %r9d, -0x28(%rsp)
movl -0x28(%rsp), %eax
movl %eax, -0x2c(%rsp)
movl -0x24(%rsp), %eax
shrl $0x3, %eax
movl %eax, -0x30(%rsp)
movl -0x24(%rsp), %eax
andl $0x7, %eax
movl %eax, -0x34(%rsp)
movq -0x18(%rsp), %rax
movq %rax, -0x40(%rsp)
movq -0x20(%rsp), %rax
movq %rax, -0x48(%rsp)
movq -0x8(%rsp), %rax
movq %rax, -0x50(%rsp)
cmpl $0x0, -0x2c(%rsp)
jbe 0x16cbe
cmpl $0x0, -0x34(%rsp)
je 0x16cbe
movl $0x8, %eax
subl -0x34(%rsp), %eax
movl %eax, -0x54(%rsp)
movq -0x50(%rsp), %rax
movl -0x30(%rsp), %ecx
shll %ecx
addl -0xc(%rsp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl -0x34(%rsp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x60(%rsp)
movl -0x54(%rsp), %eax
cmpl -0x2c(%rsp), %eax
jbe 0x16c54
movl -0x2c(%rsp), %eax
movl %eax, -0x54(%rsp)
movl -0x54(%rsp), %ecx
movl -0x2c(%rsp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rsp)
movq -0x40(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rsp)
movzbl (%rax), %eax
movq -0x60(%rsp), %rcx
movzbl %cl, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x48(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x48(%rsp)
movb %cl, (%rax)
movq -0x60(%rsp), %rax
shrq $0x8, %rax
movq %rax, -0x60(%rsp)
movl -0x54(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rsp)
cmpl $0x0, %eax
jne 0x16c62
movl -0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rsp)
jmp 0x16cc0
cmpl $0x8, -0x2c(%rsp)
jb 0x16d20
movq -0x40(%rsp), %rax
movq (%rax), %rcx
movq -0x50(%rsp), %rax
movl -0x30(%rsp), %edx
shll %edx
addl -0xc(%rsp), %edx
movl %edx, %edx
xorq (%rax,%rdx,8), %rcx
movq -0x48(%rsp), %rax
movq %rcx, (%rax)
movl -0x2c(%rsp), %eax
subl $0x8, %eax
movl %eax, -0x2c(%rsp)
movl -0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rsp)
movq -0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rsp)
movq -0x48(%rsp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rsp)
jmp 0x16cc0
cmpl $0x0, -0x2c(%rsp)
je 0x16d94
movq -0x50(%rsp), %rax
movl -0x30(%rsp), %ecx
shll %ecx
addl -0xc(%rsp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rsp)
movq -0x40(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rsp)
movzbl (%rax), %eax
movq -0x68(%rsp), %rcx
movzbl %cl, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x48(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x48(%rsp)
movb %cl, (%rax)
movq -0x68(%rsp), %rax
shrq $0x8, %rax
movq %rax, -0x68(%rsp)
movl -0x2c(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rsp)
cmpl $0x0, %eax
jne 0x16d41
jmp 0x16d94
retq
nopw %cs:(%rax,%rax)