// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::addEdges(unsigned int, std::vector<unsigned int, std::allocator<unsigned int>> const&)
void Graph::addEdges(const uint32_t node, const vector<uint32_t> &nodes) {
    uint32_t pos = (!mapping ? node : idToPos->at(node));
    set<uint32_t> neighbors;
    vector<uint32_t> removedNeighbors;
    gatherNeighborsWithRemoved(node, neighbors, removedNeighbors);
    uint32_t space = neighbors.size() + removedNeighbors.size();
    neighbors.insert(nodes.begin(), nodes.end());
    uint32_t finalNeighborCount = neighbors.size();
    if (neighbors.size() <= space) {
        while (neighbors.size() < space) {
            uint32_t removed = removedNeighbors.back();
            removedNeighbors.pop_back();
            neighbors.insert(removed);
        }
        copy(neighbors.begin(), neighbors.end(), edgeBuffer->begin() + nodeIndex[pos].offset);
    } else {
        auto it = neighbors.begin();
        uint32_t insertedElements = 0;
        uint32_t nextNodeOffset = (pos == nodeIndex.size()-1 ? edgeBuffer->size() : nodeIndex[pos+1].offset);
        for (uint32_t offset = nodeIndex[pos].offset ; offset < nextNodeOffset ; offset++) {
            (*edgeBuffer)[offset] = *it;
            it++;
            insertedElements++;
        }
        uint32_t addition = (neighbors.size() - insertedElements);
        edgeBuffer->reserve(edgeBuffer->size() + addition);
        edgeBuffer->insert(edgeBuffer->begin() + nextNodeOffset, it, neighbors.end());
        for (uint32_t i = pos + 1 ; i < nodeIndex.size() ; i++) {
            nodeIndex[i].offset += addition;
        }
    }
    nodeIndex[pos].edges = finalNeighborCount;
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1c0(%rsp)
movl %esi, 0x1bc(%rsp)
movq %rdx, 0x1b0(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x98(%rsp)
testb $0x1, 0x3c(%rax)
jne 0x9884
movl 0x1bc(%rsp), %eax
movl %eax, 0x94(%rsp)
jmp 0x98a6
movq 0x98(%rsp), %rax
movq 0x40(%rax), %rdi
leaq 0x1bc(%rsp), %rsi
callq 0x188b0
movl (%rax), %eax
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x1ac(%rsp)
leaq 0x178(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x193a0
leaq 0x160(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x17e60
movq 0x98(%rsp), %rdi
movq 0x80(%rsp), %rdx
movq 0x88(%rsp), %rcx
leaq 0x1bc(%rsp), %rsi
callq 0x1aaa0
jmp 0x9905
leaq 0x178(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x19770
movq %rax, 0x70(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x188e0
movq %rax, %rcx
movq 0x70(%rsp), %rax
addl %ecx, %eax
movl %eax, 0x150(%rsp)
movq 0x1b0(%rsp), %rdi
callq 0x193b0
movq %rax, 0x148(%rsp)
movq 0x1b0(%rsp), %rdi
callq 0x19420
movq 0x78(%rsp), %rdi
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rsi
movq 0x140(%rsp), %rdx
callq 0x1acc0
jmp 0x9980
leaq 0x178(%rsp), %rdi
callq 0x19770
movl %eax, 0x13c(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x19770
movl 0x150(%rsp), %ecx
cmpq %rcx, %rax
ja 0x9b0f
jmp 0x99b3
leaq 0x178(%rsp), %rdi
callq 0x19770
movl 0x150(%rsp), %ecx
cmpq %rcx, %rax
jae 0x9a62
leaq 0x160(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x1ad00
movq 0x58(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x138(%rsp)
callq 0x1ad40
leaq 0x178(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x19500
movb %dl, 0x67(%rsp)
movq %rax, 0x68(%rsp)
jmp 0x9a15
movb 0x67(%rsp), %al
movq 0x68(%rsp), %rcx
movq %rcx, 0x128(%rsp)
movb %al, 0x130(%rsp)
jmp 0x99b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x18520
leaq 0x178(%rsp), %rdi
callq 0x19880
jmp 0x9dfc
leaq 0x178(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x197f0
movq 0x48(%rsp), %rdi
movq %rax, 0x120(%rsp)
callq 0x19820
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x118(%rsp)
movq 0x18(%rax), %rdi
callq 0x19b50
movq 0x98(%rsp), %rdi
movq %rax, 0x108(%rsp)
movl 0x1ac(%rsp), %eax
movl %eax, %esi
callq 0x19050
movl (%rax), %eax
movl %eax, %esi
leaq 0x108(%rsp), %rdi
callq 0x19bf0
movq %rax, 0x110(%rsp)
movq 0x120(%rsp), %rdi
movq 0x118(%rsp), %rsi
movq 0x110(%rsp), %rdx
callq 0x1ad60
movq %rax, 0x50(%rsp)
jmp 0x9afd
movq 0x50(%rsp), %rax
movq %rax, 0x100(%rsp)
jmp 0x9db2
leaq 0x178(%rsp), %rdi
callq 0x197f0
movq 0x98(%rsp), %rdi
movq %rax, 0xf8(%rsp)
movl $0x0, 0xf4(%rsp)
movl 0x1ac(%rsp), %eax
movq %rax, 0x40(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x40(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x9b71
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x188e0
movq %rax, 0x38(%rsp)
jmp 0x9b93
movq 0x98(%rsp), %rdi
movl 0x1ac(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x19050
movl (%rax), %eax
movq %rax, 0x38(%rsp)
movq 0x98(%rsp), %rdi
movq 0x38(%rsp), %rax
movl %eax, 0xf0(%rsp)
movl 0x1ac(%rsp), %eax
movl %eax, %esi
callq 0x19050
movl (%rax), %eax
movl %eax, 0xec(%rsp)
movl 0xec(%rsp), %eax
cmpl 0xf0(%rsp), %eax
jae 0x9c42
leaq 0xf8(%rsp), %rdi
callq 0x1a670
movq %rax, %rcx
movq 0x98(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0x34(%rsp)
movq 0x18(%rax), %rdi
movl 0xec(%rsp), %eax
movl %eax, %esi
callq 0x18900
movl 0x34(%rsp), %ecx
movl %ecx, (%rax)
leaq 0xf8(%rsp), %rdi
xorl %esi, %esi
callq 0x1add0
movq %rax, 0xe0(%rsp)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x9bbe
leaq 0x178(%rsp), %rdi
callq 0x19770
movq %rax, %rcx
movq 0x98(%rsp), %rax
movl 0xf4(%rsp), %edx
subl %edx, %ecx
movl %ecx, 0xdc(%rsp)
movq 0x18(%rax), %rdi
movq %rdi, 0x28(%rsp)
callq 0x188e0
movq 0x28(%rsp), %rdi
movq %rax, %rsi
movl 0xdc(%rsp), %eax
addq %rax, %rsi
callq 0x18f30
jmp 0x9c91
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rdi
movq %rdi, 0x18(%rsp)
callq 0x19b50
movq %rax, 0xc0(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, %esi
leaq 0xc0(%rsp), %rdi
callq 0x19bf0
movq %rax, 0xc8(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x1aa60
movq 0xf8(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x19820
movq 0x18(%rsp), %rdi
movq %rax, 0xb0(%rsp)
movq 0xd0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xb0(%rsp), %rcx
callq 0x1ae10
movq %rax, 0x20(%rsp)
jmp 0x9d30
movq 0x20(%rsp), %rax
movq %rax, 0xa8(%rsp)
movl 0x1ac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
movq 0x98(%rsp), %rdi
movl 0xa4(%rsp), %eax
movq %rax, 0x10(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x9db0
movq 0x98(%rsp), %rdi
movl 0xdc(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xa4(%rsp), %eax
movl %eax, %esi
callq 0x19050
movl 0xc(%rsp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x9d4e
jmp 0x9db2
movq 0x98(%rsp), %rdi
movl 0x13c(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x1ac(%rsp), %eax
movl %eax, %esi
callq 0x19050
movl 0x8(%rsp), %ecx
movl %ecx, 0x4(%rax)
leaq 0x160(%rsp), %rdi
callq 0x18520
leaq 0x178(%rsp), %rdi
callq 0x19880
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x158(%rsp), %rdi
callq 0x2310
nopl (%rax)