// File: ncbi[P]amr/common.cpp
// Function: Common_sp::makeTempDir[abi:cxx11]()
string makeTempDir ()
{
  string tmpDir (getEnv ("TMPDIR"));
  if (tmpDir. empty ())
    tmpDir = "/tmp";

  string tmp = tmpDir + "/" + programName + ".XXXXXX";
  if (! mkdtemp (var_cast (tmp. c_str ())))
    throw runtime_error ("Error creating a temporary directory in " + tmpDir);
	if (tmp. empty ())
		throw runtime_error ("Cannot create a temporary directory in " + tmpDir);

  {
  	const string testFName (tmp + "/test");
    {
      ofstream f (testFName);
      f << "abc" << endl;
      if (! f. good ())
		    throw runtime_error (tmpDir + " is full, make space there or use environment variable TMPDIR to change location for temporary files");
    }
    removeFile (testFName);
  }

  return tmp;  
}

// Assembly:
subq $0x388, %rsp            # imm = 0x388
movq %rdi, 0x38(%rsp)
movq %rdi, %rax
movq %rax, 0x40(%rsp)
movq %rdi, 0x380(%rsp)
leaq 0x33f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xcd00
movq 0x48(%rsp), %rdx
leaq 0x87fdf(%rip), %rsi     # 0xcded9
leaq 0x340(%rsp), %rdi
callq 0x29fd0
jmp 0x45f09
leaq 0x360(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x73260
jmp 0x45f20
leaq 0x340(%rsp), %rdi
callq 0xce98
leaq 0x33f(%rsp), %rdi
callq 0xc7a0
leaq 0x360(%rsp), %rdi
callq 0xcc10
testb $0x1, %al
jne 0x45f4d
jmp 0x45fc7
leaq 0x87f8c(%rip), %rsi     # 0xcdee0
leaq 0x360(%rsp), %rdi
callq 0xca00
jmp 0x45f63
jmp 0x45fc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x45f9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x340(%rsp), %rdi
callq 0xce98
leaq 0x33f(%rsp), %rdi
callq 0xc7a0
jmp 0x46453
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x46446
movb $0x0, 0x32b(%rsp)
leaq 0x88428(%rip), %rdx     # 0xce3fe
leaq 0x2e8(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0x2d9a0
jmp 0x45fed
leaq 0xc0c64(%rip), %rdx     # 0x106c58
leaq 0x308(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x2e220
jmp 0x4600b
movq 0x38(%rsp), %rdi
leaq 0x87ece(%rip), %rdx     # 0xcdee5
leaq 0x308(%rsp), %rsi
callq 0x2a2f0
jmp 0x46026
leaq 0x308(%rsp), %rdi
callq 0xce98
leaq 0x2e8(%rsp), %rdi
callq 0xce98
movq 0x38(%rsp), %rdi
callq 0xc300
movq %rax, %rdi
callq 0x73d50
movq %rax, 0x30(%rsp)
jmp 0x46059
movq 0x30(%rsp), %rdi
callq 0xcd80
cmpq $0x0, %rax
jne 0x4618f
movb $0x1, 0x2c7(%rsp)
movl $0x10, %edi
callq 0xc3b0
movq %rax, 0x28(%rsp)
leaq 0x87e62(%rip), %rsi     # 0xcdeed
leaq 0x2c8(%rsp), %rdi
leaq 0x360(%rsp), %rdx
callq 0x2a1c0
jmp 0x460a2
movq 0x28(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
callq 0xcbb0
jmp 0x460b6
movq 0x28(%rsp), %rdi
movb $0x0, 0x2c7(%rsp)
movq 0xbff26(%rip), %rsi     # 0x105ff0
movq 0xbfe9f(%rip), %rdx     # 0x105f70
callq 0xcc80
jmp 0x46460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x46112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x308(%rsp), %rdi
callq 0xce98
leaq 0x2e8(%rsp), %rdi
callq 0xce98
jmp 0x46446
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x4643c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x46174
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0xce98
testb $0x1, 0x2c7(%rsp)
jne 0x46180
jmp 0x4618a
movq 0x28(%rsp), %rdi
callq 0xc580
jmp 0x4643c
movq 0x38(%rsp), %rdi
callq 0xcc10
testb $0x1, %al
jne 0x461a2
jmp 0x46262
movb $0x1, 0x29f(%rsp)
movl $0x10, %edi
callq 0xc3b0
movq %rax, 0x20(%rsp)
leaq 0x87d56(%rip), %rsi     # 0xcdf16
leaq 0x2a0(%rsp), %rdi
leaq 0x360(%rsp), %rdx
callq 0x2a1c0
jmp 0x461d7
movq 0x20(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0xcbb0
jmp 0x461eb
movq 0x20(%rsp), %rdi
movb $0x0, 0x29f(%rsp)
movq 0xbfdf1(%rip), %rsi     # 0x105ff0
movq 0xbfd6a(%rip), %rdx     # 0x105f70
callq 0xcc80
jmp 0x46460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x46247
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0xce98
testb $0x1, 0x29f(%rsp)
jne 0x46253
jmp 0x4625d
movq 0x20(%rsp), %rdi
callq 0xc580
jmp 0x4643c
movq 0x38(%rsp), %rsi
leaq 0x87cd0(%rip), %rdx     # 0xcdf3e
leaq 0x278(%rsp), %rdi
callq 0x2d9a0
jmp 0x4627d
leaq 0x78(%rsp), %rdi
leaq 0x278(%rsp), %rsi
movl $0x10, %edx
callq 0xcdf0
jmp 0x46296
leaq 0x87ca7(%rip), %rsi     # 0xcdf44
leaq 0x78(%rsp), %rdi
callq 0xc6f0
movq %rax, 0x18(%rsp)
jmp 0x462ae
movq 0x18(%rsp), %rdi
movq 0xbfc86(%rip), %rsi     # 0x105f40
callq 0xc760
jmp 0x462c1
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x78(%rsp,%rax), %rdi
callq 0xcc60
movb %al, 0x17(%rsp)
jmp 0x462da
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x463c5
jmp 0x462e8
movb $0x1, 0x57(%rsp)
movl $0x10, %edi
callq 0xc3b0
movq %rax, 0x8(%rsp)
leaq 0x87c45(%rip), %rdx     # 0xcdf48
leaq 0x58(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0x2d9a0
jmp 0x46317
movq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xcbb0
jmp 0x46328
movq 0x8(%rsp), %rdi
movb $0x0, 0x57(%rsp)
movq 0xbfcb7(%rip), %rsi     # 0x105ff0
movq 0xbfc30(%rip), %rdx     # 0x105f70
callq 0xcc80
jmp 0x46460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x46409
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x463ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
jmp 0x463b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x330(%rsp)
movl %eax, 0x32c(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xce98
testb $0x1, 0x57(%rsp)
jne 0x463b9
jmp 0x463c3
movq 0x8(%rsp), %rdi
callq 0xc580
jmp 0x463ff
leaq 0x78(%rsp), %rdi
callq 0xcae0
leaq 0x278(%rsp), %rdi
callq 0x2f6f0
jmp 0x463de
leaq 0x278(%rsp), %rdi
callq 0xce98
movb $0x1, 0x32b(%rsp)
testb $0x1, 0x32b(%rsp)
jne 0x46422
jmp 0x46418
leaq 0x78(%rsp), %rdi
callq 0xcae0
leaq 0x278(%rsp), %rdi
callq 0xce98
jmp 0x4643c
movq 0x38(%rsp), %rdi
callq 0xce98
leaq 0x360(%rsp), %rdi
callq 0xce98
movq 0x40(%rsp), %rax
addq $0x388, %rsp            # imm = 0x388
retq
movq 0x38(%rsp), %rdi
callq 0xce98
leaq 0x360(%rsp), %rdi
callq 0xce98
movq 0x330(%rsp), %rdi
callq 0xccf0