// File: /workspace/github_cpp_makefile_star2_O2/ncbi[P]amr/common.cpp
// Function: Common_sp::ShellApplication::getBlastThreadsParam(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long) const
string ShellApplication::getBlastThreadsParam (const string &blast,
                                               size_t threads_max_max) const
{
  ASSERT (! tmp. empty ());

  const size_t t = min (threads_max, threads_max_max);
  if (t <= 1)  // One thread is main
    return noString;
  
	bool num_threadsP = false;
	bool mt_modeP = false;
	{
	  const string blast_help (tmp + "/blast_help");
    exec (fullProg (blast) + " -help > " + blast_help);
    LineInput f (blast_help);
    while (f. nextLine ())
    {
      trim (f. line);
      if (contains (f. line, "-num_threads "))
        num_threadsP = true;
      if (contains (f. line, "-mt_mode "))
        mt_modeP = true;
    }
  }
  
  if (! num_threadsP)
    return noString;
  
  string s ("  -num_threads " + to_string (t));
  
  bool mt_mode_works = true;
#ifdef __APPLE__
  {
    mt_mode_works = false;
    const string blast_version (tmp + "/blast_version");
    exec (fullProg (blast) + " -version > " + blast_version);
    LineInput f (blast_version);
    while (f. nextLine ())
    {
      trim (f. line);
      const string prefix (blast + ": ");
      if (isLeft (f. line, prefix))
      {
        trimSuffix (f. line, "+");
        Istringstream iss;
        iss. reset (f. line. substr (prefix. size ()));
        const SoftwareVersion v (iss);
      //PRINT (v);  
        iss. reset ("2.13.0");  // PD-4560
        const SoftwareVersion threshold (iss);;
      //PRINT (threshold);  
        mt_mode_works = (threshold <= v);
      }
      break;
    }
  }
#endif

  if (mt_modeP && mt_mode_works)  
    s += "  -mt_mode 1";
    
  return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0xb060
andl $0x0, (%rax)
cmpq $0x0, 0x170(%r14)
je 0x3bf79
movq 0x4884c(%rip), %rax     # 0x845d8
cmpq %r12, %rax
cmovbq %rax, %r12
cmpq $0x1, %r12
ja 0x3bdb0
leaq 0x48d58(%rip), %rsi     # 0x84af8
movq %r15, %rdi
callq 0xb7b0
movq %r15, %rax
jmp 0x3bf67
leaq 0x168(%r14), %rsi
leaq 0x22041(%rip), %rdx     # 0x5ddff
leaq 0x60(%rsp), %rdi
callq 0x1c88d
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3b112
leaq 0x2202c(%rip), %rdx     # 0x5de0b
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1b92d
leaq 0x100(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x1cbaf
leaq 0x48cec(%rip), %rsi     # 0x84af8
leaq 0x100(%rsp), %rdi
callq 0x2812e
movq %r12, 0x18(%rsp)
movq %r15, 0x10(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xbb68
leaq 0x40(%rsp), %rdi
callq 0xbb68
leaq 0x20(%rsp), %rdi
callq 0xbb68
leaq 0x100(%rsp), %rdi
leaq 0x60(%rsp), %rsi
xorl %edx, %edx
callq 0x1d20a
leaq 0x368(%rsp), %r15
xorl %r14d, %r14d
leaq 0x40(%rsp), %rbp
leaq 0x20(%rsp), %rbx
xorl %r12d, %r12d
leaq 0x100(%rsp), %rdi
callq 0x219d4
testb %al, %al
je 0x3bee1
movq %r15, %rdi
callq 0x3c32f
movq %rbp, %rdi
leaq 0x21f8e(%rip), %rsi     # 0x5de21
movq %rbx, %rdx
callq 0x1b7b6
movq %r15, %rdi
movq %rbp, %rsi
callq 0x1d40b
movl %eax, %r13d
movq %rbp, %rdi
callq 0xbb68
movq %rbp, %rdi
leaq 0x21f5a(%rip), %rsi     # 0x5de15
movq %rbx, %rdx
callq 0x1b7b6
orb %r13b, %r14b
movq %r15, %rdi
movq %rbp, %rsi
callq 0x1d40b
movl %eax, %r13d
movq %rbp, %rdi
callq 0xbb68
orb %r13b, %r12b
jmp 0x3be70
leaq 0x100(%rsp), %rdi
callq 0x1d368
leaq 0x60(%rsp), %rdi
callq 0xbb68
testb $0x1, %r14b
je 0x3bf50
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x1c047
leaq 0x21f05(%rip), %rsi     # 0x5de1f
movq 0x10(%rsp), %rdi
movq %rbx, %rdx
callq 0x1b94c
leaq 0x100(%rsp), %rdi
callq 0xbb68
testb $0x1, %r12b
movq 0x10(%rsp), %rbx
je 0x3bf64
leaq 0x21ee9(%rip), %rsi     # 0x5de2f
movq %rbx, %rdi
callq 0xbac0
jmp 0x3bf64
leaq 0x48ba1(%rip), %rsi     # 0x84af8
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xb7b0
movq %rbx, %rax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xb6c0
testl %eax, %eax
jne 0x3c053
leaq 0x1f9b4(%rip), %rsi     # 0x5b941
leaq 0xe0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b7b6
leaq 0xc0(%rsp), %rdi
movl $0x1148, %esi           # imm = 0x1148
callq 0x1caa3
leaq 0x20(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x1ca3c
leaq 0x1dc11(%rip), %rdx     # 0x59be3
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1b92d
leaq 0x21dc0(%rip), %rsi     # 0x5dda8
leaq 0x80(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1b7b6
leaq 0x1f93d(%rip), %rdx     # 0x5b93e
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1b92d
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x1ca3c
leaq 0x21cbd(%rip), %rdx     # 0x5dcf1
leaq 0x100(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b92d
leaq 0x100(%rsp), %rdi
callq 0x224fc
pushq $0x1
popq %rdi
callq 0xb6d0
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0xbb68
jmp 0x3c070
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0xbb68
jmp 0x3c07f
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0xbb68
jmp 0x3c091
movq %rax, %r14
leaq 0x80(%rsp), %rdi
callq 0xbb68
jmp 0x3c0a3
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0xbb68
jmp 0x3c0b2
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0xbb68
jmp 0x3c0c1
movq %rax, %r14
leaq 0xc0(%rsp), %rdi
callq 0xbb68
jmp 0x3c0db
movq %rax, %r14
movq %rbx, %rdi
jmp 0x3c147
movq %rax, %r14
leaq 0xe0(%rsp), %rdi
jmp 0x3c147
movq %rax, %r14
leaq 0x100(%rsp), %rdi
jmp 0x3c147
movq %rax, %r14
jmp 0x3c14c
jmp 0x3c129
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0xbb68
jmp 0x3c10e
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0xbb68
jmp 0x3c11d
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0xbb68
jmp 0x3c142
movq %rax, %r14
jmp 0x3c142
jmp 0x3c132
jmp 0x3c132
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0x1d368
leaq 0x60(%rsp), %rdi
callq 0xbb68
movq %r14, %rdi
callq 0xba30