// File: /workspace/github_cpp_makefile_star2_O3/iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::rebuildFromNodes(std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&)
void Graph::rebuildFromNodes(unordered_set<uint32_t> &nodes) {
    zeroDegreeNodes.clear();
    if (!nodes.size()) {
        nodeIndex.clear();
        edgeBuffer->clear();
        if (mapping) {
            idToPos->clear();
            posToId->clear();
        }
        return;
    }
    vector<NodeInfo> nodeIndex;
    nodeIndex.reserve(nodes.size());
    vector<uint32_t> *edgeBuffer = new vector<uint32_t>();
    unordered_map<uint32_t, uint32_t> *idToPos = new unordered_map<uint32_t, uint32_t>();
    vector<uint32_t> *posToId = new vector<uint32_t>();
    posToId->reserve(nodes.size());
    uint32_t offset = 0;

    for (auto node: nodes) {
        uint32_t edges = 0;
        uint32_t pos = (!mapping ? node : this->idToPos->at(node));
        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 or are outside of nodes struct */
        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 || nodes.find((*this->edgeBuffer)[i]) != nodes.end()) {
                edgeBuffer->push_back((*this->edgeBuffer)[i]);
                edges++;
            }
            if (edges == this->nodeIndex[pos].edges) {
                break;
            }
        }
        if (!edges) {
            zeroDegreeNodes.push_back(node);
        } else {
            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;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x20(%rdi), %rax
cmpq %rax, 0x28(%rdi)
je 0x348e
movq %rax, 0x28(%rbx)
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0x3810
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0xbce0
movl $0x18, %edi
callq 0x21e0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x28(%rsp)
movq $0x0, 0x10(%rax)
movl $0x38, %edi
callq 0x21e0
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, 0x48(%rsp)
movups %xmm0, 0x28(%rax)
movl $0x18, %edi
callq 0x21e0
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x18(%r14), %rsi
movq %rax, %rdi
callq 0xbd9c
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x3783
leaq 0x20(%rbx), %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0x10(%rsp)
movq %r14, 0x60(%rsp)
movq %rbp, 0x58(%rsp)
movl 0x8(%r15), %eax
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x3c(%rbx)
jne 0x357e
movq 0x40(%rbx), %rdi
leaq 0xc(%rsp), %rsi
callq 0xd37a
testq %rax, %rax
je 0x3869
movl 0xc(%rax), %eax
movl %eax, %eax
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
decq %rdx
cmpq %rax, %rdx
movq %r15, 0x20(%rsp)
jne 0x35ba
movq 0x18(%rbx), %rsi
movq 0x8(%rsi), %rdx
subq (%rsi), %rdx
shrq $0x2, %rdx
jmp 0x35c4
leal 0x1(%rax), %edx
leaq (%rdx,%rdx,2), %rdx
movl (%rcx,%rdx,4), %edx
leaq (%rax,%rax,2), %r13
movl (%rcx,%r13,4), %r15d
cmpl %edx, %r15d
jae 0x36ec
movl %edx, %ebp
leaq (,%r15,4), %r14
incq %r15
xorl %r12d, %r12d
cmpb $0x0, 0x3c(%rbx)
je 0x3614
movq 0x18(%rbx), %rax
movq 0x40(%rbx), %rdi
movq (%rax), %rsi
addq %r14, %rsi
callq 0xd37a
testq %rax, %rax
je 0x385d
addq $0xc, %rax
movq (%rbx), %rcx
movq 0x18(%rbx), %rdx
jmp 0x361e
movq 0x18(%rbx), %rdx
movq (%rdx), %rax
addq %r14, %rax
movl (%rax), %eax
leaq (%rax,%rax,2), %rax
cmpb $0x1, 0x8(%rcx,%rax,4)
jne 0x364b
movq (%rdx), %rsi
addq %r14, %rsi
movq 0x60(%rsp), %rdi
callq 0xdcaa
testq %rax, %rax
movq 0x28(%rsp), %rdi
je 0x3676
movq 0x18(%rbx), %rdx
jmp 0x3650
movq 0x28(%rsp), %rdi
movq (%rdx), %rdx
addq %r14, %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x366e
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x3673
callq 0xd7b4
incl %r12d
movq (%rbx), %rcx
cmpl 0x4(%rcx,%r13,4), %r12d
je 0x3694
addq $0x4, %r14
leaq 0x1(%r15), %rax
cmpq %rbp, %r15
movq %rax, %r15
jb 0x35e5
testl %r12d, %r12d
movq 0x58(%rsp), %rbp
je 0x36ec
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl 0xc(%rsp), %ecx
movl %ecx, 0x14(%rsp)
movl %eax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0xd8cc
movq 0x8(%rbp), %rsi
cmpq 0x10(%rbp), %rsi
movq 0x20(%rsp), %r15
je 0x3721
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbp)
jmp 0x372e
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x370b
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rbx)
movq 0x20(%rsp), %r15
jmp 0x3777
movq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xd7b4
movq 0x20(%rsp), %r15
jmp 0x3777
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 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x3763
movl 0x1c(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x14(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x38(%rsp)
jmp 0x3772
leaq 0x30(%rsp), %rdi
leaq 0x14(%rsp), %rdx
callq 0xdb48
addl %r12d, 0x10(%rsp)
movq (%r15), %r15
testq %r15, %r15
jne 0x3556
movb $0x1, 0x3c(%rbx)
movq 0x40(%rbx), %r15
testq %r15, %r15
je 0x37a0
movq %r15, %rdi
callq 0xc81c
movq %r15, %rdi
callq 0x21a0
movq 0x48(%rbx), %r15
testq %r15, %r15
movq 0x48(%rsp), %r14
je 0x37c3
movq (%r15), %rdi
testq %rdi, %rdi
je 0x37bb
callq 0x21a0
movq %r15, %rdi
callq 0x21a0
movq %r14, 0x40(%rbx)
movq %rbp, 0x48(%rbx)
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0xb6ec
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0x37ee
movq (%r15), %rdi
testq %rdi, %rdi
je 0x37ee
callq 0x21a0
movq %r15, %rdi
callq 0x21a0
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rbx)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x384e
callq 0x21a0
jmp 0x384e
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x381d
movq %rax, 0x8(%rbx)
movq 0x18(%rbx), %rax
movq (%rax), %rcx
cmpq %rcx, 0x8(%rax)
je 0x382e
movq %rcx, 0x8(%rax)
cmpb $0x1, 0x3c(%rbx)
jne 0x384e
movq 0x40(%rbx), %rdi
callq 0xc7bc
movq 0x48(%rbx), %rax
movq (%rax), %rcx
cmpq %rcx, 0x8(%rax)
je 0x384e
movq %rcx, 0x8(%rax)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15f6c(%rip), %rdi     # 0x197d0
callq 0x2280
leaq 0x15f60(%rip), %rdi     # 0x197d0
callq 0x2280
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
jmp 0x388d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x389f
callq 0x21a0
movq %rbx, %rdi
callq 0x2320
nop