// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3LoadExtension
static int sqlite3LoadExtension(
  sqlite3 *db,          /* Load the extension into this database connection */
  const char *zFile,    /* Name of the shared library containing extension */
  const char *zProc,    /* Entry point.  Use "sqlite3_extension_init" if 0 */
  char **pzErrMsg       /* Put error message here if not 0 */
){
  sqlite3_vfs *pVfs = db->pVfs;
  void *handle;
  sqlite3_loadext_entry xInit;
  char *zErrmsg = 0;
  const char *zEntry;
  char *zAltEntry = 0;
  void **aHandle;
  u64 nMsg = 300 + sqlite3Strlen30(zFile);
  int ii;
  int rc;

  /* Shared library endings to try if zFile cannot be loaded as written */
  static const char *azEndings[] = {
#if SQLITE_OS_WIN
     "dll"
#elif defined(__APPLE__)
     "dylib"
#else
     "so"
#endif
  };


  if( pzErrMsg ) *pzErrMsg = 0;

  /* Ticket #1863.  To avoid a creating security problems for older
  ** applications that relink against newer versions of SQLite, the
  ** ability to run load_extension is turned off by default.  One
  ** must call either sqlite3_enable_load_extension(db) or
  ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0)
  ** to turn on extension loading.
  */
  if( (db->flags & SQLITE_LoadExtension)==0 ){
    if( pzErrMsg ){
      *pzErrMsg = sqlite3_mprintf("not authorized");
    }
    return SQLITE_ERROR;
  }

  zEntry = zProc ? zProc : "sqlite3_extension_init";

  handle = sqlite3OsDlOpen(pVfs, zFile);
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
    char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
    if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
    handle = sqlite3OsDlOpen(pVfs, zAltFile);
    sqlite3_free(zAltFile);
  }
#endif
  if( handle==0 ){
    if( pzErrMsg ){
      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
      if( zErrmsg ){
        sqlite3_snprintf(nMsg, zErrmsg,
            "unable to open shared library [%s]", zFile);
        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
      }
    }
    return SQLITE_ERROR;
  }
  xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);

  /* If no entry point was specified and the default legacy
  ** entry point name "sqlite3_extension_init" was not found, then
  ** construct an entry point name "sqlite3_X_init" where the X is
  ** replaced by the lowercase value of every ASCII alphabetic
  ** character in the filename after the last "/" upto the first ".",
  ** and eliding the first three characters if they are "lib".
  ** Examples:
  **
  **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example_init
  **    C:/lib/mathfuncs.dll              ==>  sqlite3_mathfuncs_init
  */
  if( xInit==0 && zProc==0 ){
    int iFile, iEntry, c;
    int ncFile = sqlite3Strlen30(zFile);
    zAltEntry = sqlite3_malloc64(ncFile+30);
    if( zAltEntry==0 ){
      sqlite3OsDlClose(pVfs, handle);
      return SQLITE_NOMEM_BKPT;
    }
    memcpy(zAltEntry, "sqlite3_", 8);
    for(iFile=ncFile-1; iFile>=0 && !DirSep(zFile[iFile]); iFile--){}
    iFile++;
    if( sqlite3_strnicmp(zFile+iFile, "lib", 3)==0 ) iFile += 3;
    for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){
      if( sqlite3Isalpha(c) ){
        zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];
      }
    }
    memcpy(zAltEntry+iEntry, "_init", 6);
    zEntry = zAltEntry;
    xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
  }
  if( xInit==0 ){
    if( pzErrMsg ){
      nMsg += sqlite3Strlen30(zEntry);
      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
      if( zErrmsg ){
        sqlite3_snprintf(nMsg, zErrmsg,
            "no entry point [%s] in shared library [%s]", zEntry, zFile);
        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
      }
    }
    sqlite3OsDlClose(pVfs, handle);
    sqlite3_free(zAltEntry);
    return SQLITE_ERROR;
  }
  sqlite3_free(zAltEntry);
  rc = xInit(db, &zErrmsg, &sqlite3Apis);
  if( rc ){
    if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
    if( pzErrMsg ){
      *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
    }
    sqlite3_free(zErrmsg);
    sqlite3OsDlClose(pVfs, handle);
    return SQLITE_ERROR;
  }

  /* Append the new shared library handle to the db->aExtension array. */
  aHandle = sqlite3DbMallocZero(db, sizeof(handle)*(db->nExtension+1));
  if( aHandle==0 ){
    return SQLITE_NOMEM_BKPT;
  }
  if( db->nExtension>0 ){
    memcpy(aHandle, db->aExtension, sizeof(handle)*db->nExtension);
  }
  sqlite3DbFree(db, db->aExtension);
  db->aExtension = aHandle;

  db->aExtension[db->nExtension++] = handle;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3c3400
addl $0x12c, %eax            # imm = 0x12C
cltq
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3cd55c
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
andq $0x10000, %rax          # imm = 0x10000
cmpq $0x0, %rax
jne 0x3cd59b
cmpq $0x0, -0x28(%rbp)
je 0x3cd58f
leaq 0x1df1fb(%rip), %rdi    # 0x5ac779
movb $0x0, %al
callq 0x3c3780
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x3cda7d
cmpq $0x0, -0x20(%rbp)
je 0x3cd5af
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x3cd5bf
leaq 0x1df1d2(%rip), %rax    # 0x5ac788
movq %rax, -0x90(%rbp)
jmp 0x3cd5bf
movq -0x90(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x411eb0
movq %rax, -0x38(%rbp)
movl $0x0, -0x6c(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x6c(%rbp)
movb %al, -0x91(%rbp)
jge 0x3cd5fe
cmpq $0x0, -0x38(%rbp)
sete %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x3cd60a
jmp 0x3cd66a
movq -0x18(%rbp), %rsi
movslq -0x6c(%rbp), %rcx
leaq 0x2729a7(%rip), %rax    # 0x63ffc0
movq (%rax,%rcx,8), %rdx
leaq 0x1585a1(%rip), %rdi    # 0x525bc5
movb $0x0, %al
callq 0x3c3780
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x3cd642
movl $0x7, -0x4(%rbp)
jmp 0x3cda7d
movq -0x30(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x411eb0
movq %rax, -0x38(%rbp)
movq -0x78(%rbp), %rdi
callq 0x3c0800
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x3cd5e2
cmpq $0x0, -0x38(%rbp)
jne 0x3cd6d7
cmpq $0x0, -0x28(%rbp)
je 0x3cd6cb
movq -0x68(%rbp), %rdi
callq 0x3c07c0
movq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x48(%rbp)
je 0x3cd6c9
movq -0x68(%rbp), %rax
movl %eax, %edi
movq -0x48(%rbp), %rsi
movq -0x18(%rbp), %rcx
leaq 0x1df0f4(%rip), %rdx    # 0x5ac79f
movb $0x0, %al
callq 0x3c38c0
movq -0x30(%rbp), %rdi
movq -0x68(%rbp), %rax
subq $0x1, %rax
movl %eax, %esi
movq -0x48(%rbp), %rdx
callq 0x411ee0
jmp 0x3cd6cb
movl $0x1, -0x4(%rbp)
jmp 0x3cda7d
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x411f10
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x3cd8a5
cmpq $0x0, -0x20(%rbp)
jne 0x3cd8a5
movq -0x18(%rbp), %rdi
callq 0x3c3400
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
addl $0x1e, %eax
movslq %eax, %rdi
callq 0x3c07c0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x3cd746
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x411f40
movl $0x7, -0x4(%rbp)
jmp 0x3cda7d
movq -0x58(%rbp), %rax
movq 0x1df071(%rip), %rcx    # 0x5ac7c2
movq %rcx, (%rax)
movl -0x88(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x7c(%rbp)
movb %al, -0x92(%rbp)
jl 0x3cd788
movq -0x18(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
sete %al
xorb $-0x1, %al
movb %al, -0x92(%rbp)
movb -0x92(%rbp), %al
testb $0x1, %al
jne 0x3cd794
jmp 0x3cd7a1
jmp 0x3cd796
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x3cd760
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x7c(%rbp), %rax
addq %rax, %rdi
leaq 0x162afa(%rip), %rsi    # 0x5302b6
movl $0x3, %edx
callq 0x3c3ef0
cmpl $0x0, %eax
jne 0x3cd7d4
movl -0x7c(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x7c(%rbp)
movl $0x8, -0x80(%rbp)
movq -0x18(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movl %ecx, -0x84(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x93(%rbp)
je 0x3cd80a
cmpl $0x2e, -0x84(%rbp)
setne %al
movb %al, -0x93(%rbp)
movb -0x93(%rbp), %al
testb $0x1, %al
jne 0x3cd816
jmp 0x3cd86b
movl -0x84(%rbp), %eax
movzbl %al, %eax
movl %eax, %ecx
leaq 0x1d93a8(%rip), %rax    # 0x5a6bd0
movzbl (%rax,%rcx), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x3cd85b
movl -0x84(%rbp), %eax
movl %eax, %ecx
leaq 0x1d921d(%rip), %rax    # 0x5a6a60
movb (%rax,%rcx), %dl
movq -0x58(%rbp), %rax
movl -0x80(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x80(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x3cd85d
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x3cd7db
movq -0x58(%rbp), %rax
movslq -0x80(%rbp), %rcx
movl 0x16db05(%rip), %edx    # 0x53b37e
movl %edx, (%rax,%rcx)
movw 0x16daff(%rip), %dx     # 0x53b382
movw %dx, 0x4(%rax,%rcx)
movq -0x58(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x411f10
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x3cd943
cmpq $0x0, -0x28(%rbp)
je 0x3cd921
movq -0x50(%rbp), %rdi
callq 0x3c3400
cltq
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x3c07c0
movq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x48(%rbp)
je 0x3cd91f
movq -0x68(%rbp), %rax
movl %eax, %edi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq 0x1deeca(%rip), %rdx    # 0x5ac7cb
movb $0x0, %al
callq 0x3c38c0
movq -0x30(%rbp), %rdi
movq -0x68(%rbp), %rax
subq $0x1, %rax
movl %eax, %esi
movq -0x48(%rbp), %rdx
callq 0x411ee0
jmp 0x3cd921
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x411f40
movq -0x58(%rbp), %rdi
callq 0x3c0800
movl $0x1, -0x4(%rbp)
jmp 0x3cda7d
movq -0x58(%rbp), %rdi
callq 0x3c0800
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq 0x26cbf9(%rip), %rdx    # 0x63a558
callq *%rax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
je 0x3cd9c4
cmpl $0x100, -0x70(%rbp)     # imm = 0x100
jne 0x3cd97f
movl $0x0, -0x4(%rbp)
jmp 0x3cda7d
cmpq $0x0, -0x28(%rbp)
je 0x3cd9a2
movq -0x48(%rbp), %rsi
leaq 0x1dee65(%rip), %rdi    # 0x5ac7f6
movb $0x0, %al
callq 0x3c3780
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rdi
callq 0x3c0800
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x411f40
movl $0x1, -0x4(%rbp)
jmp 0x3cda7d
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xd4(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x3c9520
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x3cd9f8
movl $0x7, -0x4(%rbp)
jmp 0x3cda7d
movq -0x10(%rbp), %rax
cmpl $0x0, 0xd4(%rax)
jle 0x3cda28
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0xd4(%rax), %rdx
shlq $0x3, %rdx
callq 0x19610
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
callq 0x3c00a0
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xd8(%rax)
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rax
movq -0x10(%rbp), %rsi
movl 0xd4(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0xd4(%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)