// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r12
movl %esi, %r14d
movq %rdi, %rbp
movl %esi, (%rsp)
cmpb $0x1, 0x3c(%rdi)
jne 0x5e67
movq 0x40(%rbp), %rdi
movq %rsp, %rsi
callq 0xb880
movl (%rax), %r14d
leaq 0x40(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
movq %rsp, %rsi
leaq 0x38(%rsp), %rdx
movq %rbp, %rdi
callq 0xa83c
leaq 0x38(%rsp), %rdi
movq 0x28(%rdi), %r15
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
movq (%r12), %rsi
movq 0x8(%r12), %rdx
callq 0xcc60
subq %r13, %rbx
shrq $0x2, %rbx
addl %ebx, %r15d
movq 0x60(%rsp), %rbx
cmpq %r15, %rbx
jbe 0x5f11
movl %r14d, %esi
movq (%rbp), %rcx
movq 0x8(%rbp), %rax
subq %rcx, %rax
pushq $0xc
popq %rdi
cqto
idivq %rdi
decq %rax
cmpq %rsi, %rax
movq %rbp, 0x30(%rsp)
movq %rbx, 0x8(%rsp)
jne 0x5f7b
movq 0x18(%rbp), %r12
movq 0x8(%r12), %rax
subq (%r12), %rax
shrq $0x2, %rax
jmp 0x5f8a
leaq 0x38(%rsp), %r12
leaq 0x4(%rsp), %r13
movq %rbx, %rax
cmpq %r15, %rax
jae 0x5f4a
movq 0x18(%rsp), %rax
movl -0x4(%rax), %ecx
addq $-0x4, %rax
movl %ecx, 0x4(%rsp)
movq %rax, 0x18(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xbad0
movq 0x60(%rsp), %rax
jmp 0x5f1e
movq 0x50(%rsp), %rdi
movq (%rbp), %rax
movq 0x18(%rbp), %rcx
movl %r14d, %r14d
imulq $0xc, %r14, %rdx
movl (%rax,%rdx), %edx
shlq $0x2, %rdx
addq (%rcx), %rdx
leaq 0x40(%rsp), %rsi
callq 0xccad
movq (%rbp), %rcx
jmp 0x6039
leal 0x1(%r14), %eax
imulq $0xc, %rax, %rax
movl (%rcx,%rax), %eax
movq 0x18(%rbp), %r12
movq 0x50(%rsp), %r13
movq %rsi, 0x28(%rsp)
imulq $0xc, %rsi, %rdx
movl (%rcx,%rdx), %ebx
movl %eax, %ebp
movq 0x8(%rsp), %r15
negl %r15d
cmpq %rbp, %rbx
jae 0x5fc8
movl 0x20(%r13), %eax
movq (%r12), %rcx
movl %eax, (%rcx,%rbx,4)
movq %r13, %rdi
callq 0x21b0
movq %rax, %r13
incq %rbx
incl %r15d
jmp 0x5fa5
negl %r15d
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x2, %rax
leaq (%r15,%rax), %rsi
movq %r12, %rdi
callq 0xa11c
movq 0x30(%rsp), %rbx
movq 0x18(%rbx), %rdi
shlq $0x2, %rbp
addq (%rdi), %rbp
movq %rbp, %rsi
movq %r13, %rdx
leaq 0x40(%rsp), %rcx
callq 0xa8de
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
subq %rcx, %rax
cqto
pushq $0xc
popq %rsi
idivq %rsi
incl %r14d
movq 0x8(%rsp), %rbx
movl %r14d, %edx
cmpq %rdx, %rax
jbe 0x6034
imulq $0xc, %rdx, %rsi
addl %r15d, (%rcx,%rsi)
leal 0x1(%rdx), %r14d
jmp 0x601e
movq 0x28(%rsp), %r14
imulq $0xc, %r14, %rax
movl %ebx, 0x4(%rcx,%rax)
leaq 0x10(%rsp), %rdi
callq 0xb872
leaq 0x38(%rsp), %rdi
callq 0xacde
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x606e
jmp 0x606e
jmp 0x606e
jmp 0x606e
jmp 0x606e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb872
leaq 0x38(%rsp), %rdi
callq 0xacde
movq %rbx, %rdi
callq 0x22c0
nop