// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %r8, 0x28(%rsp)
movq (%rsi), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x30(%rax), %ecx
cmpl $-0x1, %ecx
je 0x6927
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
addq $0x10, %rdx
movq %rdx, 0x20(%rsp)
leaq 0x30(%rsp), %rbp
movq 0x18(%rax), %rax
testl %ecx, %ecx
je 0x67b3
movl %ecx, %r13d
movq %rax, %rdi
callq 0x2210
decq %r13
jne 0x67a6
movl 0x20(%rax), %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rbx
movq %rbx, %rsi
callq 0xdcaa
testq %rax, %rax
je 0x67ef
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xc45a
testb %al, %al
jne 0x691a
jmp 0x6927
movl $0x38, %edi
callq 0x21e0
movq %rax, %r13
movq 0x8(%r15), %rax
movq -0x8(%rax), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xc370
movq %r13, 0x30(%rsp)
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x682b
movq %r13, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x6836
movq %r15, %rdi
movq %rbp, %rdx
callq 0xe336
leaq 0x1c(%rsp), %rbx
movq %r14, 0x30(%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
movq %rbp, %rdx
callq 0xd538
movq 0x8(%r15), %rax
movq -0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %eax
cmpq %rax, 0x18(%r14)
jne 0x691a
leaq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
movq $0x1, 0x38(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, 0x50(%rsp) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movl $0x3, 0x1c(%rsp)
movq 0x20(%rsp), %r13
movq (%r13), %r13
testq %r13, %r13
je 0x68c3
leaq 0x8(%r13), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0xde74
testb %al, %al
jne 0x68a1
cmpq $0x3, 0x48(%rsp)
je 0x693d
movq 0x10(%rsp), %r13
testq %r13, %r13
je 0x68dd
movq %r13, %rdi
callq 0xc906
movq %r13, %rdi
callq 0x21a0
addq $-0x8, 0x8(%r15)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd3d6
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xc45a
movl %eax, %r13d
movq %rbp, %rdi
callq 0xc950
testb %r13b, %r13b
je 0x6927
movq 0x10(%rsp), %rax
movl 0x30(%rax), %ecx
jmp 0x679b
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30(%rsp), %rdi
movq 0x10(%rdi), %rax
movl 0x8(%rax), %ebx
callq 0xc950
jmp 0x692c
jmp 0x695f
movq %rax, %rbx
movq %r13, %rdi
callq 0x21a0
jmp 0x696c
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xc950
movq %rbx, %rdi
callq 0x2320