// File: /workspace/github_cpp_makefile_star2_O3/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 0x10(%rdi), %rcx
movq (%rdi), %r14
movq 0x8(%rdi), %rax
subq %r14, %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
movq %rax, %rdx
subq %r14, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %r12
addl %r12d, %ebp
movl %ebp, %edx
subl %ecx, %edx
jbe 0x56e75
movq %rdi, %rbx
cmpl $0x65, %edx
movl $0x64, %r13d
cmovael %edx, %r13d
addl %ecx, %r13d
leaq (,%r13,8), %rax
leaq (%rax,%rax,2), %rdi
callq 0x3f060
movq %rax, %r15
testl %r12d, %r12d
je 0x56dce
movl %r12d, %eax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movq 0x10(%r14,%rcx), %rdx
movq %rdx, 0x10(%r15,%rcx)
movups (%r14,%rcx), %xmm0
movups %xmm0, (%r15,%rcx)
addq $0x18, %rcx
cmpq %rcx, %rax
jne 0x56db1
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
subq %rax, %rcx
je 0x56e19
sarq $0x5, %rcx
addq $0x10, %rax
movl $0x1, %edx
movq -0x8(%rax), %rsi
testq %rsi, %rsi
je 0x56dfb
subq %r14, %rsi
addq %r15, %rsi
movq %rsi, -0x8(%rax)
movq (%rax), %rsi
testq %rsi, %rsi
je 0x56e0c
subq %r14, %rsi
addq %r15, %rsi
movq %rsi, (%rax)
movl %edx, %esi
addq $0x20, %rax
incl %edx
cmpq %rsi, %rcx
ja 0x56de8
leaq 0x30(%rbx), %rax
movq 0x30(%rbx), %rcx
cmpq %rax, %rcx
je 0x56e3f
movq (%rcx), %rdx
movq 0x10(%rcx), %rsi
subq %r14, %rsi
addq %r15, %rsi
movq %rsi, 0x10(%rcx)
movq %rdx, %rcx
cmpq %rax, %rdx
jne 0x56e26
testq %r14, %r14
je 0x56e4c
movq %r14, %rdi
callq 0x40f10
movq %r15, (%rbx)
movl %ebp, %eax
leaq (%rax,%rax,2), %rax
leaq (%r15,%rax,8), %rax
movq %rax, 0x8(%rbx)
leaq (%r13,%r13,2), %rax
leaq (%r15,%rax,8), %rax
movq %rax, 0x10(%rbx)
movl %r12d, %eax
leaq (%rax,%rax,2), %rax
leaq (%r15,%rax,8), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq