// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixGetTempname
static int unixGetTempname(int nBuf, char *zBuf){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  unsigned int i, j;
  const char *zDir;

  /* It's odd to simulate an io-error here, but really this is just
  ** using the io-error infrastructure to test that SQLite handles this
  ** function failing. 
  */
  SimulateIOError( return SQLITE_IOERR );

  zDir = unixTempFileDir();
  if( zDir==0 ) zDir = ".";

  /* Check that the output buffer is large enough for the temporary file 
  ** name. If it is not, return SQLITE_ERROR.
  */
  if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
    return SQLITE_ERROR;
  }

  do{
    sqlite3_snprintf(nBuf-18, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
    j = (int)strlen(zBuf);
    sqlite3_randomness(15, &zBuf[j]);
    for(i=0; i<15; i++, j++){
      zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
    }
    zBuf[j] = 0;
    zBuf[j+1] = 0;
  }while( osAccess(zBuf,0)==0 );
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movl %edi, -0x2c(%rbp)
movq 0x71f07(%rip), %rax     # 0x88e88
movq %rax, 0x70b08(%rip)     # 0x87a90
cmpq $0x0, 0x70b08(%rip)     # 0x87a98
jne 0x16fa5
leaq 0x547b2(%rip), %rdi     # 0x6b74b
callq 0x84a0
movq %rax, 0x70af3(%rip)     # 0x87a98
xorl %r14d, %r14d
leaq 0x70ae1(%rip), %r13     # 0x87a90
leaq -0xc8(%rbp), %r15
xorl %r12d, %r12d
cmpq $0x30, %r14
je 0x17002
testq %r12, %r12
je 0x16ff8
movq %r12, %rdi
movq %r15, %rsi
callq *0x708e8(%rip)          # 0x878b8
testl %eax, %eax
jne 0x16ff8
movl -0xb0(%rbp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x16ff8
movq %r12, %rdi
pushq $0x7
popq %rsi
callq *0x70894(%rip)          # 0x87888
testl %eax, %eax
je 0x17002
movq (%r14,%r13), %r12
addq $0x8, %r14
jmp 0x16fb9
testq %r12, %r12
leaq 0x58540(%rip), %rdi     # 0x6f54c
cmovneq %r12, %rdi
movq %rdi, -0x38(%rbp)
callq 0x8170
addq $0x19, %rax
movl -0x2c(%rbp), %edi
movslq %edi, %rcx
cmpq %rcx, %rax
jae 0x170b7
addl $-0x12, %edi
movb $0x3e, %r14b
leaq 0x58437(%rip), %r15     # 0x6f470
movl %edi, -0x2c(%rbp)
xorl %r13d, %r13d
movq %rbx, %rsi
leaq 0x546e5(%rip), %rdx     # 0x6b72e
movq -0x38(%rbp), %rcx
xorl %eax, %eax
callq 0xaf26
movq %rbx, %rdi
callq 0x8170
movq %rax, %r12
movl %r12d, %esi
addq %rbx, %rsi
pushq $0xf
popq %rdi
callq 0xb09f
movl %r12d, %eax
movl %eax, %ecx
cmpl $-0xf, %r13d
je 0x17091
movzbl (%rbx,%rcx), %eax
divb %r14b
movzbl %ah, %eax
movb (%rax,%r15), %al
movb %al, (%rbx,%rcx)
leal 0x1(%rcx), %eax
decl %r13d
jmp 0x17070
xorl %eax, %eax
movb %al, (%rbx,%rcx)
subl %r13d, %r12d
incl %r12d
movb %al, (%rbx,%r12)
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq *0x707da(%rip)          # 0x87888
testl %eax, %eax
movl -0x2c(%rbp), %edi
je 0x1703c
jmp 0x170bb
pushq $0x1
popq %r12
movl %r12d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq