// File: /workspace/github_cpp_makefile_star2_O3/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 $0x88, %rsp
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r14
movl %esi, 0xc(%rsp)
cmpb $0x1, 0x3c(%rdi)
jne 0x6cd3
movq 0x40(%r14), %rdi
leaq 0xc(%rsp), %rsi
callq 0xd37a
testq %rax, %rax
je 0x6f6e
movl 0xc(%rax), %ebx
leaq 0x50(%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 0x30(%rsp), %rcx
movq %rax, 0x10(%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rcx)
leaq 0xc(%rsp), %rsi
leaq 0x48(%rsp), %rbp
movq %r14, 0x18(%rsp)
movq %r14, %rdi
movq %rbp, %rdx
callq 0xc4e8
movq 0x70(%rsp), %rax
movq 0x38(%rsp), %r14
subq 0x30(%rsp), %r14
movq (%r12), %r13
movq 0x8(%r12), %r15
movq %rbp, 0x20(%rsp)
movq %rax, 0x10(%rsp)
movq %rax, %rbp
cmpq %r15, %r13
je 0x6d6e
leaq 0x48(%rsp), %r12
leaq 0x20(%rsp), %rbp
movq %r12, %rdi
leaq 0x50(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xcc6e
addq $0x4, %r13
cmpq %r15, %r13
jne 0x6d4d
movq 0x70(%rsp), %rbp
shrq $0x2, %r14
addl 0x10(%rsp), %r14d
cmpq %r14, %rbp
jbe 0x6dc4
movl %ebx, %edx
movq 0x18(%rsp), %r15
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rcx
decq %rcx
cmpq %rdx, %rcx
movq %rbp, 0x28(%rsp)
jne 0x6e4a
movq 0x18(%r15), %rcx
movq 0x8(%rcx), %r14
subq (%rcx), %r14
shrq $0x2, %r14
jmp 0x6e55
movq 0x18(%rsp), %r15
jae 0x6dfc
leaq 0x48(%rsp), %r12
leaq 0x20(%rsp), %r13
movq 0x38(%rsp), %rax
movl -0x4(%rax), %ecx
addq $-0x4, %rax
movl %ecx, 0x20(%rsp)
movq %rax, 0x38(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xd4c0
cmpq %r14, 0x70(%rsp)
jb 0x6dd5
movq 0x60(%rsp), %rax
movl %ebx, %r13d
movq (%r15), %r12
leaq 0x50(%rsp), %r14
cmpq %r14, %rax
je 0x6f33
movq 0x18(%r15), %rcx
leaq (,%r13,2), %rdx
addq %r13, %rdx
movl (%r12,%rdx,4), %ebx
shlq $0x2, %rbx
addq (%rcx), %rbx
movl 0x20(%rax), %ecx
movl %ecx, (%rbx)
addq $0x4, %rbx
movq %rax, %rdi
callq 0x2210
cmpq %r14, %rax
jne 0x6e2f
jmp 0x6f33
leal 0x1(%rbx), %ecx
leaq (%rcx,%rcx,2), %rcx
movl (%rax,%rcx,4), %r14d
movq 0x60(%rsp), %r12
movq %rdx, 0x10(%rsp)
leaq (%rdx,%rdx,2), %rcx
movl (%rax,%rcx,4), %ecx
xorl %eax, %eax
movq 0x18(%r15), %rdi
movq (%rdi), %rbp
movl %r14d, %r13d
cmpl %r14d, %ecx
jae 0x6eb9
movq %rdi, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
movq %rcx, %r15
movl 0x20(%r12), %eax
movl %eax, (%rbp,%r15,4)
movq %r12, %rdi
callq 0x2210
movq %rax, %r12
incq %r15
cmpq %r15, %r13
jne 0x6e87
movq 0x78(%rsp), %rax
subl %r14d, %eax
movq 0x18(%rsp), %r15
movq 0x80(%rsp), %rdi
movq 0x28(%rsp), %rcx
leal (%rcx,%rax), %r14d
movq 0x8(%rdi), %rax
subq %rbp, %rax
sarq $0x2, %rax
leaq (%r14,%rax), %rsi
callq 0xbd9c
movq 0x18(%r15), %rdi
shlq $0x2, %r13
addq (%rdi), %r13
movq %r13, %rsi
movq %r12, %rdx
leaq 0x50(%rsp), %rcx
callq 0xe620
movq (%r15), %r12
movq 0x8(%r15), %rax
subq %r12, %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
leal 0x1(%rbx), %ecx
cmpq %rcx, %rax
movq 0x28(%rsp), %rbp
movq 0x10(%rsp), %r13
jbe 0x6f33
addl $0x2, %ebx
leaq (%rcx,%rcx,2), %rcx
addl %r14d, (%r12,%rcx,4)
movl %ebx, %ecx
incl %ebx
cmpq %rcx, %rax
ja 0x6f22
leaq (,%r13,2), %rax
addq %r13, %rax
movl %ebp, 0x4(%r12,%rax,4)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6f52
callq 0x21a0
leaq 0x48(%rsp), %rdi
callq 0xc906
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1285b(%rip), %rdi     # 0x197d0
callq 0x2280
jmp 0x6f82
jmp 0x6f82
jmp 0x6f82
jmp 0x6f82
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6f94
callq 0x21a0
leaq 0x48(%rsp), %rdi
callq 0xc906
movq %rbx, %rdi
callq 0x2320