// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.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 */

  /* Get low-level information about the file that we can used to
  ** create a unique name for the file.
  */
  fd = pFile->h;
  rc = fstat(fd, &statbuf);
  if( rc!=0 ){
    pFile->lastErrno = errno;
#ifdef EOVERFLOW
	if( pFile->lastErrno==EOVERFLOW ) return UNQLITE_NOTIMPLEMENTED;
#endif
    return UNQLITE_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 & UNQLITE_FSFLAGS_IS_MSDOS)!=0 ){
    rc = write(fd, "S", 1);
    if( rc!=1 ){
      pFile->lastErrno = errno;
      return UNQLITE_IOERR;
    }
    rc = fstat(fd, &statbuf);
    if( rc!=0 ){
      pFile->lastErrno = errno;
      return UNQLITE_IOERR;
    }
  }
#endif
  SyZero(&fileId,sizeof(fileId));
  fileId.dev = statbuf.st_dev;
  fileId.ino = statbuf.st_ino;
  pInode = inodeList;
  while( pInode && SyMemcmp((const void *)&fileId,(const void *)&pInode->fileId, sizeof(fileId)) ){
    pInode = pInode->pNext;
  }
  if( pInode==0 ){
    pInode = (unixInodeInfo *)unqlite_malloc( sizeof(*pInode) );
    if( pInode==0 ){
      return UNQLITE_NOMEM;
    }
    SyZero(pInode,sizeof(*pInode));
	SyMemcpy((const void *)&fileId,(void *)&pInode->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 UNQLITE_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 0x10(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edi
leaq -0xc0(%rbp), %rsi
callq 0xdb20
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x5c1e0
callq 0xdcc0
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
cmpl $0x4b, 0x1c(%rax)
jne 0x5c1d4
movl $0xffffffef, -0x4(%rbp) # imm = 0xFFFFFFEF
jmp 0x5c340
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5c340
leaq -0x30(%rbp), %rdi
movl $0x10, %esi
callq 0x54280
movq -0xc0(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0x932c5(%rip), %rax     # 0xef4d0
movq %rax, -0xc8(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xc8(%rbp)
movb %al, -0xc9(%rbp)
je 0x5c245
movq -0xc8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movl $0x10, %edx
callq 0x5d3c0
cmpl $0x0, %eax
setne %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x5c251
jmp 0x5c265
movq -0xc8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc8(%rbp)
jmp 0x5c212
cmpq $0x0, -0xc8(%rbp)
jne 0x5c31b
movl $0x38, %edi
callq 0x5bc10
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
jne 0x5c29a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5c340
movq -0xc8(%rbp), %rdi
movl $0x38, %esi
callq 0x54280
movq -0xc8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movl $0x10, %edx
callq 0x5d570
movq -0xc8(%rbp), %rax
movl $0x1, 0x18(%rax)
movq 0x931fb(%rip), %rcx     # 0xef4d0
movq -0xc8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0xc8(%rbp), %rax
movq $0x0, 0x30(%rax)
cmpq $0x0, 0x931d9(%rip)     # 0xef4d0
je 0x5c30b
movq -0xc8(%rbp), %rcx
movq 0x931c9(%rip), %rax     # 0xef4d0
movq %rcx, 0x30(%rax)
movq -0xc8(%rbp), %rax
movq %rax, 0x931b7(%rip)     # 0xef4d0
jmp 0x5c32b
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
nopl (%rax)