// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: unixFileControl
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
  unixFile *pFile = (unixFile*)id;
  switch( op ){
#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
    case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: {
      int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE);
      return rc ? SQLITE_IOERR_BEGIN_ATOMIC : SQLITE_OK;
    }
    case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: {
      int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE);
      return rc ? SQLITE_IOERR_COMMIT_ATOMIC : SQLITE_OK;
    }
    case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: {
      int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE);
      return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK;
    }
#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */

    case SQLITE_FCNTL_LOCKSTATE: {
      *(int*)pArg = pFile->eFileLock;
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_LAST_ERRNO: {
      *(int*)pArg = pFile->lastErrno;
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_CHUNK_SIZE: {
      pFile->szChunk = *(int *)pArg;
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_SIZE_HINT: {
      int rc;
      SimulateIOErrorBenign(1);
      rc = fcntlSizeHint(pFile, *(i64 *)pArg);
      SimulateIOErrorBenign(0);
      return rc;
    }
    case SQLITE_FCNTL_PERSIST_WAL: {
      unixModeBit(pFile, UNIXFILE_PERSIST_WAL, (int*)pArg);
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {
      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_VFSNAME: {
      *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_TEMPFILENAME: {
      char *zTFile = sqlite3_malloc64( pFile->pVfs->mxPathname );
      if( zTFile ){
        unixGetTempname(pFile->pVfs->mxPathname, zTFile);
        *(char**)pArg = zTFile;
      }
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_HAS_MOVED: {
      *(int*)pArg = fileHasMoved(pFile);
      return SQLITE_OK;
    }
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
    case SQLITE_FCNTL_LOCK_TIMEOUT: {
      int iOld = pFile->iBusyTimeout;
      pFile->iBusyTimeout = *(int*)pArg;
      *(int*)pArg = iOld;
      return SQLITE_OK;
    }
#endif
#if SQLITE_MAX_MMAP_SIZE>0
    case SQLITE_FCNTL_MMAP_SIZE: {
      i64 newLimit = *(i64*)pArg;
      int rc = SQLITE_OK;
      if( newLimit>sqlite3GlobalConfig.mxMmap ){
        newLimit = sqlite3GlobalConfig.mxMmap;
      }

      /* The value of newLimit may be eventually cast to (size_t) and passed
      ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a
      ** 64-bit type. */
      if( newLimit>0 && sizeof(size_t)<8 ){
        newLimit = (newLimit & 0x7FFFFFFF);
      }

      *(i64*)pArg = pFile->mmapSizeMax;
      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
        pFile->mmapSizeMax = newLimit;
        if( pFile->mmapSize>0 ){
          unixUnmapfile(pFile);
          rc = unixMapfile(pFile, -1);
        }
      }
      return rc;
    }
#endif
#ifdef SQLITE_DEBUG
    /* The pager calls this method to signal that it has done
    ** a rollback and that the database is therefore unchanged and
    ** it hence it is OK for the transaction change counter to be
    ** unchanged.
    */
    case SQLITE_FCNTL_DB_UNCHANGED: {
      ((unixFile*)id)->dbUpdate = 0;
      return SQLITE_OK;
    }
#endif
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
    case SQLITE_FCNTL_SET_LOCKPROXYFILE:
    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {
      return proxyFileControl(id,op,pArg);
    }
#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
  }
  return SQLITE_NOTFOUND;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
pushq $0xc
popq %rbp
decl %esi
cmpl $0x13, %esi
ja 0x22dc91
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x142a90(%rip), %rax    # 0x3705f4
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movzbl 0x1c(%rbx), %eax
jmp 0x22dc8c
movq (%r14), %r14
cmpl $0x0, 0x48(%rbx)
jle 0x22dd08
movl 0x18(%rbx), %edi
leaq 0x8(%rsp), %rsi
callq *0x20cf6f(%rip)         # 0x43ab00
movl $0x70a, %ebp            # imm = 0x70A
testl %eax, %eax
jne 0x22dc91
movslq 0x48(%rbx), %rcx
movq %r14, (%rsp)
leaq (%r14,%rcx), %r15
decq %r15
movq %r15, %rax
cqto
idivq %rcx
subq %rdx, %r15
movq 0x38(%rsp), %rcx
cmpq %rcx, %r15
jle 0x22dd04
movslq 0x40(%rsp), %r14
movq %rcx, %rax
cqto
idivq %r14
movq %rdx, %r12
notq %r12
addq %rcx, %r12
leaq -0x1(%r15), %r13
leaq (%r14,%r15), %rbp
decq %rbp
addq %r14, %r12
cmpq %rbp, %r12
jge 0x22dd04
cmpq %r15, %r12
cmovgeq %r13, %r12
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x13c969(%rip), %rdx    # 0x36a570
pushq $0x1
popq %rcx
callq 0x22e83f
cmpl $0x1, %eax
je 0x22dbe7
movl $0x30a, %ebp            # imm = 0x30A
jmp 0x22dc91
movq 0x8(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x13b27f(%rip), %rdi    # 0x368ea9
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x22132b
movq %rax, (%r14)
jmp 0x22dc91
movl 0x20(%rbx), %eax
jmp 0x22dc8c
pushq $0x10
jmp 0x22dc76
movq 0x8(%rbx), %rax
movslq 0x8(%rax), %rdi
callq 0x21f7df
xorl %ebp, %ebp
testq %rax, %rax
je 0x22dc91
movq %rax, %r15
movq 0x8(%rbx), %rax
movl 0x8(%rax), %edi
movq %r15, %rsi
callq 0x22e9b6
movq %r15, (%r14)
jmp 0x22dc91
movl (%r14), %eax
movl %eax, 0x48(%rbx)
jmp 0x22dc8f
pushq $0x4
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x22e98a
jmp 0x22dc8f
movq %rbx, %rdi
callq 0x22e539
movl %eax, (%r14)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rcx
movq 0x20ca91(%rip), %rax    # 0x43a740
cmpq %rax, %rcx
cmovlq %rcx, %rax
movq 0x60(%rbx), %rcx
movq %rcx, (%r14)
testq %rax, %rax
sets %dl
cmpq %rcx, %rax
sete %cl
xorl %ebp, %ebp
orb %dl, %cl
jne 0x22dc91
cmpl $0x0, 0x4c(%rbx)
jne 0x22dc91
movq %rax, 0x60(%rbx)
cmpq $0x0, 0x50(%rbx)
jle 0x22dc91
movq %rbx, %rdi
callq 0x22e81a
pushq $-0x1
popq %rsi
movq %rbx, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22eaed
movq (%rsp), %r14
xorl %ebp, %ebp
cmpq $0x0, 0x60(%rbx)
jle 0x22dc91
cmpq %r14, 0x50(%rbx)
jge 0x22dc91
cmpl $0x0, 0x48(%rbx)
jle 0x22dd33
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22eaed
movl %eax, %ebp
jmp 0x22dc91
movl 0x18(%rbx), %edi
movq %r14, %rsi
callq 0x22e8bc
testl %eax, %eax
je 0x22dd21
callq 0x17060
movl (%rax), %eax
movl %eax, 0x20(%rbx)
movq 0x38(%rbx), %rdx
leaq 0x1481ae(%rip), %rsi    # 0x375f05
movl $0x60a, %ebp            # imm = 0x60A
movl $0x60a, %edi            # imm = 0x60A
movl $0x924a, %ecx           # imm = 0x924A
callq 0x22e701
jmp 0x22dc91