// File: /workspace/github_cpp_makefile_star2_O3/iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::contractToSingleNode(std::vector<unsigned int, std::allocator<unsigned int>> const&, std::vector<unsigned int, std::allocator<unsigned int>> const&, ReduceInfo&)
uint32_t Graph::contractToSingleNode(const vector<uint32_t> &nodes, const vector<uint32_t> &neighbors, ReduceInfo &reduceInfo) {
    uint32_t newNode = nextUnusedId;
    assert(++nextUnusedId != 0);
    assert(!mapping || mapping && idToPos->find(newNode) == idToPos->end());
    set<uint32_t> newNeighbors;
    for (auto it = neighbors.begin() ; it != neighbors.end() ; it++) {
        GraphTraversal graphTraversal(*this, *it);
        while (graphTraversal.curEdgeOffset != NONE) {
            uint32_t neighbor = (*edgeBuffer)[graphTraversal.curEdgeOffset];
            if (find(nodes.begin(), nodes.end(), neighbor) == nodes.end() && find(neighbors.begin(), neighbors.end(), neighbor) == neighbors.end()) {
                if (newNeighbors.insert(neighbor).second) {
                    replaceNeighbor(neighbor, *it, newNode);
                    uint32_t pos = (!mapping ? neighbor : idToPos->at(neighbor));
                    nodeIndex[pos].edges++;
                }
            }
            getNextEdge(graphTraversal);
        }
    }
    reduceInfo.nodesRemoved--;
    if (!newNeighbors.size()) {
        zeroDegreeNodes.push_back(newNode);
    } else {
        uint32_t offset = edgeBuffer->size();
        edgeBuffer->reserve(edgeBuffer->size() + newNeighbors.size());
        copy(newNeighbors.begin(), newNeighbors.end(), back_inserter(*edgeBuffer));
        nodeIndex.push_back(NodeInfo(offset, newNeighbors.size()));
        if (mapping) {
            idToPos->insert({newNode, nodeIndex.size() - 1});
            posToId->push_back(newNode);
        }
    }
    return newNode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x20(%rsp)
movl 0x38(%rdi), %eax
movl %eax, 0xc(%rsp)
incl %eax
movl %eax, 0x38(%rdi)
je 0x3b22
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
cmpb $0x1, 0x3c(%rdi)
jne 0x38f3
movq 0x40(%rbx), %rdi
leaq 0xc(%rsp), %rsi
callq 0xd37a
testq %rax, %rax
jne 0x3b41
leaq 0x30(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq (%r12), %rbp
cmpq 0x8(%r12), %rbp
je 0x3a62
leaq 0x10(%rsp), %r14
leaq 0x1c(%rsp), %r15
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0xba5a
movl 0x14(%rsp), %eax
cmpl $-0x1, %eax
je 0x39e6
movq 0x18(%rbx), %rcx
movl %eax, %eax
movq (%rcx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x1c(%rsp)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movq %r15, %rdx
callq 0xdd05
cmpq 0x8(%r13), %rax
jne 0x39d6
movq (%r12), %rdi
movq 0x8(%r12), %rsi
movq %r15, %rdx
callq 0xdd05
cmpq 0x8(%r12), %rax
jne 0x39d6
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0xd4c0
testb $0x1, %dl
je 0x39d6
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
leaq 0xc(%rsp), %rcx
callq 0x3b8a
cmpb $0x1, 0x3c(%rbx)
movq %r15, %rax
jne 0x39c9
movq 0x40(%rbx), %rdi
movq %r15, %rsi
callq 0xd37a
testq %rax, %rax
je 0x3b16
addq $0xc, %rax
movl (%rax), %eax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
incl 0x4(%rcx,%rax,4)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xbe2e
jmp 0x3937
addq $0x4, %rbp
cmpq 0x8(%r12), %rbp
jne 0x3929
movq 0x50(%rsp), %rsi
movq 0x20(%rsp), %rax
decl (%rax)
testq %rsi, %rsi
je 0x3a69
movq 0x18(%rbx), %rdi
movq 0x8(%rdi), %r14
subq (%rdi), %r14
sarq $0x2, %r14
addq %r14, %rsi
callq 0xbd9c
movq 0x40(%rsp), %rdi
movq 0x18(%rbx), %rdx
leaq 0x30(%rsp), %rsi
callq 0xddaa
movl 0x50(%rsp), %eax
movl %r14d, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3a8c
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x8(%rbx)
jmp 0x3a99
movq 0x20(%rsp), %rax
decl (%rax)
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x3a79
addq $0x28, %rbx
jmp 0x3adb
addq $0x20, %rbx
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xd7b4
jmp 0x3ae8
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0xdb48
cmpb $0x1, 0x3c(%rbx)
jne 0x3ae8
movq 0x8(%rbx), %rax
subq (%rbx), %rax
movq 0x40(%rbx), %rdi
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl 0xc(%rsp), %ecx
leaq 0x10(%rsp), %rsi
movl %ecx, (%rsi)
decl %eax
movl %eax, 0x4(%rsi)
callq 0xd8cc
movq 0x48(%rbx), %rbx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3b07
addq $0x8, %rbx
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, (%rbx)
movl 0xc(%rsp), %ebx
leaq 0x28(%rsp), %rdi
callq 0xc906
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xd7b4
jmp 0x3ae8
leaq 0x15cb3(%rip), %rdi     # 0x197d0
callq 0x2280
leaq 0x15549(%rip), %rdi     # 0x19072
leaq 0x15512(%rip), %rsi     # 0x19042
leaq 0x1554f(%rip), %rcx     # 0x19086
movl $0x115, %edx            # imm = 0x115
callq 0x2110
leaq 0x155a5(%rip), %rdi     # 0x190ed
leaq 0x154f3(%rip), %rsi     # 0x19042
leaq 0x15530(%rip), %rcx     # 0x19086
movl $0x116, %edx            # imm = 0x116
callq 0x2110
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
jmp 0x3b74
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xc906
movq %rbx, %rdi
callq 0x2320
nop