// File: /workspace/github_c_makefile_star2_O0/heltilda[P]cicada/lnklst.c
// Function: addPLLElement
ccInt addPLLElement(pinned_LL *basePLL, void **newElementPtr, ccInt *newElementIndex)
{
    ccInt counter, rtrn;
    
    
        // Case 1:  add to the top of the list
    
    if (basePLL->lowestFreeSpot > basePLL->data.elementNum)   {             // shouldn't move what's in the lower sublists
        rtrn = addElements(&(basePLL->data), 1, ccFalse);         // with my current insertElements scheme
        if (rtrn != passed)  return rtrn;
        rtrn = addElements(&(basePLL->references), 1, ccTrue);     // references must be initially set to 0
        if (rtrn != passed)  return rtrn;
        
        *newElementIndex = basePLL->data.elementNum;
        *newElementPtr = element(&(basePLL->data), *newElementIndex);
        basePLL->lowestFreeSpot = *newElementIndex+1;
        basePLL->highestFreeSpot = 1;         }   // cannot equal lowestFreeSpot: we need it to be lower than any spots that open up
    
    
        // Case 2:  go to the lowest free element in the existing list
    
    else  {
        *newElementIndex = basePLL->lowestFreeSpot;
        *newElementPtr = element(&(basePLL->data), *newElementIndex);
        *LL_int(&(basePLL->references), *newElementIndex) = 0;
        
        if (basePLL->lowestFreeSpot >= basePLL->highestFreeSpot)  {
            basePLL->lowestFreeSpot = basePLL->data.elementNum+1;
            basePLL->highestFreeSpot = 1;     }
        
        else  {
        for (counter = basePLL->lowestFreeSpot+1; counter <= basePLL->highestFreeSpot; counter++)  {
        if (*LL_int(&(basePLL->references), counter) == 0)  {
            basePLL->lowestFreeSpot = counter;
            counter = basePLL->highestFreeSpot;
    }   }}}
    
    return passed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x9958
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x98eb
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9a1e
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x8e70
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x9913
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9a1e
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0x9700
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x44(%rax)
jmp 0x9a17
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0x9700
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0x9700
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jl 0x99c4
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x44(%rax)
jmp 0x9a15
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jg 0x9a13
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl -0x24(%rbp), %esi
callq 0x9700
cmpl $0x0, (%rax)
jne 0x9a06
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0x9a08
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x99d1
jmp 0x9a15
jmp 0x9a17
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)