// File: /workspace/github_c_makefile_star2_O3/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 $0xa8, %rsp
movl $0xc, %ebp
decl %esi
cmpl $0x13, %esi
ja 0x2836fe
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x14cd79(%rip), %rax    # 0x3d01e4
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movzbl 0x1c(%rbx), %eax
jmp 0x2836e7
movq (%r14), %r14
cmpl $0x0, 0x48(%rbx)
jle 0x28352f
movl 0x18(%rbx), %edi
leaq 0x18(%rsp), %rsi
callq *0x2386b8(%rip)         # 0x4bbb50
movl $0x70a, %ebp            # imm = 0x70A
testl %eax, %eax
jne 0x2836fe
movslq 0x48(%rbx), %rcx
leaq (%r14,%rcx), %r15
decq %r15
movq %r15, %rax
cqto
idivq %rcx
subq %rdx, %r15
movq 0x48(%rsp), %r12
cmpq %r12, %r15
jle 0x28352f
movslq 0x50(%rsp), %rbp
movq %r12, %rax
cqto
idivq %rbp
notq %rdx
addq %rbp, %r12
addq %rdx, %r12
leaq (%r15,%rbp), %r13
decq %r13
cmpq %r13, %r12
jge 0x28352f
leaq -0x1(%r15), %rax
movq %rax, 0x10(%rsp)
leaq 0x20(%rbx), %rax
movq %rax, 0x8(%rsp)
cmpq %r15, %r12
cmovgeq 0x10(%rsp), %r12
movl 0x18(%rbx), %edi
movq %r12, %rsi
leaq 0x146c61(%rip), %rdx    # 0x3ca170
movl $0x1, %ecx
movq 0x8(%rsp), %r8
callq 0x2843c9
cmpl $0x1, %eax
jne 0x283763
addq %rbp, %r12
cmpq %r13, %r12
jl 0x2834f9
xorl %ebp, %ebp
cmpq $0x0, 0x60(%rbx)
jle 0x2836fe
cmpq %r14, 0x50(%rbx)
jge 0x2836fe
cmpl $0x0, 0x48(%rbx)
jle 0x283712
movq %rbx, %rdi
movq %r14, %rsi
callq 0x28461e
movl %eax, %ebp
jmp 0x2836fe
movq 0x8(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x145538(%rip), %rdi    # 0x3c8aa9
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x274b53
movq %rax, (%r14)
jmp 0x2836fe
movl 0x20(%rbx), %eax
jmp 0x2836e7
cmpl $0x0, (%r14)
js 0x2836d4
movzwl 0x1e(%rbx), %eax
je 0x2836ec
orl $0x10, %eax
jmp 0x2836f8
movq 0x8(%rbx), %rax
movslq 0x8(%rax), %r15
callq 0x2725a7
xorl %ebp, %ebp
testl %eax, %eax
jne 0x2836fe
movq %r15, %rdi
callq 0x272ae6
testq %rax, %rax
je 0x2836fe
movq %rax, %r15
movq 0x8(%rbx), %rax
movl 0x8(%rax), %edi
movq %r15, %rsi
callq 0x2844e6
movq %r15, (%r14)
jmp 0x2836fe
movl (%r14), %eax
movl %eax, 0x48(%rbx)
jmp 0x2836fc
cmpl $0x0, (%r14)
js 0x2836dd
movzwl 0x1e(%rbx), %eax
je 0x2836f3
orl $0x4, %eax
jmp 0x2836f8
xorl %ebp, %ebp
cmpq $0x0, 0x10(%rbx)
movl $0x0, %ecx
je 0x283647
movq 0x38(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq *0x23850c(%rip)         # 0x4bbb38
movl $0x1, %ecx
testl %eax, %eax
jne 0x283647
movq 0x20(%rsp), %rax
movq 0x10(%rbx), %rdx
xorl %ecx, %ecx
cmpq 0x8(%rdx), %rax
setne %cl
movl %ecx, (%r14)
jmp 0x2836fe
movq (%r14), %rcx
movq 0x238137(%rip), %rax    # 0x4bb790
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 0x2836fe
cmpl $0x0, 0x4c(%rbx)
jne 0x2836fe
movq %rax, 0x60(%rbx)
cmpq $0x0, 0x50(%rbx)
jle 0x2836fe
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x2836b4
leaq 0x50(%rbx), %r14
movq 0x58(%rbx), %rsi
callq *0x23865b(%rip)         # 0x4bbd00
movq $0x0, 0x68(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq %rbx, %rdi
movq $-0x1, %rsi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x28461e
movzwl 0x1e(%rbx), %eax
shrl $0x4, %eax
jmp 0x2836e4
movzwl 0x1e(%rbx), %eax
shrl $0x2, %eax
andl $0x1, %eax
movl %eax, (%r14)
jmp 0x2836fc
andl $0xffef, %eax           # imm = 0xFFEF
jmp 0x2836f8
andl $0xfffb, %eax           # imm = 0xFFFB
movw %ax, 0x1e(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x18(%rbx), %ebp
movl %ebp, %edi
movq %r14, %rsi
callq *0x238448(%rip)         # 0x4bbb68
testl %eax, %eax
jns 0x283732
callq 0x17060
movl (%rax), %eax
cmpl $0x4, %eax
je 0x283715
jmp 0x28373f
je 0x283550
callq 0x17060
movl (%rax), %eax
movl %eax, 0x20(%rbx)
movq 0x38(%rbx), %rdx
leaq 0x152398(%rip), %rsi    # 0x3d5ae5
movl $0x60a, %ebp            # imm = 0x60A
movl $0x60a, %edi            # imm = 0x60A
movl $0x924a, %ecx           # imm = 0x924A
callq 0x2842dc
jmp 0x2836fe
movl $0x30a, %ebp            # imm = 0x30A
jmp 0x2836fe