// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: fillInUnixFile
static int fillInUnixFile(
  unqlite_vfs *pVfs,      /* Pointer to vfs object */
  int h,                  /* Open file descriptor of file being opened */
  int dirfd,              /* Directory file descriptor */
  unqlite_file *pId,      /* Write to the unixFile structure here */
  const char *zFilename,  /* Name of the file being opened */
  int noLock,             /* Omit locking if true */
  int isDelete            /* Delete on close if true */
){
  const unqlite_io_methods *pLockingStyle = &unixIoMethod;
  unixFile *pNew = (unixFile *)pId;
  int rc = UNQLITE_OK;

  /* Parameter isDelete is only used on vxworks. Express this explicitly 
  ** here to prevent compiler warnings about unused parameters.
  */
  SXUNUSED(isDelete);
  SXUNUSED(noLock);
  SXUNUSED(pVfs);

  pNew->h = h;
  pNew->dirfd = dirfd;
  pNew->fileFlags = 0;
  pNew->zPath = zFilename;
  
  unixEnterMutex();
  rc = findInodeInfo(pNew, &pNew->pInode);
  if( rc!=UNQLITE_OK ){
      /* If an error occured in findInodeInfo(), close the file descriptor
      ** immediately, before releasing the mutex. findInodeInfo() may fail
      ** in two scenarios:
      **
      **   (a) A call to fstat() failed.
      **   (b) A malloc failed.
      **
      ** Scenario (b) may only occur if the process is holding no other
      ** file descriptors open on the same file. If there were other file
      ** descriptors on this file, then no malloc would be required by
      ** findInodeInfo(). If this is the case, it is quite safe to close
      ** handle h - as it is guaranteed that no posix locks will be released
      ** by doing so.
      **
      ** If scenario (a) caused the error then things are not so safe. The
      ** implicit assumption here is that if fstat() fails, things are in
      ** such bad shape that dropping a lock or two doesn't matter much.
      */
      close(h);
      h = -1;
  }
  unixLeaveMutex();
  
  pNew->lastErrno = 0;
  if( rc!=UNQLITE_OK ){
    if( dirfd>=0 ) close(dirfd); /* silent leak if fail, already in error */
    if( h>=0 ) close(h);
  }else{
    pNew->pMethod = pLockingStyle;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
leaq 0x8f118(%rip), %rax     # 0xeaed0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, 0x10(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x8(%rbp)
movl -0xc(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x10(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x38(%rax)
callq 0x5bec0
movq -0x38(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x8, %rsi
callq 0x5c170
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x5be3a
movl -0xc(%rbp), %edi
callq 0xd350
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
callq 0x5bf10
movq -0x38(%rbp), %rax
movl $0x0, 0x1c(%rax)
cmpl $0x0, -0x3c(%rbp)
je 0x5be6e
cmpl $0x0, -0x10(%rbp)
jl 0x5be5e
movl -0x10(%rbp), %edi
callq 0xd350
cmpl $0x0, -0xc(%rbp)
jl 0x5be6c
movl -0xc(%rbp), %edi
callq 0xd350
jmp 0x5be79
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl -0x3c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)