// File: /workspace/github_cpp_makefile_star2_O3/iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::rebuild(ReduceInfo&)
void Graph::rebuild(ReduceInfo &reduceInfo) {
    if (!reduceInfo.nodesRemoved) {
        return;
    }
    vector<NodeInfo> nodeIndex;
    uint32_t newNodes = (this->nodeIndex.size() > reduceInfo.nodesRemoved ? this->nodeIndex.size() - reduceInfo.nodesRemoved : this->nodeIndex.size());
    uint32_t newEdges = this->getTotalEdges();
    nodeIndex.reserve(newNodes);
    vector<uint32_t> *edgeBuffer = new vector<uint32_t>();
    edgeBuffer->reserve(newEdges);
    unordered_map<uint32_t, uint32_t> *idToPos = new unordered_map<uint32_t, uint32_t>();
    vector<uint32_t> *posToId = new vector<uint32_t>();
    posToId->reserve(newNodes);
    uint32_t offset = 0;

    for (uint32_t pos = 0 ; pos < this->nodeIndex.size() ; pos++) {
        if (this->nodeIndex[pos].removed) {
            continue;
        }
        uint32_t node = (!mapping ? pos : (*this->posToId)[pos]);
        if (!this->nodeIndex[pos].edges) {
            //cout << "Found node " << node << " with no edges at rebuilding\n";
            zeroDegreeNodes.push_back(node);
            continue;
        }
        uint32_t edges = 0;
        uint32_t nextNodeOffset = (pos == this->nodeIndex.size()-1 ? this->edgeBuffer->size() : this->nodeIndex[pos+1].offset);
        /* Don't add neighbors that are marked as removed */
        for (uint32_t i = this->nodeIndex[pos].offset ; i < nextNodeOffset ; i++) {
            uint32_t nPos = (!this->mapping ? (*this->edgeBuffer)[i] : this->idToPos->at((*this->edgeBuffer)[i]));
            if (!this->nodeIndex[nPos].removed) {
                edgeBuffer->push_back((*this->edgeBuffer)[i]);
                edges++;
            }
            if (edges == this->nodeIndex[pos].edges) {
                break;
            }
        }
        assert(edges > 0);
        idToPos->insert({node, nodeIndex.size()});
        posToId->push_back(node);
        nodeIndex.push_back(Graph::NodeInfo(offset, edges));
        offset += edges;
    }
    this->mapping = true;
    if (this->idToPos != NULL) {
        delete this->idToPos;
    }
    if (this->posToId != NULL) {
        delete this->posToId;
    }
    this->idToPos = idToPos;
    this->posToId = posToId;
    this->nodeIndex = nodeIndex;
    delete this->edgeBuffer;
    this->edgeBuffer = edgeBuffer;
    reduceInfo.nodesRemoved = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl (%rsi), %r8d
testq %r8, %r8
je 0x3404
movq %rdi, %r14
movq %rsi, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorl %r12d, %r12d
movq %r12, 0x30(%rsp)
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
movq %rdi, %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r15, %rcx
cmpq %r8, %rcx
cmovbeq %r12, %r8
movq %rcx, %rdx
subq %r8, %rdx
cmpq %rax, %rdi
je 0x3083
addq $0x8, %rax
movl $0x1, %esi
cmpb $0x0, (%rax)
jne 0x3073
addl -0x4(%rax), %r12d
movl %esi, %edi
addq $0xc, %rax
incl %esi
cmpq %rdi, %rcx
ja 0x306a
movl %r12d, %r12d
movl %edx, %ebp
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0xbce0
movl $0x18, %edi
callq 0x21e0
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0xbd9c
movq %rbx, 0x38(%rsp)
movl $0x38, %edi
callq 0x21e0
movq %rax, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rax)
addq $0x30, %rax
movq %rax, (%r13)
movq $0x1, 0x8(%r13)
movups %xmm0, 0x10(%r13)
movl $0x3f800000, 0x20(%r13) # imm = 0x3F800000
movups %xmm0, 0x28(%r13)
movl $0x18, %edi
callq 0x21e0
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, %rdi
movq %rbp, %rsi
callq 0xbd9c
movq (%r14), %rcx
movq 0x8(%r14), %rdx
movq %rdx, %rax
subq %rcx, %rax
movq %rbx, %rbp
je 0x336d
sarq $0x2, %rax
imulq %r15, %rax
leaq 0x20(%r14), %rsi
movq %rsi, 0x48(%rsp)
xorl %r12d, %r12d
movl $0x0, 0x10(%rsp)
movq %r13, 0x58(%rsp)
movq %rbp, 0x50(%rsp)
leaq (%r12,%r12,2), %rbx
cmpb $0x0, 0x8(%rcx,%rbx,4)
jne 0x3340
cmpb $0x1, 0x3c(%r14)
movl %r12d, %edi
jne 0x3179
movq 0x48(%r14), %rdx
movq (%rdx), %rdx
movl (%rdx,%r12,4), %edi
leaq (%rcx,%rbx,4), %rdx
movl %edi, 0xc(%rsp)
cmpl $0x0, 0x4(%rdx)
je 0x31a5
decq %rax
cmpq %r12, %rax
movq %r12, 0x60(%rsp)
jne 0x31c2
movq 0x18(%r14), %rsi
movq 0x8(%rsi), %rax
subq (%rsi), %rax
shrq $0x2, %rax
jmp 0x31ce
movq 0x28(%r14), %rsi
cmpq 0x30(%r14), %rsi
je 0x335c
movl %edi, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%r14)
jmp 0x3339
leal 0x1(%r12), %eax
leaq (%rax,%rax,2), %rax
movl (%rcx,%rax,4), %eax
movl (%rdx), %r13d
cmpl %eax, %r13d
jae 0x341f
movl %eax, %ebp
leaq (,%r13,4), %r15
incq %r13
xorl %r12d, %r12d
cmpb $0x0, 0x3c(%r14)
je 0x3216
movq 0x18(%r14), %rax
movq 0x40(%r14), %rdi
movq (%rax), %rsi
addq %r15, %rsi
callq 0xd37a
testq %rax, %rax
je 0x3413
addq $0xc, %rax
movq (%r14), %rcx
jmp 0x3220
movq 0x18(%r14), %rax
movq (%rax), %rax
addq %r15, %rax
movl (%rax), %eax
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0x8(%rcx,%rax,4)
jne 0x325f
movq 0x18(%r14), %rax
movq (%rax), %rdx
addq %r15, %rdx
movq 0x38(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3254
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x325c
callq 0xd7b4
movq (%r14), %rcx
incl %r12d
cmpl 0x4(%rcx,%rbx,4), %r12d
je 0x327a
addq $0x4, %r15
leaq 0x1(%r13), %rax
cmpq %rbp, %r13
movq %rax, %r13
jb 0x31ea
testl %r12d, %r12d
je 0x341f
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl 0xc(%rsp), %ecx
movl %ecx, 0x14(%rsp)
movl %eax, 0x18(%rsp)
movq 0x58(%rsp), %r13
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
callq 0xd8cc
movq 0x50(%rsp), %rbp
movq 0x8(%rbp), %rsi
cmpq 0x10(%rbp), %rsi
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
je 0x32de
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbp)
jmp 0x32eb
movq %rbp, %rdi
leaq 0xc(%rsp), %rdx
callq 0xd7b4
movl 0x10(%rsp), %eax
movl %eax, 0x14(%rsp)
movl %r12d, 0x18(%rsp)
movb $0x0, 0x1c(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x3320
movl 0x1c(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x14(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x28(%rsp)
jmp 0x332f
leaq 0x20(%rsp), %rdi
leaq 0x14(%rsp), %rdx
callq 0xdb48
addl %r12d, 0x10(%rsp)
movq 0x60(%rsp), %r12
movq (%r14), %rcx
movq 0x8(%r14), %rdx
incl %r12d
movq %rdx, %rax
subq %rcx, %rax
sarq $0x2, %rax
imulq %r15, %rax
cmpq %r12, %rax
ja 0x3155
jmp 0x336d
movq 0x48(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xd7b4
jmp 0x3339
movq %rbp, %rbx
movb $0x1, 0x3c(%r14)
movq 0x40(%r14), %rbp
testq %rbp, %rbp
je 0x338e
movq %rbp, %rdi
callq 0xc81c
movq %rbp, %rdi
callq 0x21a0
movq 0x48(%r14), %rbp
testq %rbp, %rbp
je 0x33ad
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x33a5
callq 0x21a0
movq %rbp, %rdi
callq 0x21a0
movq %r13, 0x40(%r14)
movq %rbx, 0x48(%r14)
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0xb6ec
movq 0x18(%r14), %r12
testq %r12, %r12
movq 0x38(%rsp), %rbx
je 0x33de
movq (%r12), %rdi
testq %rdi, %rdi
je 0x33de
callq 0x21a0
movq %r12, %rdi
callq 0x21a0
movq %rbx, 0x18(%r14)
movq 0x40(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3404
callq 0x21a0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x163b6(%rip), %rdi     # 0x197d0
callq 0x2280
leaq 0x15c12(%rip), %rdi     # 0x19038
leaq 0x15c15(%rip), %rsi     # 0x19042
leaq 0x15c1c(%rip), %rcx     # 0x19050
movl $0xc3, %edx
callq 0x2110
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
jmp 0x3452
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3464
callq 0x21a0
movq %rbx, %rdi
callq 0x2320