// File: /workspace/github_cpp_makefile_star2_O2/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), %ecx
testq %rcx, %rcx
je 0x2f15
movq %rdi, %r14
movq %rsi, 0x50(%rsp)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r15
andq $0x0, 0x10(%r15)
movaps %xmm0, (%r15)
movq 0x8(%rdi), %rax
subq (%rdi), %rax
pushq $0xc
popq %r13
cqto
idivq %r13
movq %rax, %rbx
xorl %eax, %eax
cmpq %rcx, %rbx
cmovbel %eax, %ecx
subl %ecx, %ebx
callq 0x2828
movl %eax, %r12d
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa06c
pushq $0x18
popq %rdi
callq 0x2190
movq %rax, %r15
movl %r12d, %esi
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %rax, %rdi
callq 0xa11c
pushq $0x38
popq %rdi
callq 0x2190
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rax)
movq %rax, %rcx
addq $0x30, %rcx
movq %rcx, (%rax)
movq $0x1, 0x8(%rax)
movups %xmm0, 0x10(%rax)
movl $0x3f800000, 0x20(%rax) # imm = 0x3F800000
movq %rax, 0x20(%rsp)
movups %xmm0, 0x28(%rax)
pushq $0x18
popq %rdi
callq 0x2190
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %rax, %rdi
movq %rbx, %rsi
movq %rax, 0x18(%rsp)
callq 0xa11c
leaq 0x20(%r14), %rax
movq %rax, 0x58(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %r15, 0x28(%rsp)
movl %r12d, %esi
movq (%r14), %rcx
movq 0x8(%r14), %rax
subq %rcx, %rax
cqto
idivq %r13
cmpq %rsi, %rax
jbe 0x2e90
imulq $0xc, %rsi, %rbp
cmpb $0x0, 0x8(%rcx,%rbp)
jne 0x2e88
cmpb $0x1, 0x3c(%r14)
movl %r12d, %edi
jne 0x2d4e
movq 0x48(%r14), %rdx
movq (%rdx), %rdx
movl (%rdx,%rsi,4), %edi
leaq (%rcx,%rbp), %rdx
movl %edi, 0x4(%rsp)
cmpl $0x0, 0x4(%rdx)
je 0x2d7e
decq %rax
cmpq %rsi, %rax
movl %ebx, 0x14(%rsp)
movq %r12, 0x60(%rsp)
jne 0x2d92
movq 0x18(%r14), %rsi
movq 0x8(%rsi), %rax
subq (%rsi), %rax
shrq $0x2, %rax
jmp 0x2d9e
movq 0x58(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0xa1ac
jmp 0x2e88
leal 0x1(%r12), %eax
imulq $0xc, %rax, %rax
movl (%rcx,%rax), %eax
movl (%rdx), %ebx
movl %eax, %r15d
leaq (,%rbx,4), %r13
decq %rbx
xorl %r12d, %r12d
incq %rbx
cmpq %r15, %rbx
jae 0x2e14
cmpb $0x0, 0x3c(%r14)
je 0x2dd8
movq 0x18(%r14), %rax
movq 0x40(%r14), %rdi
movq (%rax), %rsi
addq %r13, %rsi
callq 0xb880
movq (%r14), %rcx
jmp 0x2de2
movq 0x18(%r14), %rax
movq (%rax), %rax
addq %r13, %rax
movl (%rax), %eax
imulq $0xc, %rax, %rax
cmpb $0x0, 0x8(%rcx,%rax)
jne 0x2e09
movq 0x18(%r14), %rax
movq (%rax), %rsi
addq %r13, %rsi
movq 0x28(%rsp), %rdi
callq 0xa1ac
incl %r12d
movq (%r14), %rcx
addq $0x4, %r13
cmpl 0x4(%rcx,%rbp), %r12d
jne 0x2db1
testl %r12d, %r12d
je 0x2f24
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
cqto
pushq $0xc
popq %r13
idivq %r13
movl 0x4(%rsp), %ecx
movl %ecx, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xbfd8
movq 0x28(%rsp), %r15
movl 0x14(%rsp), %ebx
movq 0x18(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0xa1ac
movl %ebx, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
movb $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xc224
addl %r12d, %ebx
movq 0x60(%rsp), %r12
incl %r12d
jmp 0x2d10
movb $0x1, 0x3c(%r14)
movq 0x40(%r14), %rbx
testq %rbx, %rbx
je 0x2eae
movq %rbx, %rdi
callq 0xac1a
movq %rbx, %rdi
callq 0x2160
movq 0x48(%r14), %rbx
testq %rbx, %rbx
je 0x2ec7
movq %rbx, %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x2160
movq 0x20(%rsp), %rax
movq %rax, 0x40(%r14)
movq 0x18(%rsp), %rax
movq %rax, 0x48(%r14)
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x9b18
movq 0x18(%r14), %rbx
testq %rbx, %rbx
je 0x2ef7
movq %rbx, %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x2160
movq %r15, 0x18(%r14)
movq 0x50(%rsp), %rax
andl $0x0, (%rax)
leaq 0x30(%rsp), %rdi
callq 0xb864
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14111(%rip), %rdi     # 0x1703c
leaq 0x14114(%rip), %rsi     # 0x17046
leaq 0x1411b(%rip), %rcx     # 0x17054
movl $0xc3, %edx
callq 0x2100
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
jmp 0x2f55
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xb864
movq %rbx, %rdi
callq 0x22c0