// File: canzarlab[P]Trajan/src/Parallel.cpp
// Function: ParallelSolver::Solve(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void ParallelSolver::Solve(string filename, string outScoreFile)
{
    GenericBnBSolver* S[thr_num];
    thread T[thr_num];
    mutex m; 
    
    for (int i = 0; i < thr_num; ++i)
    {
        S[i] = MakeSolver(t1, t2, d, k, dag, i, *this);
        T[i] = thread{&ParallelSolver::Callback, this, filename,outScoreFile, S[i]};
    }

    unique_lock<mutex> lock{m};
    thr_cond.wait(lock, [&] { return thr_val != thread::id{}; });

    for (int i = 0; i < thr_num; ++i)
    {
        T[i].join();
        delete S[i];
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rsi, -0x100(%rbp)
movq %rdx, -0xf8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl 0x88(%rax), %ecx
movq %rsp, %rdx
movq %rdx, -0x20(%rbp)
leaq 0xf(,%rcx,8), %rsi
andq $-0x10, %rsi
movq %rsp, %rdx
subq %rsi, %rdx
movq %rdx, -0xe8(%rbp)
movq %rdx, %rsp
movq %rcx, -0x28(%rbp)
movl 0x88(%rax), %eax
movq %rax, -0xe0(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xd8(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0xec5a7
movq -0xd8(%rbp), %rax
movq -0xe0(%rbp), %rdx
shlq $0x3, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x110(%rbp)
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xd9430
movq -0x118(%rbp), %rax
movq -0x110(%rbp), %rcx
addq $0x8, %rax
cmpq %rcx, %rax
movq %rax, -0x108(%rbp)
jne 0xec576
leaq -0x58(%rbp), %rdi
callq 0xbcd80
movl $0x0, -0x5c(%rbp)
movq -0xf0(%rbp), %rcx
movl -0x5c(%rbp), %eax
cmpl 0x88(%rcx), %eax
jge 0xec731
movq -0xf0(%rbp), %rsi
movq 0xa8(%rsi), %rax
movq %rax, -0x128(%rbp)
movq %rsi, %rax
addq $0xb0, %rax
movq %rax, -0x120(%rbp)
addq $0x128, %rsi            # imm = 0x128
leaq -0x80(%rbp), %rdi
callq 0xa190
jmp 0xec604
movq -0xf0(%rbp), %r9
movq -0x120(%rbp), %rsi
movq -0x128(%rbp), %rdi
movsd 0x148(%r9), %xmm0
movl -0x5c(%rbp), %r8d
movzbl 0x150(%r9), %ecx
andl $0x1, %ecx
leaq -0x80(%rbp), %rdx
callq 0xeb150
movq %rax, -0x130(%rbp)
jmp 0xec643
movq -0xe8(%rbp), %rax
movq -0x130(%rbp), %rdx
movslq -0x5c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq -0x80(%rbp), %rdi
callq 0xa8d8
movq -0xf0(%rbp), %rdx
movq -0xe8(%rbp), %rax
movq -0x100(%rbp), %rcx
movq -0xf8(%rbp), %r8
leaq -0x4c5(%rip), %rsi      # 0xec1c0
movq %rsi, -0xa8(%rbp)
movq $0x0, -0xa0(%rbp)
movq %rdx, -0xb0(%rbp)
movslq -0x5c(%rbp), %rdx
leaq (%rax,%rdx,8), %r9
leaq -0x98(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0xedf60
jmp 0xec6c2
movq -0xd8(%rbp), %rdi
movslq -0x5c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0xd9520
leaq -0x98(%rbp), %rdi
callq 0xbd7d0
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xec5b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xec871
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xa8d8
jmp 0xec871
leaq -0xc0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xee040
jmp 0xec743
movq -0xf0(%rbp), %rax
movq %rax, %rdi
addq $0x50, %rdi
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdx
leaq -0xc0(%rbp), %rsi
callq 0xec8e0
jmp 0xec76d
movl $0x0, -0xcc(%rbp)
movq -0xf0(%rbp), %rcx
movl -0xcc(%rbp), %eax
cmpl 0x88(%rcx), %eax
jge 0xec804
movq -0xd8(%rbp), %rax
movslq -0xcc(%rbp), %rcx
leaq (%rax,%rcx,8), %rdi
callq 0xa770
jmp 0xec7a5
movq -0xe8(%rbp), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, %rax
je 0xec7d1
movq -0x138(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0xec7d3
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0xec777
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xee080
jmp 0xec871
leaq -0xc0(%rbp), %rdi
callq 0xee080
movq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
shlq $0x3, %rdx
movq %rcx, %rax
addq %rdx, %rax
cmpq %rax, %rcx
movq %rax, -0x140(%rbp)
je 0xec865
movq -0x140(%rbp), %rdi
addq $-0x8, %rdi
movq %rdi, -0x148(%rbp)
callq 0xbd7d0
movq -0xd8(%rbp), %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x140(%rbp)
jne 0xec834
movq -0x20(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
movq -0xd8(%rbp), %rcx
movq -0xe0(%rbp), %rdx
shlq $0x3, %rdx
movq %rcx, %rax
addq %rdx, %rax
cmpq %rax, %rcx
movq %rax, -0x150(%rbp)
je 0xec8c6
movq -0x150(%rbp), %rdi
addq $-0x8, %rdi
movq %rdi, -0x158(%rbp)
callq 0xbd7d0
movq -0xd8(%rbp), %rcx
movq -0x158(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x150(%rbp)
jne 0xec895
jmp 0xec8c8
movq -0x88(%rbp), %rdi
callq 0xa7c0
nopw %cs:(%rax,%rax)