// File: /workspace/github_c_makefile_star2_O1/heltilda[P]cicada/lnklst.c
// Function: compareElements
ccBool compareElements(linkedlist *sourceList, ccInt sourceBegin, linkedlist * destList, ccInt destBegin, ccInt numberToCompare)
{
    ccInt firstCompared, lastCompared, elementSize, sourceBottom, destBottom, rtrn;
    sublistHeader *currentSourceSublist, *currentDestSublist;
    
    
        // make sure params were passed correctly
    
    if ((sourceList->memory == NULL) || (destList->memory == NULL))  return init_err;
    if (sourceList->elementSize != destList->elementSize)  return mismatched_indices_err;
    if (numberToCompare == 0)  return ccTrue;
    if ((!elementExists(sourceList, sourceBegin)) || (!elementExists(destList, destBegin)))
        return out_of_range_err;
    if ((!elementExists(sourceList, sourceBegin+numberToCompare-1)) || (!elementExists(destList, destBegin+numberToCompare-1)))
        return out_of_range_err;
    
    elementSize = sourceList->elementSize;
    
    currentSourceSublist = findSublist(sourceList, sourceBegin, &sourceBottom);
    currentDestSublist = findSublist(destList, destBegin, &destBottom);
    
    firstCompared = 1;
    lastCompared = numberToCompare-1;
    
    
        // Now, by chunks (size of each sublist), do straight comparisons of memory.
    
    while (lastCompared < numberToCompare)
    {
        if (currentSourceSublist->numElements + sourceBottom < sourceBegin+firstCompared)   {
            sourceBottom += currentSourceSublist->numElements;
            currentSourceSublist = currentSourceSublist->nextSublist;    }
        
        if (currentDestSublist->numElements + destBottom < destBegin+firstCompared)    {
            destBottom += currentDestSublist->numElements;
            currentDestSublist = currentDestSublist->nextSublist;    }
        
        lastCompared = numberToCompare;
        if (sourceBottom+currentSourceSublist->numElements < sourceBegin+lastCompared)
            lastCompared = sourceBottom + currentSourceSublist->numElements - sourceBegin;
        if (destBottom+currentDestSublist->numElements < destBegin+lastCompared)
            lastCompared = destBottom + currentDestSublist->numElements - destBegin;
        
        rtrn = memcmp((void *) ((char *) currentSourceSublist + (firstCompared+sourceBegin-sourceBottom-1)*elementSize + sublistHeaderSize),
                        (void *) ((char *) currentDestSublist + (firstCompared+destBegin-destBottom-1)*elementSize + sublistHeaderSize),
                        (size_t) (lastCompared-firstCompared+1)*elementSize);
        if (rtrn != 0)  return ccFalse;
        
        firstCompared = lastCompared+1;
    }
    
    return ccTrue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x8(%rdi), %r12
movb $0x3, %al
testq %r12, %r12
je 0x8e2e
movq 0x8(%rdx), %r13
testq %r13, %r13
je 0x8e2e
movslq 0x10(%rdi), %r9
movb $0x4, %al
cmpl 0x10(%rdx), %r9d
jne 0x8e2e
movl %r8d, %r14d
testl %r8d, %r8d
je 0x8e2c
movb $0x2, %al
testl %esi, %esi
jle 0x8e2e
cmpl %esi, (%rdi)
jl 0x8e2e
testl %ecx, %ecx
jle 0x8e2e
cmpl %ecx, (%rdx)
jl 0x8e2e
leal (%r14,%rsi), %r10d
movl %r10d, (%rsp)
cmpl $0x2, %r10d
jl 0x8e2e
leal (%r14,%rsi), %r10d
decl %r10d
cmpl %r10d, (%rdi)
jl 0x8e2e
leal (%r14,%rcx), %edi
cmpl $0x2, %edi
jl 0x8e2e
leal (%r14,%rcx), %edi
decl %edi
cmpl %edi, (%rdx)
jl 0x8e2e
movl (%r12), %eax
movl $0x1, %ebx
cmpl %esi, %eax
jge 0x8d39
movl %eax, %r15d
movq 0x8(%r12), %r12
movl (%r12), %eax
addl %r15d, %eax
cmpl %esi, %eax
jl 0x8d21
incl %r15d
jmp 0x8d3f
movl $0x1, %r15d
movl (%r13), %eax
cmpl %ecx, %eax
jge 0x8d59
movl %eax, %ebx
movq 0x8(%r13), %r13
movl (%r13), %eax
addl %ebx, %eax
cmpl %ecx, %eax
jl 0x8d47
incl %ebx
movl $0x1, %eax
movq %rsi, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movl (%r12), %edx
addl %r15d, %edx
leal (%rax,%rsi), %r10d
cmpl %r10d, %edx
jge 0x8d80
movq 0x8(%r12), %r12
movl %edx, %r15d
movl (%r13), %edi
addl %ebx, %edi
leal (%rax,%rcx), %edx
cmpl %edx, %edi
jge 0x8d93
movq 0x8(%r13), %r13
movl %edi, %ebx
movl (%r12), %r11d
addl %r15d, %r11d
movl %r11d, %edi
subl %esi, %edi
cmpl (%rsp), %r11d
cmovgel %r14d, %edi
movl (%r13), %esi
addl %ebx, %esi
leal (%rdi,%rcx), %r8d
movl %esi, %ebp
subl %ecx, %ebp
cmpl %r8d, %esi
cmovgel %edi, %ebp
movl %r15d, 0x4(%rsp)
movl %r15d, %esi
notl %esi
addl %esi, %r10d
movl %ebx, %r15d
movl %ebx, %esi
notl %esi
addl %esi, %edx
movl %ebp, %r8d
subl %eax, %r8d
imull %r9d, %r10d
movslq %r10d, %rax
leaq (%r12,%rax), %rdi
addq $0x18, %rdi
imull %r9d, %edx
movslq %edx, %rax
leaq (%rax,%r13), %rsi
addq $0x18, %rsi
incl %r8d
movslq %r8d, %rdx
movq %r9, %rbx
imulq %r9, %rdx
callq 0x8180
testl %eax, %eax
jne 0x8e3d
leal 0x1(%rbp), %eax
cmpl %r14d, %ebp
movq %rbx, %r9
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rsi
movl %r15d, %ebx
movl 0x4(%rsp), %r15d
jl 0x8d68
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x8e2e