// File: /workspace/github_cpp_makefile_star2_O1/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)
cmpl $-0x1, 0x30(%rax)
je 0x6957
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0x10(%rdx), %rax
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %rbp
leaq 0x1c(%rsp), %r13
movq 0x10(%rsp), %rcx
movq 0x18(%rcx), %rax
movl 0x30(%rcx), %ebx
testq %rbx, %rbx
je 0x676e
movq %rax, %rdi
callq 0x2210
decq %rbx
jne 0x6761
movl 0x20(%rax), %ecx
movl %ecx, 0xc(%rsp)
movq (%r14), %rdi
movq 0x8(%r14), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x67cd
movq (%rdx), %r9
movq %rdx, %rax
cmpl 0x8(%r9), %ecx
je 0x67cd
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x67cb
movl 0x8(%r9), %edi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x67cd
movq %r10, %rax
cmpl %edi, %ecx
jne 0x67a1
jmp 0x67cd
xorl %eax, %eax
testq %rax, %rax
je 0x6800
cmpq $0x0, (%rax)
je 0x6800
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xcb00
testb %al, %al
jne 0x6947
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
jmp 0x694b
movl $0x38, %edi
callq 0x21e0
movq %rax, %rbx
movq 0x8(%r15), %rax
movq -0x8(%rax), %rcx
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
movq %r12, %rdx
callq 0xca16
movq %rbx, 0x30(%rsp)
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x683e
movq %rbx, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x6849
movq %r15, %rdi
movq %rbp, %rdx
callq 0xe9d6
movq %r14, 0x30(%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
movq %rbp, %rdx
callq 0xdc3e
movq 0x8(%r15), %rax
movq -0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %eax
cmpq %rax, 0x18(%r14)
jne 0x6947
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), %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x68d0
leaq 0x8(%rbx), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movq %r14, %rcx
movq %r13, %r8
callq 0xe514
testb %al, %al
jne 0x68af
cmpq $0x3, 0x48(%rsp)
jne 0x68e8
movq 0x40(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x8(%rsp)
xorl %ebx, %ebx
jmp 0x693b
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x6902
movq %rbx, %rdi
callq 0xcfae
movq %rbx, %rdi
callq 0x21a0
addq $-0x8, 0x8(%r15)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xda9e
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xcb00
movl %eax, %ebx
testb %al, %al
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl 0x8(%rsp), %ecx
cmovel %eax, %ecx
movl %ecx, 0x8(%rsp)
movq %rbp, %rdi
callq 0xcff8
testb %bl, %bl
je 0x694b
movb $0x1, %al
jmp 0x694d
xorl %eax, %eax
testb %al, %al
jne 0x6750
jmp 0x695f
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movl 0x8(%rsp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6981
movq %rax, %r14
movq %rbx, %rdi
callq 0x21a0
jmp 0x698e
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0xcff8
movq %r14, %rdi
callq 0x2320