// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rdx, %r12
movl %esi, %r15d
movq %rdi, %rbx
movl %esi, 0x4(%rsp)
cmpb $0x1, 0x3c(%rdi)
jne 0x6d10
movq 0x40(%rbx), %rdi
leaq 0x4(%rsp), %rsi
callq 0xda16
movl (%rax), %r15d
leaq 0x28(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x50(%rsp), %rcx
movq %rax, 0x10(%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rcx)
leaq 0x4(%rsp), %rsi
leaq 0x20(%rsp), %rbp
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movq %rbp, %rdx
callq 0xcb9e
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rbx
subq 0x50(%rsp), %rbx
movq (%r12), %r13
movq 0x8(%r12), %r14
movq %rbp, 0x18(%rsp)
cmpq %r14, %r13
je 0x6da3
leaq 0x20(%rsp), %r12
leaq 0x18(%rsp), %rbp
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xd32e
addq $0x4, %r13
cmpq %r14, %r13
jne 0x6d87
shrq $0x2, %rbx
addl 0x8(%rsp), %ebx
movq 0x48(%rsp), %rbp
movl %r15d, %r13d
cmpq %rbx, %rbp
jbe 0x6df9
movq 0x10(%rsp), %r14
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
decq %rcx
cmpq %r13, %rcx
jne 0x6e80
movq 0x18(%r14), %rcx
movq 0x8(%rcx), %rbx
subq (%rcx), %rbx
shrq $0x2, %rbx
jmp 0x6e8b
cmpq %rbx, 0x48(%rsp)
movq 0x10(%rsp), %r14
jae 0x6e36
leaq 0x20(%rsp), %r15
leaq 0x18(%rsp), %r12
movq 0x58(%rsp), %rax
movl -0x4(%rax), %ecx
addq $-0x4, %rax
movl %ecx, 0x18(%rsp)
movq %rax, 0x58(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xdbc6
cmpq %rbx, 0x48(%rsp)
jb 0x6e0f
movq 0x38(%rsp), %rax
leaq 0x28(%rsp), %r15
cmpq %r15, %rax
je 0x6f63
movq (%r14), %rcx
movq 0x18(%r14), %rdx
leaq (,%r13,2), %rsi
addq %r13, %rsi
movl (%rcx,%rsi,4), %ebx
shlq $0x2, %rbx
addq (%rdx), %rbx
movl 0x20(%rax), %ecx
movl %ecx, (%rbx)
addq $0x4, %rbx
movq %rax, %rdi
callq 0x2210
cmpq %r15, %rax
jne 0x6e65
jmp 0x6f63
leal 0x1(%r15), %ecx
leaq (%rcx,%rcx,2), %rcx
movl (%rax,%rcx,4), %ebx
movq 0x38(%rsp), %r12
movq %r13, 0x8(%rsp)
leaq (,%r13,2), %rcx
addq %r13, %rcx
movl (%rax,%rcx,4), %ecx
xorl %eax, %eax
movl %ebx, %r13d
cmpl %ebx, %ecx
jae 0x6eed
movq %rbp, 0x70(%rsp)
movq 0x18(%r14), %rax
movq (%rax), %r14
movq %rcx, 0x68(%rsp)
movq %rcx, %rbp
movl 0x20(%r12), %eax
movl %eax, (%r14,%rbp,4)
movq %r12, %rdi
callq 0x2210
movq %rax, %r12
incq %rbp
cmpq %rbp, %r13
jne 0x6ec0
movq 0x68(%rsp), %rax
subl %ebx, %eax
movq 0x10(%rsp), %r14
movq 0x70(%rsp), %rbp
leal (%rax,%rbp), %ebx
movq 0x18(%r14), %rdi
movq 0x8(%rdi), %rax
subq (%rdi), %rax
sarq $0x2, %rax
leaq (%rbx,%rax), %rsi
callq 0xc44a
movq 0x18(%r14), %rdi
shlq $0x2, %r13
addq (%rdi), %r13
movq %r13, %rsi
movq %r12, %rdx
leaq 0x28(%rsp), %rcx
callq 0xecf8
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
leal 0x1(%r15), %edx
cmpq %rdx, %rcx
movq 0x8(%rsp), %r13
jbe 0x6f63
addl $0x2, %r15d
leaq (%rdx,%rdx,2), %rdx
addl %ebx, (%rax,%rdx,4)
movl %r15d, %edx
incl %r15d
cmpq %rdx, %rcx
ja 0x6f51
movq (%r14), %rax
leaq (,%r13,2), %rcx
addq %r13, %rcx
movl %ebp, 0x4(%rax,%rcx,4)
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6f84
callq 0x21a0
leaq 0x20(%rsp), %rdi
callq 0xcfae
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6fa5
jmp 0x6fa5
jmp 0x6fa5
jmp 0x6fa5
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6fb7
callq 0x21a0
leaq 0x20(%rsp), %rdi
callq 0xcfae
movq %rbx, %rdi
callq 0x2320
nop