// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixFileControl
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
  unixFile *pFile = (unixFile*)id;
  switch( op ){
    case SQLITE_FCNTL_LOCKSTATE: {
      *(int*)pArg = pFile->eFileLock;
      return SQLITE_OK;
    }
    case SQLITE_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_malloc( pFile->pVfs->mxPathname );
      if( zTFile ){
        unixGetTempname(pFile->pVfs->mxPathname, zTFile);
        *(char**)pArg = zTFile;
      }
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_MMAP_SIZE: {
      i64 newLimit = *(i64*)pArg;
      int rc = SQLITE_OK;
      if( newLimit>sqlite3GlobalConfig.mxMmap ){
        newLimit = sqlite3GlobalConfig.mxMmap;
      }
      *(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;
    }
#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_SET_LOCKPROXYFILE:
    case SQLITE_GET_LOCKPROXYFILE: {
      return proxyFileControl(id,op,pArg);
    }
#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
  }
  return SQLITE_NOTFOUND;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl $0xc, %r14d
decl %esi
cmpl $0x11, %esi
ja 0x18124
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x5d29d(%rip), %rax     # 0x75150
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movzbl 0x1c(%rbx), %eax
jmp 0x18082
movq (%r15), %r15
cmpl $0x0, 0x48(%rbx)
jle 0x17ef6
movl 0x18(%rbx), %edi
leaq -0xc8(%rbp), %rsi
callq *0x7c9f2(%rip)          # 0x948d0
testl %eax, %eax
je 0x1808a
movl $0x70a, %r14d           # imm = 0x70A
xorl %eax, %eax
testb %al, %al
je 0x18124
xorl %r14d, %r14d
cmpq $0x0, 0x60(%rbx)
jle 0x18124
cmpq %r15, 0x50(%rbx)
jge 0x18124
cmpl $0x0, 0x48(%rbx)
jle 0x18140
movq %rbx, %rdi
movq %r15, %rsi
callq 0x19275
movl %eax, %r14d
jmp 0x18124
movq 0x8(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x6179f(%rip), %rdi     # 0x796d9
xorl %r14d, %r14d
xorl %eax, %eax
callq 0xb76d
movq %rax, (%r15)
jmp 0x18124
movl 0x20(%rbx), %eax
jmp 0x18082
cmpl $0x0, (%r15)
js 0x18044
movzwl 0x1e(%rbx), %eax
je 0x18111
orl $0x10, %eax
jmp 0x1811d
movq 0x8(%rbx), %rax
movl 0x8(%rax), %r12d
callq 0x9d1f
xorl %r14d, %r14d
testl %eax, %eax
je 0x1804d
xorl %r12d, %r12d
jmp 0x18058
movl (%r15), %eax
movl %eax, 0x48(%rbx)
jmp 0x18121
cmpl $0x0, (%r15)
js 0x18078
movzwl 0x1e(%rbx), %eax
je 0x18118
orl $0x4, %eax
jmp 0x1811d
movq (%r15), %rcx
movq 0x7c56f(%rip), %rax     # 0x94530
cmpq %rax, %rcx
cmovlq %rcx, %rax
movq 0x60(%rbx), %rcx
movq %rcx, (%r15)
xorl %r14d, %r14d
testq %rax, %rax
js 0x18124
cmpq 0x60(%rbx), %rax
je 0x18124
cmpl $0x0, 0x4c(%rbx)
jne 0x18124
movq %rax, 0x60(%rbx)
cmpq $0x0, 0x50(%rbx)
jle 0x18124
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x18024
leaq 0x50(%rbx), %r14
movq 0x58(%rbx), %rsi
callq *0x7ca53(%rip)          # 0x94a68
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 0x19275
movzwl 0x1e(%rbx), %eax
shrl $0x4, %eax
jmp 0x1807f
movl %r12d, %edi
callq 0xa2a2
movq %rax, %r12
testq %r12, %r12
je 0x18124
movq 0x8(%rbx), %rax
movl 0x8(%rax), %edi
movq %r12, %rsi
callq 0x190f8
movq %r12, (%r15)
jmp 0x18124
movzwl 0x1e(%rbx), %eax
shrl $0x2, %eax
andl $0x1, %eax
movl %eax, (%r15)
jmp 0x18121
movslq 0x48(%rbx), %rcx
leaq (%r15,%rcx), %r12
decq %r12
movq %r12, %rax
cqto
idivq %rcx
subq %rdx, %r12
cmpq -0x98(%rbp), %r12
jle 0x18139
movq -0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
movl 0x18(%rbx), %r14d
movl %r14d, %edi
movq %r12, %rsi
callq *0x7c820(%rip)          # 0x948e8
movl %eax, %r13d
testl %eax, %eax
jns 0x180d9
callq 0x8060
cmpl $0x4, (%rax)
je 0x180bc
testl %r13d, %r13d
je 0x18196
callq 0x8060
movl (%rax), %eax
movl %eax, 0x20(%rbx)
movq 0x38(%rbx), %rdx
leaq 0x6154c(%rip), %rsi     # 0x79643
movl $0x60a, %r14d           # imm = 0x60A
movl $0x60a, %edi            # imm = 0x60A
movl $0x686d, %ecx           # imm = 0x686D
callq 0x18ea3
jmp 0x17eec
andl $0xffef, %eax           # imm = 0xFFEF
jmp 0x1811d
andl $0xfffb, %eax           # imm = 0xFFFB
movw %ax, 0x1e(%rbx)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
jmp 0x17eee
movl 0x18(%rbx), %r14d
movl %r14d, %edi
movq %r15, %rsi
callq *0x7c798(%rip)          # 0x948e8
movl %eax, %r12d
testl %eax, %eax
jns 0x18161
callq 0x8060
cmpl $0x4, (%rax)
je 0x18144
testl %r12d, %r12d
je 0x17f18
callq 0x8060
movl (%rax), %eax
movl %eax, 0x20(%rbx)
movq 0x38(%rbx), %rdx
leaq 0x614c4(%rip), %rsi     # 0x79643
movl $0x60a, %r14d           # imm = 0x60A
movl $0x60a, %edi            # imm = 0x60A
movl $0x687e, %ecx           # imm = 0x687E
callq 0x18ea3
jmp 0x18124
movq -0x30(%rbp), %rdx
leal (%rdx,%rdx), %eax
movslq %eax, %rcx
addq -0x98(%rbp), %rcx
leaq -0x1(%rcx), %rax
movslq %edx, %rsi
cqto
movq %rsi, -0x30(%rbp)
idivq %rsi
notq %rdx
leaq (%rcx,%rdx), %r13
decq %r13
leaq 0x20(%rbx), %rax
movq %rax, -0x38(%rbp)
movl $0x30a, %r14d           # imm = 0x30A
cmpq %r12, %r13
setge %al
jge 0x17eee
movl 0x18(%rbx), %edi
movq %r13, %rsi
leaq 0x66178(%rip), %rdx     # 0x7e360
movl $0x1, %ecx
movq -0x38(%rbp), %r8
callq 0x18f86
addq -0x30(%rbp), %r13
cmpl $0x1, %eax
je 0x181c9
jmp 0x17eec