// File: /workspace/github_c_makefile_star2_O1/heltilda[P]cicada/intrpt.c
// Function: addMemory
ccInt addMemory(window *theWindow, ccInt insertionOffset, ccInt newIndices)
{
    member *loopMember;
    window *loopWindow;
    view *loopView;
    variable *theVariable = theWindow->variable_ptr;
    ccInt counter, rtrn, fullInsertionOffset = insertionOffset + theWindow->offset;
    
    if (newIndices == 0)  return passed;
    
    theVariable->instances += newIndices;
    
    
        // adjust the offset/index_width of any window that could conceivably be affected
    
    for (counter = 1; counter <= theVariable->windows.data.elementNum; counter++)  {
        loopWindow = (window *) element(&(theVariable->windows.data), counter);    // 1st cond below:  if theWindow isn't yet ref'd
        if ((loopWindow == theWindow) || (*LL_int(&(theVariable->windows.references), counter) != 0))  {
            adjustOffsetAndIW(loopWindow == theWindow,
                    &(loopWindow->offset), &(loopWindow->width), fullInsertionOffset, newIndices);
    }   }
    
    if (baseView.windowPtr != NULL)  {
    if (baseView.windowPtr->variable_ptr == theVariable)  {
        adjustOffsetAndIW(baseView.windowPtr->variable_ptr == theWindow->variable_ptr,
                    &(baseView.offset), &(baseView.width), fullInsertionOffset, newIndices);
    }}
    if (searchView.windowPtr != NULL)  {
    if (searchView.windowPtr->variable_ptr == theVariable)  {
        adjustOffsetAndIW(searchView.windowPtr->variable_ptr == theWindow->variable_ptr,
                    &(searchView.offset), &(searchView.width), fullInsertionOffset, newIndices);
    }}
    
    for (counter = 1; counter <= PCStack.top; counter++)  {
        loopView = (view *) element(&(PCStack.data), counter);
        if (loopView->windowPtr != NULL)  {
        if (loopView->windowPtr->variable_ptr == theVariable)     {
            adjustOffsetAndIW(loopView->windowPtr->variable_ptr == theWindow->variable_ptr,
                    &(loopView->offset), &(loopView->width), fullInsertionOffset, newIndices);
    }   }}
    
    
        // recursively call addMemory() for each member, if it is a composite or array variable
    
    if (theVariable->type >= composite_type)  {
        if (isBusy(theVariable, busy_add_flag))  return passed;
        setBusy(theVariable, busy_add_flag);
        
        for (counter = 1; counter <= theVariable->mem.members.elementNum; counter++)  {
            loopMember = LL_member(theVariable, counter);
            if ((loopMember->memberWindow != NULL) && (loopMember->memberWindow->jamStatus != unjammed))  {
                if (((ccFloat) newIndices)*loopMember->indices > ccIntMax)  return index_argument_err;
                rtrn = addMemory(loopMember->memberWindow,
                        insertionOffset*(loopMember->indices)+loopMember->memberWindow->offset, newIndices*loopMember->indices);
                if (rtrn != passed)  return rtrn;
        }   }
        
        if (GL_Path.stemView.windowPtr != NULL)  {
        if (GL_Path.stemView.windowPtr->variable_ptr == theVariable)  {
            adjustOffsetAndIW(GL_Path.stemView.windowPtr == theWindow,
                    &(GL_Path.stemView.offset), &(GL_Path.stemView.width), fullInsertionOffset, newIndices);
            GL_Path.stemMember = NULL;       // we can't tell if it was added to or pushed up
    }   }}
    
    
            // if a primitive variable, add the memory directly to the linked lists
    
    else  {
        if (newIndices > 0)  {
            
            if (theVariable->type != string_type)  {
                rtrn = insertElements(&(theVariable->mem.data), fullInsertionOffset+1, newIndices, ccTrue);
                if (rtrn != passed)  return rtrn;       }
            
            else  {         // allocate one big sublist in case the members LL isn't set up with spare room
                rtrn = addMember(theVariable, fullInsertionOffset+1, 0, NULL, ccFalse, newIndices, ccFalse);
                if (rtrn != passed)  return rtrn;
                
                for (counter = fullInsertionOffset+1; counter <= fullInsertionOffset+newIndices; counter++)  {
                    
                    variable *oneStringVar;
                    window *oneStringWindow = NULL;
                    member *oneStringMember = NULL;
                    
                    rtrn = addVariable(&oneStringVar, char_type, char_type, 0, ccFalse);
                    if (rtrn == passed)  rtrn = addWindow(oneStringVar, 0, 0, &oneStringWindow, ccTrue);
                    if (rtrn == passed)  rtrn = addMember(theVariable, counter, 0, &oneStringMember, ccFalse, 0, ccTrue);
                    if (rtrn != passed)  return rtrn;
                    
                    oneStringMember->memberWindow = oneStringWindow;
                    refWindow(oneStringWindow);
        }   }   }
        else  {
            if (theVariable->type == string_type)  {
            for (counter = fullInsertionOffset+(-newIndices); counter >= fullInsertionOffset+1; counter--)  {
                removeMember(theVariable, counter);
            }}
            else  deleteElements(&(theVariable->mem.data), fullInsertionOffset+1, fullInsertionOffset+(-newIndices));
    }   }
    
    return passed;
}

// Assembly:
xorl %eax, %eax
testl %edx, %edx
je 0xeac5
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r12
movq 0x10(%rdi), %rax
movl 0x18(%rdi), %r14d
movl %edx, 0x14(%rsp)
addl %edx, 0xf0(%rax)
movl %esi, 0x2c(%rsp)
addl %esi, %r14d
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x30(%rax)
jle 0xe780
movq 0x18(%rsp), %rax
leaq 0x30(%rax), %rbx
leaq 0x50(%rax), %r13
xorl %r15d, %r15d
incl %r15d
movq %rbx, %rdi
movl %r15d, %esi
callq 0x911c
movq %rax, %rbp
cmpq %r12, %rax
je 0xe75a
movq %r13, %rdi
movl %r15d, %esi
callq 0x911c
cmpl $0x0, (%rax)
je 0xe77b
xorl %edi, %edi
cmpq %r12, %rbp
sete %dil
leaq 0x18(%rbp), %rsi
addq $0x1c, %rbp
movq %rbp, %rdx
movl %r14d, %ecx
movl 0x14(%rsp), %r8d
callq 0xff3a
cmpl (%rbx), %r15d
jl 0xe734
leaq 0x16fd9(%rip), %rbp     # 0x25760
movq 0x140(%rbp), %rax
testq %rax, %rax
movl 0x14(%rsp), %r13d
movq %r14, %rbx
movq 0x18(%rsp), %r15
je 0xe7cc
movq 0x10(%rax), %rax
cmpq %r15, %rax
jne 0xe7cc
xorl %edi, %edi
cmpq 0x10(%r12), %rax
sete %dil
leaq 0x148(%rbp), %rsi
leaq 0x14c(%rbp), %rdx
movl %ebx, %ecx
movl %r13d, %r8d
callq 0xff3a
movq 0x158(%rbp), %rax
testq %rax, %rax
je 0xe804
movq 0x10(%rax), %rax
cmpq %r15, %rax
jne 0xe804
xorl %edi, %edi
cmpq 0x10(%r12), %rax
sete %dil
leaq 0x160(%rbp), %rsi
leaq 0x164(%rbp), %rdx
movl %ebx, %ecx
movl %r13d, %r8d
callq 0xff3a
cmpl $0x0, 0x16f2d(%rip)     # 0x25738
jle 0xe85e
xorl %ebx, %ebx
leaq 0x16f2a(%rip), %r15     # 0x25740
incl %ebx
movq %r15, %rdi
movl %ebx, %esi
callq 0x911c
movq (%rax), %rcx
testq %rcx, %rcx
je 0xe856
movq 0x10(%rcx), %rcx
cmpq 0x18(%rsp), %rcx
jne 0xe856
xorl %edi, %edi
cmpq 0x10(%r12), %rcx
sete %dil
leaq 0x8(%rax), %rsi
addq $0xc, %rax
movq %rax, %rdx
movl %r14d, %ecx
movl %r13d, %r8d
callq 0xff3a
cmpl 0x16edc(%rip), %ebx     # 0x25738
jl 0xe816
movq 0x18(%rsp), %rcx
movl 0xc0(%rcx), %eax
cmpl $0x5, %eax
jl 0xe954
movl 0xf4(%rcx), %eax
testb $0x10, %al
jne 0xeab5
orl $0x10, %eax
movl %eax, 0xf4(%rcx)
cmpl $0x0, 0x10(%rcx)
movl 0x2c(%rsp), %r15d
jle 0xe901
leaq 0x10(%rcx), %rbx
cvtsi2sdl 0x14(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %r13d, %r13d
incl %r13d
movq %rbx, %rdi
movl %r13d, %esi
callq 0x911c
movq (%rax), %rdi
testq %rdi, %rdi
je 0xe8fc
cmpb $0x2, 0x20(%rdi)
je 0xe8fc
movl 0xc(%rax), %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd 0x38(%rsp), %xmm0
ucomisd 0xd41d(%rip), %xmm0     # 0x1bcf8
ja 0xeac6
movl %edx, %esi
imull %r15d, %esi
addl 0x18(%rdi), %esi
imull 0x14(%rsp), %edx
callq 0xe6e5
testl %eax, %eax
jne 0xeab7
cmpl (%rbx), %r13d
jl 0xe8a7
movq 0x120(%rbp), %rax
testq %rax, %rax
je 0xeab5
movq 0x18(%rsp), %rcx
cmpq %rcx, 0x10(%rax)
jne 0xeab5
xorl %edi, %edi
cmpq %r12, %rax
sete %dil
leaq 0x128(%rbp), %rsi
leaq 0x12c(%rbp), %rdx
movl %r14d, %ecx
movl 0x14(%rsp), %r8d
callq 0xff3a
movq $0x0, 0x108(%rbp)
jmp 0xeab5
testl %r13d, %r13d
movq %r14, %r15
jle 0xe98a
cmpl $0x4, %eax
jne 0xe9ae
leal 0x1(%r15), %esi
movq 0x18(%rsp), %rax
leaq 0x10(%rax), %rdi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x84af
xorl %ecx, %ecx
testl %eax, %eax
setne %al
je 0xe9f4
movb %al, %cl
movl %ecx, %eax
jmp 0xeab7
cmpl $0x4, %eax
jne 0xe9d7
movl %r15d, %ebx
subl %r13d, %ebx
cmpl %r15d, %ebx
jle 0xeab5
movq 0x18(%rsp), %rdi
movl %ebx, %esi
callq 0xf9cd
decl %ebx
jmp 0xe995
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
incl %r15d
movl %r15d, %esi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x84af
testl %eax, %eax
jne 0xeab7
jmp 0xeab5
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leal 0x1(%r15), %esi
subl %r13d, %r15d
movl %r15d, %edx
callq 0x868b
jmp 0xeab5
addl %r15d, %r13d
movl %r13d, %r14d
xorl %ebx, %ebx
leaq 0x40(%rsp), %r12
leaq 0x30(%rsp), %r13
movq %rbx, 0x20(%rsp)
movq %rbx, 0x30(%rsp)
movq %r12, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xf277
testl %eax, %eax
jne 0xea44
movq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x20(%rsp), %rcx
movl $0x1, %r8d
callq 0xd0f1
incl %r15d
testl %eax, %eax
jne 0xea6a
movl $0x1, (%rsp)
movq 0x18(%rsp), %rdi
movl %r15d, %esi
xorl %edx, %edx
movq %r13, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xefa3
movl %eax, %ecx
testl %eax, %eax
jne 0xeaa2
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %rdx
movq %rcx, (%rdx)
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
je 0xeaa0
movq 0x8(%rcx), %rdx
movl (%rdx), %esi
leal 0x1(%rsi), %edi
movl %edi, (%rdx)
testl %esi, %esi
jne 0xeaa0
movq 0x10(%rcx), %rcx
movq 0x8(%rcx), %rcx
incl (%rcx)
movl %ebp, %ecx
testl %eax, %eax
jne 0xe983
movl %ecx, %ebp
cmpl %r14d, %r15d
jl 0xea06
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %eax
jmp 0xeab7