// File: /workspace/github_c_makefile_star2_O2/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 0xdd9b
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r12
movq 0x10(%rdi), %rcx
movl 0x18(%rdi), %eax
movl %edx, %ebp
addl %edx, 0xf0(%rcx)
movl %esi, 0x24(%rsp)
addl %esi, %eax
movq %rax, 0x18(%rsp)
leaq 0x30(%rcx), %rbx
movq %rcx, 0x10(%rsp)
leaq 0x50(%rcx), %r13
pushq $0x1
popq %r14
cmpl (%rbx), %r14d
jg 0xdb39
movq %rbx, %rdi
movl %r14d, %esi
callq 0x9088
movq %rax, %r15
cmpq %r12, %rax
je 0xdb13
movq %r13, %rdi
movl %r14d, %esi
callq 0x9088
cmpl $0x0, (%rax)
je 0xdb34
xorl %edi, %edi
cmpq %r12, %r15
sete %dil
leaq 0x18(%r15), %rsi
addq $0x1c, %r15
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
callq 0xf10b
incl %r14d
jmp 0xdaeb
leaq 0x16c20(%rip), %r15     # 0x24760
movq 0x140(%r15), %rax
testq %rax, %rax
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbx
je 0xdb80
cmpq %rbx, 0x10(%rax)
jne 0xdb80
xorl %edi, %edi
cmpq 0x10(%r12), %rbx
sete %dil
leaq 0x148(%r15), %rsi
leaq 0x14c(%r15), %rdx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0xf10b
movq 0x158(%r15), %rax
testq %rax, %rax
je 0xdbb6
cmpq %rbx, 0x10(%rax)
jne 0xdbb6
xorl %edi, %edi
cmpq 0x10(%r12), %rbx
sete %dil
leaq 0x160(%r15), %rsi
leaq 0x164(%r15), %rdx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0xf10b
pushq $0x1
popq %rbx
leaq 0x16b80(%rip), %r14     # 0x24740
cmpl 0x16b72(%rip), %ebx     # 0x24738
jg 0xdc0f
movq %r14, %rdi
movl %ebx, %esi
callq 0x9088
movq (%rax), %rcx
testq %rcx, %rcx
je 0xdc0b
movq 0x10(%rsp), %rdx
cmpq %rdx, 0x10(%rcx)
jne 0xdc0b
xorl %edi, %edi
movq 0x10(%rsp), %rcx
cmpq 0x10(%r12), %rcx
sete %dil
leaq 0x8(%rax), %rsi
addq $0xc, %rax
movq %rax, %rdx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0xf10b
incl %ebx
jmp 0xdbc0
movq 0x10(%rsp), %r14
movl 0xc0(%r14), %eax
cmpl $0x5, %eax
jl 0xdcaf
movl 0xf4(%r14), %eax
testb $0x10, %al
jne 0xdd8b
orl $0x10, %eax
movl %eax, 0xf4(%r14)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x10(%r14), %rbx
pushq $0x1
popq %r13
pushq $0x20
popq %r14
cmpl (%rbx), %r13d
jg 0xdd13
movq %rbx, %rdi
movl %r13d, %esi
callq 0x9088
movq (%rax), %rdi
testq %rdi, %rdi
je 0xdcaa
cmpb $0x2, 0x20(%rdi)
je 0xdcaa
movl 0xc(%rax), %edx
cvtsi2sd %edx, %xmm0
mulsd 0x38(%rsp), %xmm0
ucomisd 0xc006(%rip), %xmm0     # 0x19c90
ja 0xde27
movl %edx, %esi
imull 0x24(%rsp), %esi
addl 0x18(%rdi), %esi
imull %ebp, %edx
callq 0xdaa5
testl %eax, %eax
jne 0xdd8d
incl %r13d
jmp 0xdc53
testl %ebp, %ebp
jle 0xdce9
cmpl $0x4, %eax
jne 0xdd58
leal 0x1(%r13), %r12d
andl $0x0, (%rsp)
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xe2d6
testl %eax, %eax
je 0xdd9c
pushq $0x1
popq %rax
jmp 0xdd8d
cmpl $0x4, %eax
jne 0xdd75
movl %r13d, %ebx
subl %ebp, %ebx
cmpl %r13d, %ebx
jle 0xdd8b
movq %r14, %rdi
movl %ebx, %esi
callq 0xec0e
decl %ebx
movq 0x18(%rsp), %r13
jmp 0xdcf7
movq 0x120(%r15), %rax
testq %rax, %rax
movq 0x10(%rsp), %rcx
je 0xdd8b
cmpq %rcx, 0x10(%rax)
jne 0xdd8b
xorl %edi, %edi
cmpq %r12, %rax
sete %dil
leaq 0x128(%r15), %rsi
leaq 0x12c(%r15), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
callq 0xf10b
andq $0x0, 0x108(%r15)
jmp 0xdd8b
addq $0x10, %r14
incl %r13d
pushq $0x1
popq %rcx
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x8496
testl %eax, %eax
jne 0xdd8d
jmp 0xdd8b
addq $0x10, %r14
leal 0x1(%r13), %esi
subl %ebp, %r13d
movq %r14, %rdi
movl %r13d, %edx
callq 0x864f
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl %ebp, %r13d
movq %r13, %rbx
leaq 0x40(%rsp), %r15
pushq $0x1
popq %rbp
leaq 0x30(%rsp), %r13
cmpl %ebx, %r12d
jg 0xdd8b
andq $0x0, 0x30(%rsp)
andq $0x0, 0x28(%rsp)
movq %r15, %rdi
movl %ebp, %esi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xe55e
testl %eax, %eax
jne 0xdd8d
movq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
movl %ebp, %r8d
callq 0xc718
testl %eax, %eax
jne 0xdd8d
movl $0x1, (%rsp)
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
leaq 0x28(%rsp), %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xe2d6
testl %eax, %eax
jne 0xde2f
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rdi, (%rax)
callq 0xc7e1
incl %r12d
jmp 0xddaf
movl %r14d, %eax
jmp 0xdd8d
movl %ebp, %eax
jmp 0xdd8d