// File: /workspace/github_cpp_makefile_star2_O2/Kingsford-Group[P]ghost2/src/spectralToDistance.hpp
// Function: getDistances(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, double, boost::unordered::unordered_map<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, double, boost::hash<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::equal_to<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::allocator<std::pair<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> const, double>>>*, int)
vector<D_alpha> getDistances(string file1, string file2, string outputname, double a, double b, blastmap* blastscores, int numP)
{
  ptime t = bclock::local_time();
  cout << "loading sigs file: " << file1 << "\n";
  spectramap m1 = loadSigs(file1);
  cout << "loaded " << m1.size() << " vertices in " <<
    (bclock::local_time() - t).total_milliseconds() << "ms\n";

  t = bclock::local_time();
  cout << "loading sigs file: " << file2 << "\n";
  spectramap m2 = loadSigs(file2);
  cout << "loaded " << m2.size() << " vertices in " <<
    (bclock::local_time() - t).total_milliseconds() << "ms\n";

  ofstream out(outputname.c_str());

  t = bclock::local_time();

  vector<D_alpha**> results;
  vector<string*> outputs;
  int numthreads = numP==-1?boost::thread::hardware_concurrency():numP;
  if(numthreads < 2) numthreads = 2;
  cout << "\ncalculating D_alphas on " << numthreads << " threads\n";
  boost::threadpool::pool threads(numthreads);

  ProgressBar pbar(m1.size(), t);
  for(spectramap::iterator it1 = m1.begin(); it1 != m1.end(); ++it1){
    results.push_back(new D_alpha*[m2.size()]);
    outputs.push_back(new string);
    threads.schedule(boost::bind(&distanceWorker, *it1, &m2, results.back(),
        outputs.back(), &pbar));
  }

  threads.wait();
  cout << "\nfinished calculating " << (m1.size()*m2.size()) << " distances in " <<
    (bclock::local_time()-t).total_seconds() << "s\n";

  vector<D_alpha> allDistances;
  for(int i=0; i<results.size(); i++){
    out << *(outputs[i]);
    delete outputs[i];
    for(int j=0; j<m2.size(); j++){allDistances.push_back(*(results[i][j])); delete results[i][j];}
    delete[] results[i];
  }

  applyAlpha(a, b, &allDistances, blastscores);

  out.close();
  return allDistances;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movl %r9d, %ebp
movq %r8, 0x58(%rsp)
movsd %xmm1, 0x50(%rsp)
movsd %xmm0, 0x48(%rsp)
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1889e
movq %rax, 0x8(%rsp)
movq 0x69b5d(%rip), %rdi     # 0x7cf98
leaq 0x2d487(%rip), %rsi     # 0x408c9
callq 0xe540
movq %rax, %rdi
movq %r14, %rsi
callq 0xe4a0
leaq 0x2d22a(%rip), %rsi     # 0x40683
movq %rax, %rdi
callq 0xe540
leaq 0x120(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xe7a0
leaq 0xd0(%rsp), %rdi
movq %r13, %rsi
callq 0x12757
leaq 0x120(%rsp), %rdi
callq 0xe290
movq 0x69b00(%rip), %rdi     # 0x7cf98
leaq 0x2d43e(%rip), %rsi     # 0x408dd
callq 0xe540
movq 0xe0(%rsp), %rsi
movq %rax, %rdi
callq 0xe3a0
leaq 0x2d42a(%rip), %rsi     # 0x408e5
movq %rax, %rdi
callq 0xe540
movq %rax, %r14
callq 0x1889e
leaq 0x228(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x8(%rsp), %rsi
callq 0x1c4fa
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0xe500
leaq 0x2d3f7(%rip), %rsi     # 0x408f3
movq %rax, %rdi
callq 0xe540
callq 0x1889e
movq %rax, 0x8(%rsp)
movq 0x69a83(%rip), %rdi     # 0x7cf98
leaq 0x2d3ad(%rip), %rsi     # 0x408c9
callq 0xe540
movq %rax, %rdi
movq %r12, %rsi
callq 0xe4a0
leaq 0x2d150(%rip), %rsi     # 0x40683
movq %rax, %rdi
callq 0xe540
leaq 0x100(%rsp), %rdi
movq %r12, %rsi
callq 0xe7a0
leaq 0x60(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x12757
leaq 0x100(%rsp), %rdi
callq 0xe290
movq 0x69a27(%rip), %rdi     # 0x7cf98
leaq 0x2d365(%rip), %rsi     # 0x408dd
callq 0xe540
movq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0xe3a0
leaq 0x2d354(%rip), %rsi     # 0x408e5
movq %rax, %rdi
callq 0xe540
movq %rax, %r14
callq 0x1889e
leaq 0x228(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x8(%rsp), %rsi
callq 0x1c4fa
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0xe500
leaq 0x2d321(%rip), %rsi     # 0x408f3
movq %rax, %rdi
callq 0xe540
movq (%r15), %rsi
leaq 0x228(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0xe5d0
callq 0x1889e
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
cmpl $-0x1, %ebp
jne 0x1361c
callq 0xe6c0
movl %eax, %ebp
cmpl $0x3, %ebp
pushq $0x2
popq %r14
cmovgel %ebp, %r14d
movq 0x6996a(%rip), %rdi     # 0x7cf98
leaq 0x2d2c2(%rip), %rsi     # 0x408f7
callq 0xe540
movq %rax, %rdi
movl %r14d, %esi
callq 0xe9d0
leaq 0x2d2c5(%rip), %rsi     # 0x40911
movq %rax, %rdi
callq 0xe540
movl %r14d, %esi
leaq 0xb0(%rsp), %rdi
callq 0x190dc
movl 0xe0(%rsp), %esi
movq 0x8(%rsp), %rdx
leaq 0x140(%rsp), %rdi
callq 0x19346
leaq 0xd0(%rsp), %rdi
callq 0x38e80
movq %rax, %r13
leaq 0x90(%rsp), %r14
leaq 0x190(%rsp), %rbp
leaq 0x1c8(%rsp), %r12
leaq 0xb0(%rsp), %r15
testq %r13, %r13
je 0x1379d
movq 0x70(%rsp), %rax
movq %rax, %rcx
shrq $0x3d, %rcx
shlq $0x3, %rax
negq %rcx
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0xe040
movq %rax, 0x90(%rsp)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x39006
pushq $0x20
popq %rdi
callq 0xe560
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, (%rax)
andq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rax, 0x90(%rsp)
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x39182
leaq 0x10(%r13), %rsi
movq %rbp, %rdi
callq 0x19c1e
movq 0x18(%rsp), %rax
movq -0x8(%rax), %r8
movq 0x38(%rsp), %rax
movq -0x8(%rax), %r9
leaq 0x140(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
leaq -0x992(%rip), %rsi      # 0x12dc0
movq %rbp, %rdx
leaq 0x60(%rsp), %rcx
callq 0x19b72
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x19c58
movq %r15, %rdi
movq %r14, %rsi
callq 0x193d0
movq %r14, %rdi
callq 0x194d6
leaq 0x1d0(%rsp), %rdi
callq 0x19ca6
movq %rbp, %rdi
callq 0x19ca6
movq (%r13), %r13
jmp 0x136ad
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
callq 0x194e6
movq 0x697e5(%rip), %rdi     # 0x7cf98
leaq 0x2d161(%rip), %rsi     # 0x4091b
callq 0xe540
movq 0x70(%rsp), %rsi
imulq 0xe0(%rsp), %rsi
movq %rax, %rdi
callq 0xe3a0
leaq 0x2d156(%rip), %rsi     # 0x40932
movq %rax, %rdi
callq 0xe540
movq %rax, %r14
callq 0x1889e
leaq 0x90(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x8(%rsp), %rsi
callq 0x1c4fa
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0xe500
leaq 0x2d0fb(%rip), %rsi     # 0x40918
movq %rax, %rdi
callq 0xe540
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
xorl %ebp, %ebp
pushq $0x20
popq %r15
pushq $0x50
popq %r12
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jbe 0x138e3
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %rsi
leaq 0x228(%rsp), %rdi
callq 0xe4a0
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %r13
testq %r13, %r13
je 0x1387d
movq %r13, %rdi
callq 0xe290
movq %r13, %rdi
movq %r15, %rsi
callq 0xe590
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq (%rax,%rbp,8), %rdi
cmpq %r14, 0x70(%rsp)
jbe 0x138d1
movq (%rdi,%r14,8), %rsi
movq %rbx, %rdi
callq 0x19cbc
movq 0x10(%rsp), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r14,8), %r13
testq %r13, %r13
je 0x138c1
movq %r13, %rdi
callq 0x19ce8
movq %r13, %rdi
movq %r12, %rsi
callq 0xe590
incq %r14
jmp 0x1388b
testq %rdi, %rdi
je 0x138db
callq 0xe720
incq %rbp
jmp 0x1383a
movsd 0x48(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movq %rbx, %rdi
movq 0x58(%rsp), %rsi
callq 0x13001
leaq 0x228(%rsp), %rdi
callq 0xe7f0
leaq 0x168(%rsp), %rdi
callq 0x216f2
leaq 0xb0(%rsp), %rdi
callq 0x1963e
leaq 0x30(%rsp), %rdi
callq 0x38fd2
leaq 0x10(%rsp), %rdi
callq 0x38f9e
leaq 0x228(%rsp), %rdi
callq 0xe850
leaq 0x60(%rsp), %rdi
callq 0x37f80
leaq 0xd0(%rsp), %rdi
callq 0x37f80
movq %rbx, %rax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x13a2a
jmp 0x139b4
movq %rax, %r14
jmp 0x13a4b
jmp 0x139bf
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0xe290
jmp 0x13a62
jmp 0x139c9
jmp 0x139c9
movq %rax, %r14
leaq 0x120(%rsp), %rdi
callq 0xe290
jmp 0x13a6f
jmp 0x13a12
movq %rax, %r14
jmp 0x13a37
jmp 0x139bf
jmp 0x13a0d
jmp 0x13a0d
movq %rax, %r14
jmp 0x13a58
jmp 0x139c9
movq %rax, %r14
jmp 0x13a62
jmp 0x13a12
jmp 0x13a0d
movq %rax, %r14
jmp 0x139fc
movq %rax, %r14
jmp 0x139ef
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0x194d6
leaq 0x1d0(%rsp), %rdi
callq 0x19ca6
leaq 0x190(%rsp), %rdi
callq 0x19ca6
jmp 0x13a1d
jmp 0x13a0d
movq %rax, %r14
jmp 0x13a1d
movq %rax, %r14
movq %rbx, %rdi
callq 0x19cfe
leaq 0x168(%rsp), %rdi
callq 0x216f2
leaq 0xb0(%rsp), %rdi
callq 0x1963e
leaq 0x30(%rsp), %rdi
callq 0x38fd2
leaq 0x10(%rsp), %rdi
callq 0x38f9e
leaq 0x228(%rsp), %rdi
callq 0xe850
leaq 0x60(%rsp), %rdi
callq 0x37f80
leaq 0xd0(%rsp), %rdi
callq 0x37f80
movq %r14, %rdi
callq 0xe9f0