// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq 0x8(%rdi), %r12
movb $0x3, %al
testq %r12, %r12
je 0x8ecf
movq 0x8(%rdx), %r13
testq %r13, %r13
je 0x8ecf
movslq 0x10(%rdi), %r14
movb $0x4, %al
cmpl 0x10(%rdx), %r14d
jne 0x8ecf
testl %r8d, %r8d
je 0x8ecd
movl (%rdi), %r10d
cmpl %esi, %r10d
setl %al
testl %esi, %esi
setle %dil
orb %al, %dil
movb $0x2, %al
jne 0x8ecf
movl (%rdx), %r9d
cmpl %ecx, %r9d
setl %dl
testl %ecx, %ecx
setle %dil
orb %dl, %dil
jne 0x8ecf
leal (%r8,%rsi), %edi
leal (%r8,%rsi), %edx
decl %edx
cmpl %edx, %r10d
setl %dl
movl %edi, 0x4(%rsp)
cmpl $0x2, %edi
setl %dil
orb %dl, %dil
jne 0x8ecf
leal (%r8,%rcx), %edx
leal (%r8,%rcx), %edi
decl %edi
cmpl %edi, %r9d
setl %dil
cmpl $0x2, %edx
setl %dl
orb %dil, %dl
jne 0x8ecf
movl (%r12), %eax
movl $0x1, %r15d
cmpl %esi, %eax
jge 0x8da6
movl %eax, %r9d
movq 0x8(%r12), %r12
movl (%r12), %ebp
leal (%r9,%rbp), %eax
cmpl %esi, %eax
jl 0x8d8d
incl %r9d
jmp 0x8dae
movl %eax, %ebp
movl $0x1, %r9d
movl (%r13), %eax
cmpl %ecx, %eax
jge 0x8dce
movl %eax, %r15d
movq 0x8(%r13), %r13
movl (%r13), %r11d
leal (%r11,%r15), %eax
cmpl %ecx, %eax
jl 0x8db6
incl %r15d
jmp 0x8dd1
movl %eax, %r11d
movl $0x1, %eax
movq %rsi, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
addl %r9d, %ebp
leal (%rax,%rsi), %r10d
cmpl %r10d, %ebp
jge 0x8df4
movq 0x8(%r12), %r12
movl %ebp, %r9d
leal (%r11,%r15), %edi
movq %rax, 0x30(%rsp)
leal (%rax,%rcx), %edx
cmpl %edx, %edi
jge 0x8e1a
movq 0x8(%r13), %r13
movl (%r13), %eax
movq %rax, 0x8(%rsp)
leal (%rax,%rdi), %r11d
movl %edi, %r15d
jmp 0x8e22
movq %r11, 0x8(%rsp)
movl %edi, %r11d
movl (%r12), %ebp
leal (%r9,%rbp), %edi
movq %r9, %rax
movl %edi, %r9d
subl %esi, %r9d
cmpl 0x4(%rsp), %edi
cmovgel %r8d, %r9d
leal (%r9,%rcx), %edi
movl %r11d, %ebx
subl %ecx, %ebx
cmpl %edi, %r11d
cmovgel %r9d, %ebx
movq %rax, 0x20(%rsp)
movl %eax, %esi
notl %esi
addl %esi, %r10d
movq %r15, 0x28(%rsp)
movl %r15d, %esi
notl %esi
addl %esi, %edx
movl %ebx, %r9d
subl 0x30(%rsp), %r9d
imull %r14d, %r10d
movslq %r10d, %rax
leaq (%r12,%rax), %rdi
addq $0x18, %rdi
imull %r14d, %edx
movslq %edx, %rax
leaq (%rax,%r13), %rsi
addq $0x18, %rsi
incl %r9d
movslq %r9d, %rdx
movq %r14, %r15
imulq %r14, %rdx
movq %r8, %r14
callq 0x8180
testl %eax, %eax
jne 0x8ede
leal 0x1(%rbx), %eax
cmpl %r14d, %ebx
movq %r14, %r8
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rsi
movq %r15, %r14
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r9
movq 0x8(%rsp), %r11
jl 0x8de0
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x8ecf