// File: /workspace/github_cpp_makefile_star2_O2/jstaursky[P]hutch/src/Sleigh/sleigh.cc
// Function: PcodeCacher::expandPool(unsigned int)
VarnodeData* PcodeCacher::expandPool (uint4 size)

{ // Expand the pool so that -size- more elements fit
    // Return pointer to first available element
    uint4 curmax = endpool - poolstart;
    uint4 cursize = curpool - poolstart;
    if (cursize + size <= curmax)
        return curpool; // No expansion necessary
    uint4 increase = (cursize + size) - curmax;
    if (increase < 100) // Increase by at least 100
        increase = 100;

    uint4 newsize = curmax + increase;

    VarnodeData* newpool = new VarnodeData[newsize];
    for (uint4 i = 0; i < cursize; ++i)
        newpool[i] = poolstart[i]; // Copy old data
    // Update references to the old pool
    for (uint4 i = 0; i < issued.size (); ++i) {
        VarnodeData* outvar = issued[i].outvar;
        if (outvar != (VarnodeData*)0) {
            outvar = newpool + (outvar - poolstart);
            issued[i].outvar = outvar;
        }
        VarnodeData* invar = issued[i].invar;
        if (invar != (VarnodeData*)0) {
            invar = newpool + (invar - poolstart);
            issued[i].invar = invar;
        }
    }
    list<RelativeRecord>::iterator iter;
    for (iter = label_refs.begin (); iter != label_refs.end (); ++iter) {
        VarnodeData* ref = (*iter).dataptr;
        (*iter).dataptr = newpool + (ref - poolstart);
    }

    delete[] poolstart; // Free up old pool
    poolstart = newpool;
    curpool = newpool + (cursize + size);
    endpool = newpool + newsize;
    return newpool + cursize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq (%rdi), %r14
movq 0x8(%rdi), %rcx
subq %r14, %rax
pushq $0x18
popq %rdi
cqto
idivq %rdi
movq %rax, %rsi
movq %rcx, %rax
subq %r14, %rax
cqto
idivq %rdi
movq %rax, %r15
addl %r15d, %ebp
movl %ebp, %eax
subl %esi, %eax
jbe 0x6327f
cmpl $0x65, %eax
pushq $0x64
popq %rcx
cmovael %eax, %ecx
addl %esi, %ecx
imulq $0x18, %rcx, %r13
movq %r13, %rdi
callq 0x4d060
movq %rax, %r12
movl %r15d, %eax
imulq $0x18, %rax, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x631e4
movq 0x10(%r14,%rcx), %rdx
movq %rdx, 0x10(%r12,%rcx)
movups (%r14,%rcx), %xmm0
movups %xmm0, (%r12,%rcx)
addq $0x18, %rcx
jmp 0x631c5
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rcx
jbe 0x63232
movq %rdx, %rdi
shlq $0x5, %rdi
leaq (%rax,%rdi), %rsi
movq 0x8(%rax,%rdi), %rdi
testq %rdi, %rdi
je 0x6321b
subq %r14, %rdi
addq %r12, %rdi
movq %rdi, 0x8(%rsi)
movq 0x10(%rsi), %rdi
testq %rdi, %rdi
je 0x6322e
subq %r14, %rdi
addq %r12, %rdi
movq %rdi, 0x10(%rsi)
incl %edx
jmp 0x631f5
leaq 0x30(%rbx), %rax
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0x63251
movq 0x10(%rcx), %rdx
subq %r14, %rdx
addq %r12, %rdx
movq %rdx, 0x10(%rcx)
jmp 0x63239
testq %r14, %r14
je 0x6325e
movq %r14, %rdi
callq 0x50170
movq %r12, (%rbx)
movl %ebp, %eax
imulq $0x18, %rax, %rax
addq %r12, %rax
movq %rax, 0x8(%rbx)
addq %r12, %r13
movq %r13, 0x10(%rbx)
movl %r15d, %eax
imulq $0x18, %rax, %rcx
addq %r12, %rcx
movq %rcx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop