// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rdx, %r14
movl %esi, -0x2c(%rbp)
movq 0x38(%rdi), %rcx
movq %rdi, -0x38(%rbp)
movq 0x40(%rdi), %rax
subq %rcx, %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
leaq 0x8(%rcx), %rdx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
pushq $-0x1
popq %rsi
xorl %edi, %edi
cmpq %rdi, %rax
je 0x542d
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
jmp 0x5406
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
movl %r9d, -0x40(%rbp)
movslq %r9d, %rax
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rdx
movq 0x8(%rcx,%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x48(%rbp)
movzbl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %r13
movq %rdx, -0x50(%rbp)
cmpq -0x78(%rbp), %rdx
je 0x551b
movq -0x50(%rbp), %rax
movl (%rax), %esi
movq -0x38(%rbp), %rdi
movl -0x40(%rbp), %edx
movl -0x3c(%rbp), %ecx
movq %r14, %r8
movq %rbx, %r9
callq 0x52bc
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x5ea8
movq -0x38(%rbp), %rax
movq 0x78(%rax), %r12
movq 0x80(%rax), %r15
cmpq %r15, %r12
je 0x54f4
movq %r13, %rdi
movq %r12, %rsi
callq 0x2f56
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3330
testb %al, %al
je 0x54e6
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
callq 0x5e46
cmpb $0x0, -0x2c(%rbp)
jne 0x5506
movq %r13, %rdi
callq 0x2e04
addq $0x18, %r12
jmp 0x54b2
cmpb $0x0, -0x2c(%rbp)
jne 0x550e
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
je 0x550e
jmp 0x551b
movq %r13, %rdi
callq 0x2e04
movq -0x50(%rbp), %rdx
addq $0x4, %rdx
jmp 0x546e
leaq -0x70(%rbp), %rsi
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x5ea8
leaq -0x70(%rbp), %rdi
callq 0x2d36
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x555b
jmp 0x555b
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2e04
jmp 0x555e
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x2d36
movq %rbx, %rdi
callq 0x2360
nop