// File: cauimsouza[P]rikudo-solver/src/rikudo_solver/graph.cpp
// Function: Graph::ham_cycle_sat(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_sat(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_sat(source, min_deg_v, count, map, diamonds);
        sol.insert(sol.begin(), paths.begin(), paths.end());
        if(!count && !sol.empty())  break;
    }
    
    paths = sol;
    return paths;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl $0x7fffffff, -0x24(%rbp) # imm = 0x7FFFFFFF
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x2c(%rbp)
movq -0xa8(%rbp), %rdi
movslq -0x2c(%rbp), %rax
movq %rax, -0xb0(%rbp)
addq $0x38, %rdi
callq 0x4600
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq %rcx, %rax
jae 0x9903
movq -0xa8(%rbp), %rdi
addq $0x38, %rdi
movslq -0x2c(%rbp), %rsi
callq 0x4440
movq %rax, %rdi
callq 0x5460
movslq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jae 0x98f3
movq -0xa8(%rbp), %rdi
addq $0x38, %rdi
movslq -0x2c(%rbp), %rsi
callq 0x4440
movq %rax, %rdi
callq 0x5460
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x98f5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x987f
leaq -0x48(%rbp), %rdi
callq 0xb110
movq -0xa8(%rbp), %rdi
addq $0x38, %rdi
movslq -0x24(%rbp), %rsi
callq 0x4440
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x4700
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x4730
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4760
testb $0x1, %al
jne 0x9954
jmp 0x9a6e
leaq -0x58(%rbp), %rdi
callq 0x47a0
movq -0xa8(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %esi
movl -0x24(%rbp), %edx
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
movzbl -0x9(%rbp), %ecx
andl $0x1, %ecx
callq 0x8740
movq %rax, -0xb8(%rbp)
jmp 0x998c
movq -0xb8(%rbp), %rsi
movq -0xa8(%rbp), %rdi
addq $0x78, %rdi
callq 0xb1f0
jmp 0x99a5
leaq -0x48(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0xb460
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xbaf0
movq -0xa8(%rbp), %rdi
addq $0x78, %rdi
movq %rdi, -0xd0(%rbp)
callq 0xb460
movq -0xd0(%rbp), %rdi
movq %rax, -0x90(%rbp)
callq 0xb490
movq -0xc8(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq -0x98(%rbp), %rcx
callq 0xba40
movq %rax, -0xc0(%rbp)
jmp 0x9a24
movq -0xc0(%rbp), %rax
movq %rax, -0xa0(%rbp)
testb $0x1, -0x9(%rbp)
jne 0x9a5e
leaq -0x48(%rbp), %rdi
callq 0xbb30
testb $0x1, %al
jne 0x9a5e
jmp 0x9a6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4630
jmp 0x9aaf
jmp 0x9a60
leaq -0x58(%rbp), %rdi
callq 0x47c0
jmp 0x993e
movq -0xa8(%rbp), %rdi
addq $0x78, %rdi
leaq -0x48(%rbp), %rsi
callq 0xb1f0
jmp 0x9a84
movq -0xa8(%rbp), %rax
addq $0x78, %rax
movq %rax, -0xd8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4630
movq -0xd8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x3400
nopl (%rax,%rax)