// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/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 && err!=EINVAL ) return SQLITE_IOERR_WRITE;
#else
      /* If the OS does not have posix_fallocate(), fake it. Write a
      ** single byte to the last byte in each block that falls entirely
      ** within the extended region. Then, if required, a single byte
      ** at offset (nSize-1), to set the size of the file correctly.
      ** This is a similar technique to that used by glibc on systems
      ** that do not have a real fallocate() call.
      */
      int nBlk = buf.st_blksize;  /* File-system block size */
      int nWrite = 0;             /* Number of bytes written by seekAndWrite */
      i64 iWrite;                 /* Next offset to write to */

      iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1;
      assert( iWrite>=buf.st_size );
      assert( ((iWrite+1)%nBlk)==0 );
      for(/*no-op*/; iWrite<nSize+nBlk-1; iWrite+=nBlk ){
        if( iWrite>=nSize ) iWrite = nSize - 1;
        nWrite = seekAndWrite(pFile, iWrite, "", 1);
        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
      }
#endif
    }
  }

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

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

  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 0x3d89ec
movq 0x267488(%rip), %rax    # 0x63fd40
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %edi
leaq -0xb0(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
je 0x3d88d9
movl $0x70a, -0x4(%rbp)      # imm = 0x70A
jmp 0x3d8a94
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 0x3d89ea
movq -0x78(%rbp), %rax
movl %eax, -0xb4(%rbp)
movl $0x0, -0xb8(%rbp)
movq -0x80(%rbp), %rax
movslq -0xb4(%rbp), %rcx
cqto
idivq %rcx
movslq -0xb4(%rbp), %rcx
imulq %rcx, %rax
movslq -0xb4(%rbp), %rcx
addq %rcx, %rax
subq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq -0xb4(%rbp), %rdx
addq %rdx, %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0x3d89e8
movq -0xc0(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x3d8995
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq -0xc0(%rbp), %rsi
leaq 0x1c4c81(%rip), %rdx    # 0x59d628
movl $0x1, %ecx
callq 0x3d83e0
movl %eax, -0xb8(%rbp)
cmpl $0x1, -0xb8(%rbp)
je 0x3d89cc
movl $0x30a, -0x4(%rbp)      # imm = 0x30A
jmp 0x3d8a94
jmp 0x3d89ce
movslq -0xb4(%rbp), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x3d895b
jmp 0x3d89ea
jmp 0x3d89ec
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jle 0x3d8a8d
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jle 0x3d8a8d
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jg 0x3d8a6f
movq -0x10(%rbp), %rax
movl 0x18(%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x3d84d0
cmpl $0x0, %eax
je 0x3d8a6d
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0x19060
movq -0xd0(%rbp), %rdi
movl (%rax), %esi
callq 0x3d83c0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdx
movl $0x60a, %edi            # imm = 0x60A
leaq 0x1d2506(%rip), %rsi    # 0x5aaf64
movl $0x924a, %ecx           # imm = 0x924A
callq 0x3d8070
movl %eax, -0x4(%rbp)
jmp 0x3d8a94
jmp 0x3d8a6f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3d8c00
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3d8a94
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq