// File: /workspace/github_cpp_makefile_star2_O2/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, (%rsp)
incl %eax
movl %eax, 0x38(%rdi)
je 0x34c0
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
cmpb $0x1, 0x3c(%rdi)
jne 0x3308
movq 0x40(%rbx), %rdi
movq %rsp, %rsi
callq 0xb89e
testq %rax, %rax
jne 0x34df
leaq 0x30(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq (%r12), %rsi
leaq 0x14(%rsp), %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x4(%rsp), %r14
cmpq 0x8(%r12), %rsi
je 0x33fe
movq %rbx, %rdi
movq %rsi, 0x8(%rsp)
movq %r15, %rdx
callq 0x9dde
movl 0x18(%rsp), %eax
cmpq %rbp, %rax
je 0x33f0
movq 0x18(%rbx), %rcx
movq (%rcx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x4(%rsp)
movq (%r13), %rdi
movq 0x8(%r13), %rsi
movq %r14, %rdx
callq 0xc377
cmpq 0x8(%r13), %rax
jne 0x33e0
movq (%r12), %rdi
movq 0x8(%r12), %rsi
movq %r14, %rdx
callq 0xc377
cmpq 0x8(%r12), %rax
jne 0x33e0
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xbad0
testb $0x1, %dl
je 0x33e0
movq %rbx, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
movq %rsp, %rcx
callq 0x3526
cmpb $0x1, 0x3c(%rbx)
movq %r14, %rax
jne 0x33d3
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xb880
movl (%rax), %eax
movq (%rbx), %rcx
imulq $0xc, %rax, %rax
incl 0x4(%rcx,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa1ca
jmp 0x3350
movq 0x8(%rsp), %rsi
addq $0x4, %rsi
jmp 0x3335
movq 0x20(%rsp), %rax
decl (%rax)
movq 0x50(%rsp), %rsi
testq %rsi, %rsi
je 0x3493
movq 0x18(%rbx), %rdi
movq 0x8(%rdi), %r14
subq (%rdi), %r14
sarq $0x2, %r14
addq %r14, %rsi
callq 0xa11c
movq 0x40(%rsp), %rdi
movq 0x18(%rbx), %rdx
leaq 0x30(%rsp), %rsi
callq 0xc3fe
movl 0x50(%rsp), %eax
leaq 0x14(%rsp), %rsi
movl %r14d, (%rsi)
movl %eax, 0x4(%rsi)
movb $0x0, 0x8(%rsi)
movq %rbx, %rdi
callq 0xc224
cmpb $0x1, 0x3c(%rbx)
jne 0x34a2
movq 0x40(%rbx), %rdi
movq 0x8(%rbx), %rax
subq (%rbx), %rax
pushq $0xc
popq %rcx
cqto
idivq %rcx
movl (%rsp), %ecx
leaq 0x14(%rsp), %rsi
movl %ecx, (%rsi)
decl %eax
movl %eax, 0x4(%rsi)
callq 0xbfd8
movq 0x48(%rbx), %rdi
movq %rsp, %rsi
callq 0xa1ac
jmp 0x34a2
addq $0x20, %rbx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xa1ac
movl (%rsp), %ebx
leaq 0x28(%rsp), %rdi
callq 0xacde
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13baf(%rip), %rdi     # 0x17076
leaq 0x13b78(%rip), %rsi     # 0x17046
leaq 0x13bb5(%rip), %rcx     # 0x1708a
movl $0x115, %edx            # imm = 0x115
callq 0x2100
leaq 0x13c0b(%rip), %rdi     # 0x170f1
leaq 0x13b59(%rip), %rsi     # 0x17046
leaq 0x13b96(%rip), %rcx     # 0x1708a
movl $0x116, %edx            # imm = 0x116
callq 0x2100
jmp 0x3510
jmp 0x3510
jmp 0x3510
jmp 0x3510
jmp 0x3510
jmp 0x3510
jmp 0x3510
jmp 0x3510
jmp 0x3510
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xacde
movq %rbx, %rdi
callq 0x22c0
nop