// File: /workspace/github_cpp_makefile_star2_O1/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), %ecx
movl %ecx, 0xc(%rsp)
movl %ecx, %eax
incl %eax
movl %eax, 0x38(%rdi)
je 0x3ae6
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
cmpb $0x1, 0x3c(%rdi)
jne 0x38db
movq 0x40(%rbx), %rax
movq (%rax), %rdi
movq 0x8(%rax), %r8
xorl %r10d, %r10d
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq (%rdi,%rdx,8), %rax
testq %rax, %rax
je 0x38cc
movq (%rax), %r9
movq %rax, %r10
cmpl 0x8(%r9), %ecx
je 0x38cc
movq %rdx, %rsi
movq %r9, %r11
movq (%r9), %r9
testq %r9, %r9
je 0x38c9
movl 0x8(%r9), %edi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %r10d
cmpq %rsi, %rdx
jne 0x38cc
movq %r11, %r10
cmpl %edi, %ecx
jne 0x389e
jmp 0x38cc
xorl %r10d, %r10d
testq %r10, %r10
je 0x38db
cmpq $0x0, (%r10)
jne 0x3b05
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 (%r15), %rbp
cmpq 0x8(%r15), %rbp
je 0x39cc
leaq 0x10(%rsp), %r14
leaq 0x1c(%rsp), %r13
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0xc132
movl 0x14(%rsp), %eax
cmpl $-0x1, %eax
je 0x39be
movq 0x18(%rbx), %rcx
movl %eax, %eax
movq (%rcx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x1c(%rsp)
movq (%r12), %rdi
movq 0x8(%r12), %rsi
movq %r13, %rdx
callq 0xe3b1
cmpq 0x8(%r12), %rax
jne 0x39ae
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movq %r13, %rdx
callq 0xe3b1
cmpq 0x8(%r15), %rax
jne 0x39ae
leaq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0xdbc6
testb $0x1, %dl
je 0x39ae
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
leaq 0xc(%rsp), %rcx
callq 0x3b4c
cmpb $0x1, 0x3c(%rbx)
movq %r13, %rax
jne 0x39a1
movq 0x40(%rbx), %rdi
movq %r13, %rsi
callq 0xda16
movl (%rax), %eax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
incl 0x4(%rcx,%rax,4)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc4d8
jmp 0x391d
addq $0x4, %rbp
cmpq 0x8(%r15), %rbp
jne 0x390f
movq 0x20(%rsp), %rax
decl (%rax)
movq 0x50(%rsp), %rsi
testq %rsi, %rsi
je 0x3a39
movq 0x18(%rbx), %rdi
movq 0x8(%rdi), %r14
subq (%rdi), %r14
sarq $0x2, %r14
addq %r14, %rsi
callq 0xc44a
movq 0x40(%rsp), %rdi
movq 0x18(%rbx), %rdx
leaq 0x30(%rsp), %rsi
callq 0xe44a
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 0x3a49
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x8(%rbx)
jmp 0x3a56
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x3aa7
addq $0x28, %rbx
jmp 0x3a98
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0xe250
cmpb $0x1, 0x3c(%rbx)
jne 0x3ac7
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 0xdfc4
movq 0x48(%rbx), %rbx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3aba
addq $0x8, %rbx
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, (%rbx)
jmp 0x3ac7
addq $0x20, %rbx
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xdeac
jmp 0x3ac7
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xdeac
movl 0xc(%rsp), %ebx
leaq 0x28(%rsp), %rdi
callq 0xcfae
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16585(%rip), %rdi     # 0x1a072
leaq 0x1654e(%rip), %rsi     # 0x1a042
leaq 0x1658b(%rip), %rcx     # 0x1a086
movl $0x115, %edx            # imm = 0x115
callq 0x2110
leaq 0x165e1(%rip), %rdi     # 0x1a0ed
leaq 0x1652f(%rip), %rsi     # 0x1a042
leaq 0x1656c(%rip), %rcx     # 0x1a086
movl $0x116, %edx            # imm = 0x116
callq 0x2110
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
jmp 0x3b36
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xcfae
movq %rbx, %rdi
callq 0x2320
nop