// File: /workspace/github_cpp_makefile_star2_O2/iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getGoodNode(std::vector<Graph::Traversal*, std::allocator<Graph::Traversal*>>&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, unsigned int const&) const
uint32_t Graph::getGoodNode(vector<Traversal *> &frontier, unordered_set<uint32_t> &set, vector<uint32_t> &nodes, const uint32_t &size) const {
    Traversal *traversal = frontier[0];
    if (traversal->index == NONE) {
        return NONE;
    }
    while (true) {
        auto it = traversal->set.begin();
        std::advance(it, traversal->index);
        uint32_t neighbor = *it;
        if (set.find(neighbor) == set.end()) {
            frontier.push_back(new Traversal(neighbor, *this, frontier[frontier.size()-1]));
            set.insert(neighbor);
            traversal = frontier[frontier.size()-1];

            if (set.size() == size) {
                unordered_set<uint32_t> neighbors;
                gatherAllNeighbors(set, neighbors, 3);
                if (neighbors.size() == 3) {
                    return *(neighbors.begin());
                } else {
                    delete traversal;
                    frontier.pop_back();
                    set.erase(neighbor);
                    if (!advance(frontier, &traversal, *this, set)) {
                        return NONE;
                    }
                }
            }
        } else {
            if (!advance(frontier, &traversal, *this, set)) {
                return NONE;
            }
        }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, 0x38(%rsp)
movq %rdi, 0x18(%rsp)
movq (%rsi), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x30(%rax), %ecx
cmpl $-0x1, %ecx
je 0x5b64
movq %rdx, %r14
movq %rsi, 0x28(%rsp)
leaq 0x30(%rsp), %r15
leaq 0xc(%rsp), %r12
leaq 0x40(%rsp), %rbx
movq 0x18(%rax), %rax
movq %rax, 0x30(%rsp)
movl %ecx, %esi
movq %r15, %rdi
callq 0xba84
movq 0x30(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0xc35a
testq %rax, %rax
je 0x5a1b
movq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rcx
callq 0xa784
testb %al, %al
jne 0x5b4a
jmp 0x5b57
movq %rbx, %rbp
pushq $0x38
popq %rdi
callq 0x2190
movq %rax, %rbx
movq 0x28(%rsp), %r13
movq 0x8(%r13), %rax
movq -0x8(%rax), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
callq 0xa6b6
movq %rbx, 0x40(%rsp)
movq %r13, %rdi
movq %rbp, %rbx
movq %rbp, %rsi
callq 0xc95a
movq %r14, %rdi
movq %r12, %rsi
callq 0xbc1a
movq 0x8(%r13), %rax
movq -0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movl (%rax), %eax
cmpq %rax, 0x18(%r14)
jne 0x5ada
leaq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
movq $0x1, 0x48(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, 0x60(%rsp) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movl $0x3, 0x24(%rsp)
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
leaq 0x24(%rsp), %rcx
callq 0xa61a
cmpq $0x3, 0x58(%rsp)
jne 0x5ae1
movq 0x50(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x8(%rsp)
xorl %r13d, %r13d
jmp 0x5b35
leaq 0xc(%rsp), %r12
jmp 0x5b4a
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x5af3
movq %rbx, %rdi
callq 0xacde
movq %rbx, %rdi
callq 0x2160
addq $-0x8, 0x8(%r13)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xb93a
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rcx
callq 0xa784
movl %eax, %r13d
testb %al, %al
movl 0x8(%rsp), %eax
pushq $-0x1
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x8(%rsp)
movq %rbp, %rdi
callq 0xad26
testb %r13b, %r13b
movq %rbp, %rbx
leaq 0xc(%rsp), %r12
je 0x5b5e
movq 0x10(%rsp), %rax
movl 0x30(%rax), %ecx
jmp 0x59c8
pushq $-0x1
popq %rax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
jmp 0x5b67
pushq $-0x1
popq %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5b78
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0xad26
jmp 0x5b92
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x22c0