// File: /workspace/github_cpp_makefile_star2_O3/cauimsouza[P]rikudo-solver/src/rikudo_solver/graph.cpp
// Function: Graph::ham_cycle_bt(bool, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&)
std::vector< std::vector<int> >&
Graph::ham_cycle_bt(bool count,
                    const std::vector< std::pair<int,int> >& map,
                    const std::vector< std::pair<int,int> >& diamonds)
{   
    int min_deg_v = INT_MAX;
    int min_deg = -1;
    for(int i = 0; i < adj_list.size(); i++){
        if(adj_list[i].size() < min_deg){
            min_deg = adj_list[i].size();
            min_deg_v = i;
        }
    }
    std::vector< std::vector<int> > sol;

    for(int source : adj_list[min_deg_v]){
        paths = ham_path_bt(source, min_deg_v, count, map, diamonds);
        for(auto candidate : paths)
            if(valid(candidate, map, diamonds)){
                sol.push_back(candidate);
                if(count) break;
            }
        if(!count && !sol.empty())  break;
    }
    
    paths = sol;
    return paths;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movq %rdx, %r15
movl %esi, -0x2c(%rbp)
movq 0x38(%rdi), %rax
movq 0x40(%rdi), %rdx
subq %rax, %rdx
movq %rdi, -0x38(%rbp)
je 0x64fb
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
leaq 0x8(%rax), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %edi, %edi
movq (%rdx), %r8
subq -0x8(%rdx), %r8
sarq $0x2, %r8
movslq %esi, %rsi
cmpq %rsi, %r8
cmovbl %r8d, %esi
cmovbl %edi, %r9d
incq %rdi
addq $0x18, %rdx
cmpq %rdi, %rcx
jne 0x64d4
jmp 0x6501
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movl %r9d, -0x40(%rbp)
movslq %r9d, %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
cmpq %rax, %rdx
je 0x6605
movq -0x38(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x78(%rbp)
movzbl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %rbx
movq %rdx, -0x50(%rbp)
movl (%rdx), %esi
movq -0x38(%rbp), %rdi
movl -0x40(%rbp), %edx
movl -0x3c(%rbp), %ecx
movq %r15, %r8
movq %r14, %r9
callq 0x6366
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x7436
movq -0x38(%rbp), %rax
movq 0x78(%rax), %r12
movq 0x80(%rax), %r13
cmpq %r13, %r12
je 0x65cc
movq %rbx, %rdi
movq %r12, %rsi
callq 0x335e
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x376e
testb %al, %al
je 0x65b5
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
callq 0x73fa
cmpb $0x0, -0x2c(%rbp)
jne 0x65e2
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x65c6
callq 0x21d0
addq $0x18, %r12
jmp 0x6581
cmpb $0x0, -0x2c(%rbp)
jne 0x65f3
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
movq -0x50(%rbp), %rdx
je 0x65f7
jmp 0x6605
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x65f3
callq 0x21d0
movq -0x50(%rbp), %rdx
addq $0x4, %rdx
cmpq -0x48(%rbp), %rdx
jne 0x654b
movq -0x38(%rbp), %rbx
addq $0x78, %rbx
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0x7436
leaq -0x70(%rbp), %rdi
callq 0x3122
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x664e
jmp 0x664e
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x6651
callq 0x21d0
jmp 0x6651
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3122
movq %rbx, %rdi
callq 0x2380