// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: findInodeInfo
static int findInodeInfo(
  unixFile *pFile,               /* Unix file with file desc used in the key */
  unixInodeInfo **ppInode        /* Return the unixInodeInfo object here */
){
  int rc;                        /* System call return code */
  int fd;                        /* The file descriptor for pFile */
  struct unixFileId fileId;      /* Lookup key for the unixInodeInfo */
  struct stat statbuf;           /* Low-level file information */
  unixInodeInfo *pInode = 0;     /* Candidate unixInodeInfo object */

  assert( unixMutexHeld() );

  /* Get low-level information about the file that we can used to
  ** create a unique name for the file.
  */
  fd = pFile->h;
  rc = osFstat(fd, &statbuf);
  if( rc!=0 ){
    pFile->lastErrno = errno;
#ifdef EOVERFLOW
    if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS;
#endif
    return SQLITE_IOERR;
  }

#ifdef __APPLE__
  /* On OS X on an msdos filesystem, the inode number is reported
  ** incorrectly for zero-size files.  See ticket #3260.  To work
  ** around this problem (we consider it a bug in OS X, not SQLite)
  ** we always increase the file size to 1 by writing a single byte
  ** prior to accessing the inode number.  The one byte written is
  ** an ASCII 'S' character which also happens to be the first byte
  ** in the header of every SQLite database.  In this way, if there
  ** is a race condition such that another thread has already populated
  ** the first page of the database, no damage is done.
  */
  if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){
    do{ rc = osWrite(fd, "S", 1); }while( rc<0 && errno==EINTR );
    if( rc!=1 ){
      pFile->lastErrno = errno;
      return SQLITE_IOERR;
    }
    rc = osFstat(fd, &statbuf);
    if( rc!=0 ){
      pFile->lastErrno = errno;
      return SQLITE_IOERR;
    }
  }
#endif

  memset(&fileId, 0, sizeof(fileId));
  fileId.dev = statbuf.st_dev;
#if OS_VXWORKS
  fileId.pId = pFile->pId;
#else
  fileId.ino = statbuf.st_ino;
#endif
  pInode = inodeList;
  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
    pInode = pInode->pNext;
  }
  if( pInode==0 ){
    pInode = sqlite3_malloc( sizeof(*pInode) );
    if( pInode==0 ){
      return SQLITE_NOMEM;
    }
    memset(pInode, 0, sizeof(*pInode));
    memcpy(&pInode->fileId, &fileId, sizeof(fileId));
    pInode->nRef = 1;
    pInode->pNext = inodeList;
    pInode->pPrev = 0;
    if( inodeList ) inodeList->pPrev = pInode;
    inodeList = pInode;
  }else{
    pInode->nRef++;
  }
  *ppInode = pInode;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x20(%rbp)
movq 0xb1781(%rip), %rax     # 0xd0960
movl -0x20(%rbp), %edi
leaq -0xc0(%rbp), %rsi
callq *%rax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x1f224
callq 0x8060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpl $0x4b, 0x20(%rax)
jne 0x1f218
movl $0x16, -0x4(%rbp)
jmp 0x1f395
movl $0xa, -0x4(%rbp)
jmp 0x1f395
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x8200
movq -0xc0(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0xb2e1f(%rip), %rax     # 0xd2070
movq %rax, -0xc8(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xc8(%rbp)
movb %al, -0xc9(%rbp)
je 0x1f297
movq -0xc8(%rbp), %rax
movups (%rax), %xmm1
movups -0x30(%rbp), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x1f2a3
jmp 0x1f2b7
movq -0xc8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0xc8(%rbp)
jmp 0x1f258
cmpq $0x0, -0xc8(%rbp)
jne 0x1f370
movl $0x48, %edi
callq 0xa380
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
jne 0x1f2ec
movl $0x7, -0x4(%rbp)
jmp 0x1f395
movq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x8200
movq -0xc8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xc8(%rbp), %rax
movl $0x1, 0x18(%rax)
movq 0xb2d46(%rip), %rcx     # 0xd2070
movq -0xc8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0xc8(%rbp), %rax
movq $0x0, 0x40(%rax)
cmpq $0x0, 0xb2d24(%rip)     # 0xd2070
je 0x1f360
movq -0xc8(%rbp), %rcx
movq 0xb2d14(%rip), %rax     # 0xd2070
movq %rcx, 0x40(%rax)
movq -0xc8(%rbp), %rax
movq %rax, 0xb2d02(%rip)     # 0xd2070
jmp 0x1f380
movq -0xc8(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0xc8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)