// File: /workspace/github_cpp_makefile_star2_O1/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 $0x398, %rsp            # imm = 0x398
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r13
callq 0xa070
movl $0x0, (%rax)
movq 0x170(%r14), %rdx
testq %rdx, %rdx
je 0x64448
movq 0x4c67f(%rip), %rax     # 0xb05b8
cmpq %r15, %rax
cmovbq %rax, %r15
movq %r15, 0x20(%rsp)
cmpq $0x2, %r15
jb 0x6433c
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x168(%r14), %rsi
addq %rsi, %rdx
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x2c652
leaq 0x2ae93(%rip), %rsi     # 0x8ee0a
movq %r15, %rdi
callq 0xaac0
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x626a4
leaq 0x2ae80(%rip), %rsi     # 0x8ee16
leaq 0x48(%rsp), %rdi
callq 0xaac0
leaq 0x10(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x63fc6
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x63fcd
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rsp, %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0xa190
leaq 0x100(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x64026
movq %rdx, 0xf0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x100(%rsp)
jmp 0x6402c
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq 0xf0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x4ca86(%rip), %rsi     # 0xb0ad8
callq 0x3fd63
movq 0xf0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x64074
movq 0x100(%rsp), %rsi
incq %rsi
callq 0xa5a0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x6408a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x640a5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xa5a0
movq %r13, 0x68(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x30fec
leaq 0x4a513(%rip), %rax     # 0xae5d8
leaq 0x358(%rsp), %r15
movq %rax, -0x268(%r15)
movl $0x0, -0x8(%r15)
leaq 0x368(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r13d, %r13d
movq %r13, -0x8(%rax)
movb %r13b, (%rax)
leaq 0x388(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r13, -0x8(%rax)
movb %r13b, (%rax)
movq %rsp, %rbx
xorl %r12d, %r12d
leaq 0xf0(%rsp), %rdi
callq 0x33e2a
testb %al, %al
je 0x641f0
movq %r15, %rdi
callq 0x374e6
movq %r15, %rdi
callq 0x387de
movq %rbp, (%rsp)
movq %rbx, %rdi
leaq 0x2acee(%rip), %rsi     # 0x8ee2c
leaq 0x2acf4(%rip), %rdx     # 0x8ee39
callq 0x2fdd8
movq %rbp, %r14
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %r15, %rdi
xorl %edx, %edx
callq 0xa9e0
movq %rax, %rbp
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x64179
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5a0
cmpq $-0x1, %rbp
movzbl %r13b, %r13d
movl $0x1, %eax
cmovnel %eax, %r13d
leaq 0x10(%rsp), %r14
movq %r14, (%rsp)
movq %rbx, %rdi
leaq 0x2ac83(%rip), %rsi     # 0x8ee20
leaq 0x2ac85(%rip), %rdx     # 0x8ee29
callq 0x2fdd8
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %r15, %rdi
xorl %edx, %edx
callq 0xa9e0
movq %rax, %rbp
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x641d5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5a0
cmpq $-0x1, %rbp
movzbl %r12b, %r12d
movl $0x1, %eax
cmovnel %eax, %r12d
leaq 0x10(%rsp), %rbp
jmp 0x6410b
leaq 0x4a3e1(%rip), %rax     # 0xae5d8
movq %rax, 0xf0(%rsp)
movq 0x378(%rsp), %rdi
leaq 0x388(%rsp), %rax
cmpq %rax, %rdi
je 0x64224
movq 0x388(%rsp), %rsi
incq %rsi
callq 0xa5a0
movq 0x358(%rsp), %rdi
leaq 0x368(%rsp), %rax
cmpq %rax, %rdi
je 0x64249
movq 0x368(%rsp), %rsi
incq %rsi
callq 0xa5a0
leaq 0x4a440(%rip), %rax     # 0xae690
leaq 0x310(%rsp), %rbx
movq %rax, -0x220(%rbx)
movq %rbx, %rdi
callq 0x43b9a
leaq 0x4a482(%rip), %rax     # 0xae6f0
movq %rax, -0x218(%rbx)
leaq 0x1f8(%rsp), %rbx
leaq 0x4a494(%rip), %rax     # 0xae718
movq %rax, (%rbx)
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0xa4b0
leaq 0x4a4a2(%rip), %rax     # 0xae740
movq %rax, -0x10(%r14)
leaq 0x4a4bf(%rip), %rax     # 0xae768
movq %rax, (%rbx)
movq $0x0, -0x8(%r14)
movq %rbx, %rdi
callq 0xa1c0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x642d8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xa5a0
testb $0x1, %r13b
movq 0x68(%rsp), %r13
je 0x6433c
movl $0x1, %esi
movq 0x20(%rsp), %r14
cmpq $0xa, %r14
jb 0x6437e
movl $0x4, %esi
movabsq $0x346dc5d63886594b, %rdi # imm = 0x346DC5D63886594B
cmpq $0x63, %r14
jbe 0x64372
cmpq $0x3e7, %r14            # imm = 0x3E7
jbe 0x64377
cmpq $0x2710, %r14           # imm = 0x2710
jb 0x64379
movq %r14, %rax
mulq %rdi
shrq $0xb, %rdx
addl $0x4, %esi
cmpq $0x1869f, %r14          # imm = 0x1869F
movq %rdx, %r14
ja 0x64306
addl $-0x3, %esi
jmp 0x64379
leaq 0x10(%r13), %rax
movq %rax, (%r13)
movq 0x4c78d(%rip), %rsi     # 0xb0ad8
movq 0x4c78e(%rip), %rdx     # 0xb0ae0
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2c652
movq %r13, %rax
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl $-0x2, %esi
jmp 0x64379
decl %esi
movq 0x20(%rsp), %r14
movl %esi, %esi
leaq 0xf0(%rsp), %rbx
leaq 0x100(%rsp), %rax
movq %rax, (%rbx)
movq %rbx, %rdi
xorl %edx, %edx
callq 0xa670
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
movq %r14, %rdx
callq 0x2cb62
leaq 0x2aa78(%rip), %rcx     # 0x8ee2a
movl $0xf, %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa620
leaq 0x10(%r13), %rbx
movq %rbx, (%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x643e8
movq %rdx, (%r13)
movq (%rcx), %rdx
movq %rdx, 0x10(%r13)
jmp 0x643ee
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
leaq 0x100(%rsp), %rsi
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%r13)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xf0(%rsp), %rdi
cmpq %rsi, %rdi
je 0x6442a
movq 0x100(%rsp), %rsi
incq %rsi
callq 0xa5a0
testb $0x1, %r12b
je 0x6435d
leaq 0x2a9ff(%rip), %rsi     # 0x8ee3a
movq %r13, %rdi
callq 0xaac0
jmp 0x6435d
callq 0xa6b0
testl %eax, %eax
jne 0x644da
leaq 0xc0(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x284ce(%rip), %rsi     # 0x8c936
leaq 0x284da(%rip), %rdx     # 0x8c949
leaq 0xb0(%rsp), %rdi
callq 0x2fdd8
leaq 0xd0(%rsp), %rdi
movl $0x1148, %esi           # imm = 0x1148
callq 0x2d60a
leaq 0x48(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x2d562
leaq 0x26736(%rip), %rsi     # 0x8abe5
leaq 0x48(%rsp), %rdi
callq 0xaac0
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x644e4
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x644f0
movl $0x1, %edi
callq 0xa6c0
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xa0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2a897(%rip), %rsi     # 0x8edb3
leaq 0x2a8e6(%rip), %rdx     # 0x8ee09
leaq 0x90(%rsp), %rdi
callq 0x2fdd8
leaq 0x283fc(%rip), %rsi     # 0x8c933
leaq 0x90(%rsp), %rdi
callq 0xaac0
leaq 0x80(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x64569
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x64579
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
movq 0x8(%rax), %rsi
leaq 0x70(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rdi
movq %rsp, %rsi
callq 0x2d562
leaq 0x2a753(%rip), %rsi     # 0x8ecfc
leaq 0x28(%rsp), %rdi
callq 0xaac0
leaq 0x100(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x645d7
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
jmp 0x645ea
movq %rdx, 0xf0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x100(%rsp)
movq 0x8(%rax), %rdx
leaq 0xf0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x3523b
movq %rax, %r15
movq 0xf0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x64633
movq 0x100(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x64633
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x64653
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x64653
movq %rax, %r15
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x64672
movq 0x80(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x64672
movq %rax, %r15
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x64694
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x64694
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x646af
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x646af
movq %rax, %r15
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x646cf
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x646cf
movq %rax, %r15
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6470d
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x6470d
movq %rax, %r15
movq (%r13), %rdi
cmpq %rbx, %rdi
je 0x64804
movq (%rbx), %rsi
jmp 0x647fc
movq %rax, %r15
movq 0xb0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x64804
movq 0xc0(%rsp), %rsi
jmp 0x647fc
movq %rax, %r15
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x64804
movq 0x100(%rsp), %rsi
jmp 0x647fc
movq %rax, %r15
jmp 0x64804
jmp 0x647c0
movq %rax, %r15
movq 0xf0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x64783
movq 0x100(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x64783
movq %rax, %r15
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x647a3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x647a3
movq %rax, %r15
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x647e8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xa5a0
jmp 0x647e8
movq %rax, %r15
jmp 0x647e8
movq %rax, %r15
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
jne 0x647f7
jmp 0x64804
jmp 0x647d8
jmp 0x647d8
movq %rax, %r15
leaq 0xf0(%rsp), %rdi
callq 0x2e31c
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x64804
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xa5a0
movq %r15, %rdi
callq 0xaa10