// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: findReusableFd
static UnixUnusedFd *findReusableFd(const char *zPath, int flags){
  UnixUnusedFd *pUnused = 0;

  /* Do not search for an unused file descriptor on vxworks. Not because
  ** vxworks would not benefit from the change (it might, we're not sure),
  ** but because no way to test it is currently available. It is better 
  ** not to risk breaking vxworks support for the sake of such an obscure 
  ** feature.  */
#if !OS_VXWORKS
  struct stat sStat;                   /* Results of stat() call */

  /* A stat() call may fail for various reasons. If this happens, it is
  ** almost certain that an open() call on the same path will also fail.
  ** For this reason, if an error occurs in the stat() call here, it is
  ** ignored and -1 is returned. The caller will try to open a new file
  ** descriptor on the same path, fail, and return an error to SQLite.
  **
  ** Even if a subsequent open() call does succeed, the consequences of
  ** not searching for a resusable file descriptor are not dire.  */
  if( 0==osStat(zPath, &sStat) ){
    unixInodeInfo *pInode;

    unixEnterMutex();
    pInode = inodeList;
    while( pInode && (pInode->fileId.dev!=sStat.st_dev
                     || pInode->fileId.ino!=sStat.st_ino) ){
       pInode = pInode->pNext;
    }
    if( pInode ){
      UnixUnusedFd **pp;
      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
      pUnused = *pp;
      if( pUnused ){
        *pp = pUnused->pNext;
      }
    }
    unixLeaveMutex();
  }
#endif    /* if !OS_VXWORKS */
  return pUnused;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movq 0xb1c17(%rip), %rax     # 0xd0948
movq -0x8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq *%rax
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1ee72
callq 0x1d540
movq 0xb331a(%rip), %rax     # 0xd2070
movq %rax, -0xb0(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xb0(%rbp)
movb %al, -0xb9(%rbp)
je 0x1edb1
movq -0xb0(%rbp), %rax
movq (%rax), %rcx
movb $0x1, %al
cmpq -0xa8(%rbp), %rcx
movb %al, -0xba(%rbp)
jne 0x1eda5
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0xa0(%rbp), %rax
setne %al
movb %al, -0xba(%rbp)
movb -0xba(%rbp), %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x1edbd
jmp 0x1edd1
movq -0xb0(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x1ed5d
cmpq $0x0, -0xb0(%rbp)
je 0x1ee6d
movq -0xb0(%rbp), %rax
addq $0x30, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0xbb(%rbp)
je 0x1ee1f
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
cmpl -0xc(%rbp), %eax
setne %al
movb %al, -0xbb(%rbp)
movb -0xbb(%rbp), %al
testb $0x1, %al
jne 0x1ee2b
jmp 0x1ee44
jmp 0x1ee2d
movq -0xb8(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, -0xb8(%rbp)
jmp 0x1edf1
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1ee6b
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1ee6d
callq 0x1d6c0
movq -0x18(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nop