// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: fcntlSizeHint
static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  if( pFile->szChunk>0 ){
    i64 nSize;                    /* Required file size */
    struct stat buf;              /* Used to hold return values of fstat() */
   
    if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;

    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
    if( nSize>(i64)buf.st_size ){

#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
      /* The code below is handling the return value of osFallocate() 
      ** correctly. posix_fallocate() is defined to "returns zero on success, 
      ** or an error number on  failure". See the manpage for details. */
      int err;
      do{
        err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);
      }while( err==EINTR );
      if( err ) return SQLITE_IOERR_WRITE;
#else
      /* If the OS does not have posix_fallocate(), fake it. First use
      ** ftruncate() to set the file size, then write a single byte to
      ** the last byte in each block within the extended region. This
      ** is the same technique used by glibc to implement posix_fallocate()
      ** on systems that do not have a real fallocate() system call.
      */
      int nBlk = buf.st_blksize;  /* File-system block size */
      i64 iWrite;                 /* Next offset to write to */

      if( robust_ftruncate(pFile->h, nSize) ){
        pFile->lastErrno = errno;
        return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
      }
      iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
      while( iWrite<nSize ){
        int nWrite = seekAndWrite(pFile, iWrite, "", 1);
        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
        iWrite += nBlk;
      }
#endif
    }
  }

  if( pFile->mmapSizeMax>0 && nByte>pFile->mmapSize ){
    int rc;
    if( pFile->szChunk<=0 ){
      if( robust_ftruncate(pFile->h, nByte) ){
        pFile->lastErrno = errno;
        return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
      }
    }

    rc = unixMapfile(pFile, nByte);
    return rc;
  }

  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jle 0x1e2b1
movq 0xb27f8(%rip), %rax     # 0xd0960
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %edi
leaq -0xb0(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
je 0x1e189
movl $0x70a, -0x4(%rbp)      # imm = 0x70A
jmp 0x1e341
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x48(%rcx), %rcx
addq %rcx, %rax
subq $0x1, %rax
movq -0x10(%rbp), %rcx
movslq 0x48(%rcx), %rcx
cqto
idivq %rcx
movq -0x10(%rbp), %rcx
movslq 0x48(%rcx), %rcx
imulq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0x1e2af
movq -0x78(%rbp), %rax
movl %eax, -0xb4(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edi
movq -0x20(%rbp), %rsi
callq 0x1dd60
cmpl $0x0, %eax
je 0x1e21a
callq 0x8060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdx
movl $0x60a, %edi            # imm = 0x60A
leaq 0x8ff32(%rip), %rsi     # 0xae13a
movl $0x686d, %ecx           # imm = 0x686D
callq 0x1d930
movl %eax, -0x4(%rbp)
jmp 0x1e341
movq -0x80(%rbp), %rax
movl -0xb4(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
addq %rcx, %rax
subq $0x1, %rax
movslq -0xb4(%rbp), %rcx
cqto
idivq %rcx
movslq -0xb4(%rbp), %rcx
imulq %rcx, %rax
subq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x1e2ad
movq -0x10(%rbp), %rdi
movq -0xc0(%rbp), %rsi
leaq 0x94b84(%rip), %rdx     # 0xb2df5
movl $0x1, %ecx
callq 0x1dc40
movl %eax, -0xc4(%rbp)
cmpl $0x1, -0xc4(%rbp)
je 0x1e296
movl $0x30a, -0x4(%rbp)      # imm = 0x30A
jmp 0x1e341
movslq -0xb4(%rbp), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x1e252
jmp 0x1e2af
jmp 0x1e2b1
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jle 0x1e33a
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jle 0x1e33a
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jg 0x1e31c
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x1dd60
cmpl $0x0, %eax
je 0x1e31a
callq 0x8060
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdx
movl $0x60a, %edi            # imm = 0x60A
leaq 0x8fe2f(%rip), %rsi     # 0xae13a
movl $0x687e, %ecx           # imm = 0x687E
callq 0x1d930
movl %eax, -0x4(%rbp)
jmp 0x1e341
jmp 0x1e31c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e4f0
movl %eax, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1e341
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)