// File: /workspace/github_c_makefile_star2_O3/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 %ecx, %ecx
testl %edx, %edx
je 0xe874
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r15
movq 0x10(%rdi), %rax
movl 0x18(%rdi), %ebx
movl %edx, 0x14(%rsp)
addl %edx, 0xf0(%rax)
movl %esi, 0x24(%rsp)
addl %esi, %ebx
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x30(%rax)
jle 0xe563
movq 0x18(%rsp), %rax
leaq 0x30(%rax), %r12
leaq 0x50(%rax), %r13
xorl %ebp, %ebp
incl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x91d8
movq %rax, %r14
cmpq %r15, %rax
je 0xe53d
movq %r13, %rdi
movl %ebp, %esi
callq 0x91d8
cmpl $0x0, (%rax)
je 0xe55d
xorl %edi, %edi
cmpq %r15, %r14
sete %dil
leaq 0x18(%r14), %rsi
addq $0x1c, %r14
movq %r14, %rdx
movl %ebx, %ecx
movl 0x14(%rsp), %r8d
callq 0xfce7
cmpl (%r12), %ebp
jl 0xe51a
leaq 0x171f6(%rip), %r14     # 0x25760
movq 0x140(%r14), %rax
testq %rax, %rax
movl 0x14(%rsp), %r13d
movq 0x18(%rsp), %r12
je 0xe5a8
cmpq %r12, 0x10(%rax)
jne 0xe5a8
xorl %edi, %edi
cmpq 0x10(%r15), %r12
sete %dil
leaq 0x148(%r14), %rsi
leaq 0x14c(%r14), %rdx
movl %ebx, %ecx
movl %r13d, %r8d
callq 0xfce7
movq 0x158(%r14), %rax
testq %rax, %rax
je 0xe5dc
cmpq %r12, 0x10(%rax)
jne 0xe5dc
xorl %edi, %edi
cmpq 0x10(%r15), %r12
sete %dil
leaq 0x160(%r14), %rsi
leaq 0x164(%r14), %rdx
movl %ebx, %ecx
movl %r13d, %r8d
callq 0xfce7
cmpl $0x0, 0x17155(%rip)     # 0x25738
jle 0xe639
xorl %ebp, %ebp
leaq 0x17152(%rip), %r12     # 0x25740
incl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x91d8
movq (%rax), %rcx
testq %rcx, %rcx
je 0xe631
movq 0x18(%rsp), %rdx
cmpq %rdx, 0x10(%rcx)
jne 0xe631
xorl %edi, %edi
movq 0x18(%rsp), %rcx
cmpq 0x10(%r15), %rcx
sete %dil
leaq 0x8(%rax), %rsi
addq $0xc, %rax
movq %rax, %rdx
movl %ebx, %ecx
movl %r13d, %r8d
callq 0xfce7
cmpl 0x17101(%rip), %ebp     # 0x25738
jl 0xe5ee
movq 0x18(%rsp), %rbp
movl 0xc0(%rbp), %eax
cmpl $0x5, %eax
jl 0xe726
movl 0xf4(%rbp), %eax
testb $0x10, %al
jne 0xe864
orl $0x10, %eax
movl %eax, 0xf4(%rbp)
cmpl $0x0, 0x10(%rbp)
jle 0xe6d9
leaq 0x10(%rbp), %r12
cvtsi2sdl 0x14(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %r13d, %r13d
incl %r13d
movq %r12, %rdi
movl %r13d, %esi
callq 0x91d8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xe6d3
cmpb $0x2, 0x20(%rdi)
je 0xe6d3
movl 0xc(%rax), %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd 0x38(%rsp), %xmm0
ucomisd 0xd61f(%rip), %xmm0     # 0x1bcd0
ja 0xe877
movl %edx, %esi
imull 0x24(%rsp), %esi
addl 0x18(%rdi), %esi
imull 0x14(%rsp), %edx
callq 0xe4ce
testl %eax, %eax
jne 0xe84c
cmpl (%r12), %r13d
jl 0xe67d
movq 0x120(%r14), %rax
testq %rax, %rax
movl 0x14(%rsp), %r8d
je 0xe864
cmpq %rbp, 0x10(%rax)
jne 0xe864
xorl %edi, %edi
cmpq %r15, %rax
sete %dil
leaq 0x128(%r14), %rsi
leaq 0x12c(%r14), %rdx
movl %ebx, %ecx
callq 0xfce7
movq $0x0, 0x108(%r14)
jmp 0xe864
testl %r13d, %r13d
jle 0xe811
cmpl $0x4, %eax
jne 0xe830
leal 0x1(%rbx), %esi
leaq 0x10(%rbp), %rdi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x84af
movl $0x1, %ecx
testl %eax, %eax
jne 0xe866
addl %ebx, %r13d
xorl %r14d, %r14d
leaq 0x40(%rsp), %r15
leaq 0x30(%rsp), %r12
leaq 0x28(%rsp), %rbp
movq %r14, 0x30(%rsp)
movq %r14, 0x28(%rsp)
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xf037
testl %eax, %eax
jne 0xe84c
movq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r12, %rcx
movl $0x1, %r8d
callq 0xceef
testl %eax, %eax
jne 0xe84c
incl %ebx
movl $0x1, (%rsp)
movq 0x18(%rsp), %rdi
movl %ebx, %esi
xorl %edx, %edx
movq %rbp, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xed61
testl %eax, %eax
jne 0xe87e
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xe806
movq 0x8(%rax), %rcx
movl (%rcx), %edx
leal 0x1(%rdx), %esi
movl %esi, (%rcx)
testl %edx, %edx
jne 0xe806
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
incl (%rax)
cmpl %r13d, %ebx
jl 0xe76b
jmp 0xe864
cmpl $0x4, %eax
jne 0xe850
movq %rbp, %r14
movl %ebx, %ebp
subl %r13d, %ebp
cmpl %ebx, %ebp
jle 0xe864
movq %r14, %rdi
movl %ebp, %esi
callq 0xf789
decl %ebp
jmp 0xe81e
addq $0x10, %rbp
incl %ebx
movq %rbp, %rdi
movl %ebx, %esi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x84af
testl %eax, %eax
je 0xe864
movl %eax, %ecx
jmp 0xe866
addq $0x10, %rbp
leal 0x1(%rbx), %esi
subl %r13d, %ebx
movq %rbp, %rdi
movl %ebx, %edx
callq 0x868b
xorl %ecx, %ecx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movl %ecx, %eax
retq
movl $0x20, %ecx
jmp 0xe866
movl $0x1, %ecx
jmp 0xe866