// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::buildCC(std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>> const&, std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&) const
bool Graph::buildCC(const unordered_set<uint32_t> &excludedNodes, vector<uint32_t> &component1, vector<uint32_t> &component2) const {
    component1.clear();
    component2.clear();
    uint32_t component = 0;
    unordered_set<uint32_t> exploredSet;
    stack<uint32_t> frontier;
    Graph::GraphTraversal graphTraversal(*this);
    while (graphTraversal.curNode != NONE) {
        if (excludedNodes.find(graphTraversal.curNode) == excludedNodes.end() && exploredSet.insert(graphTraversal.curNode).second) {
            if (component == 2) {
                return false;
            }
            vector<uint32_t> *componentNodes = (component == 0 ? &component1 : &component2);
            componentNodes->push_back(graphTraversal.curNode);
            frontier.push(graphTraversal.curNode);
            while (!frontier.empty()) {
                uint32_t node = frontier.top();
                frontier.pop();
                Graph::GraphTraversal neighbors(*this, node);
                while (neighbors.curEdgeOffset != NONE) {
                    node = (*edgeBuffer)[neighbors.curEdgeOffset];
                    if (excludedNodes.find(node) == excludedNodes.end() && exploredSet.insert(node).second) {
                        frontier.push(node);
                        componentNodes->push_back(node);
                    }
                    getNextEdge(neighbors);
                }
            }
            component++;
        }
        getNextNode(graphTraversal);
    }
    return true;
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1a8(%rsp)
movq %rsi, 0x1a0(%rsp)
movq %rdx, 0x198(%rsp)
movq %rcx, 0x190(%rsp)
movq 0x1a8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x198(%rsp), %rdi
callq 0x191c0
movq 0x190(%rsp), %rdi
callq 0x191c0
movl $0x0, 0x18c(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x1a020
leaq 0x100(%rsp), %rdi
callq 0x1b5d0
jmp 0xe815
movq 0x60(%rsp), %rsi
leaq 0xec(%rsp), %rdi
callq 0x2a40
jmp 0xe829
jmp 0xe82b
cmpl $-0x1, 0xec(%rsp)
je 0xeba2
movq 0x1a0(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x1b600
movq %rax, 0x58(%rsp)
jmp 0xe855
movq 0x58(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x1b550
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1a690
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x57(%rsp)
jne 0xe89b
jmp 0xe8fc
leaq 0x150(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x18960
movb %dl, 0x47(%rsp)
movq %rax, 0x48(%rsp)
jmp 0xe8bb
movb 0x47(%rsp), %al
movq 0x48(%rsp), %rcx
movq %rcx, 0xb8(%rsp)
movb %al, 0xc0(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movb 0xc0(%rsp), %al
movb %al, 0xd0(%rsp)
movb 0xd0(%rsp), %al
movb %al, 0x57(%rsp)
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0xe909
jmp 0xeb89
cmpl $0x2, 0x18c(%rsp)
jne 0xe96a
movb $0x0, 0x1b7(%rsp)
movl $0x1, 0xb4(%rsp)
jmp 0xebb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
jmp 0xebe0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x1b6a0
jmp 0xebe0
cmpl $0x0, 0x18c(%rsp)
jne 0xe983
movq 0x198(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0xe990
movq 0x190(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x19070
jmp 0xe9b4
leaq 0x100(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x1b630
jmp 0xe9cb
jmp 0xe9cd
leaq 0x100(%rsp), %rdi
callq 0x1b660
movb %al, 0x37(%rsp)
jmp 0xe9e0
movb 0x37(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xe9ef
jmp 0xeb78
leaq 0x100(%rsp), %rdi
callq 0x1b680
movq %rax, 0x28(%rsp)
jmp 0xea03
movq 0x28(%rsp), %rax
movl (%rax), %eax
movl %eax, 0xa4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x1b690
jmp 0xea20
movq 0x60(%rsp), %rsi
leaq 0x9c(%rsp), %rdi
leaq 0xa4(%rsp), %rdx
callq 0x2a70
jmp 0xea3c
jmp 0xea3e
cmpl $-0x1, 0xa0(%rsp)
je 0xeb73
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0xa0(%rsp), %eax
movl %eax, %esi
callq 0x18900
movl (%rax), %eax
movl %eax, 0xa4(%rsp)
movq 0x1a0(%rsp), %rdi
leaq 0xa4(%rsp), %rsi
callq 0x1b600
movq %rax, 0x20(%rsp)
jmp 0xea88
movq 0x20(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x1b550
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1a690
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1f(%rsp)
jne 0xeace
jmp 0xeb20
leaq 0x150(%rsp), %rdi
leaq 0xa4(%rsp), %rsi
callq 0x18960
movb %dl, 0xf(%rsp)
movq %rax, 0x10(%rsp)
jmp 0xeaee
movb 0xf(%rsp), %al
movq 0x10(%rsp), %rcx
movq %rcx, 0x68(%rsp)
movb %al, 0x70(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x78(%rsp)
movb 0x70(%rsp), %al
movb %al, 0x80(%rsp)
movb 0x80(%rsp), %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xeb2a
jmp 0xeb5a
leaq 0x100(%rsp), %rdi
leaq 0xa4(%rsp), %rsi
callq 0x1b630
jmp 0xeb41
movq 0xa8(%rsp), %rdi
leaq 0xa4(%rsp), %rsi
callq 0x19070
jmp 0xeb58
jmp 0xeb5a
movq 0x60(%rsp), %rdi
leaq 0x9c(%rsp), %rsi
callq 0x19560
jmp 0xeb6e
jmp 0xea3e
jmp 0xe9cd
movl 0x18c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18c(%rsp)
movq 0x60(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x185f0
jmp 0xeb9d
jmp 0xe82b
movb $0x1, 0x1b7(%rsp)
movl $0x1, 0xb4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x1b6a0
leaq 0x150(%rsp), %rdi
callq 0x1a030
movb 0x1b7(%rsp), %al
andb $0x1, %al
addq $0x1b8, %rsp            # imm = 0x1B8
retq
leaq 0x150(%rsp), %rdi
callq 0x1a030
movq 0xf8(%rsp), %rdi
callq 0x2310
nopw (%rax,%rax)