// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/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;
  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
  char *zErrmsg = 0;
  const char *zEntry;
  char *zAltEntry = 0;
  void **aHandle;
  int nMsg = 300 + sqlite3Strlen30(zFile);
  int ii;

  /* 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 sqlite3_enable_load_extension() to turn on extension
  ** loading.  Otherwise you get the following error.
  */
  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;
    handle = sqlite3OsDlOpen(pVfs, zAltFile);
    sqlite3_free(zAltFile);
  }
#endif
  if( handle==0 ){
    if( pzErrMsg ){
      *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
      if( zErrmsg ){
        sqlite3_snprintf(nMsg, zErrmsg, 
            "unable to open shared library [%s]", zFile);
        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
      }
    }
    return SQLITE_ERROR;
  }
  xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
                   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_malloc(ncFile+30);
    if( zAltEntry==0 ){
      sqlite3OsDlClose(pVfs, handle);
      return SQLITE_NOMEM;
    }
    memcpy(zAltEntry, "sqlite3_", 8);
    for(iFile=ncFile-1; iFile>=0 && 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 = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
                     sqlite3OsDlSym(pVfs, handle, zEntry);
  }
  if( xInit==0 ){
    if( pzErrMsg ){
      nMsg += sqlite3Strlen30(zEntry);
      *pzErrMsg = zErrmsg = sqlite3_malloc(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);
  if( xInit(db, &zErrmsg, &sqlite3Apis) ){
    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;
  }
  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 $0x90, %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 0xbcc0
addl $0x12c, %eax            # imm = 0x12C
movl %eax, -0x64(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x18899
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
andl $0x400000, %eax         # imm = 0x400000
cmpl $0x0, %eax
jne 0x188d5
cmpq $0x0, -0x28(%rbp)
je 0x188c9
leaq 0x81b12(%rip), %rdi     # 0x9a3ca
movb $0x0, %al
callq 0xf0e0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x18d71
cmpq $0x0, -0x20(%rbp)
je 0x188e9
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x188f9
leaq 0x81ae9(%rip), %rax     # 0x9a3d9
movq %rax, -0x88(%rbp)
jmp 0x188f9
movq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4fe60
movq %rax, -0x38(%rbp)
movl $0x0, -0x68(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x68(%rbp)
movb %al, -0x89(%rbp)
jge 0x18938
cmpq $0x0, -0x38(%rbp)
sete %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x18944
jmp 0x189a4
movq -0x18(%rbp), %rsi
movslq -0x68(%rbp), %rcx
leaq 0x9a06d(%rip), %rax     # 0xb29c0
movq (%rax,%rcx,8), %rdx
leaq 0x81993(%rip), %rdi     # 0x9a2f1
movb $0x0, %al
callq 0xf0e0
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x1897c
movl $0x7, -0x4(%rbp)
jmp 0x18d71
movq -0x30(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x4fe60
movq %rax, -0x38(%rbp)
movq -0x70(%rbp), %rdi
callq 0xd0d0
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1891c
cmpq $0x0, -0x38(%rbp)
jne 0x18a09
cmpq $0x0, -0x28(%rbp)
je 0x189fd
movl -0x64(%rbp), %edi
callq 0xd020
movq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x48(%rbp)
je 0x189fb
movl -0x64(%rbp), %edi
movq -0x48(%rbp), %rsi
movq -0x18(%rbp), %rcx
leaq 0x81a0f(%rip), %rdx     # 0x9a3f0
movb $0x0, %al
callq 0xf220
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %esi
subl $0x1, %esi
movq -0x48(%rbp), %rdx
callq 0x4fe90
jmp 0x189fd
movl $0x1, -0x4(%rbp)
jmp 0x18d71
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x4fec0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x18bbd
cmpq $0x0, -0x20(%rbp)
jne 0x18bbd
movq -0x18(%rbp), %rdi
callq 0xbcc0
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %edi
addl $0x1e, %edi
callq 0xd020
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x18a6f
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4fef0
movl $0x7, -0x4(%rbp)
jmp 0x18d71
movq -0x58(%rbp), %rax
movq 0x81999(%rip), %rcx     # 0x9a413
movq %rcx, (%rax)
movl -0x80(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x74(%rbp)
movb %al, -0x8a(%rbp)
jl 0x18aac
movq -0x18(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
setne %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
testb $0x1, %al
jne 0x18ab8
jmp 0x18ac5
jmp 0x18aba
movl -0x74(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x18a86
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x74(%rbp), %rax
addq %rax, %rdi
leaq 0x8193c(%rip), %rsi     # 0x9a41c
movl $0x3, %edx
callq 0xbbe0
cmpl $0x0, %eax
jne 0x18af8
movl -0x74(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x74(%rbp)
movl $0x8, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movl %ecx, -0x7c(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x8b(%rbp)
je 0x18b28
cmpl $0x2e, -0x7c(%rbp)
setne %al
movb %al, -0x8b(%rbp)
movb -0x8b(%rbp), %al
testb $0x1, %al
jne 0x18b34
jmp 0x18b83
movl -0x7c(%rbp), %eax
movzbl %al, %eax
movl %eax, %ecx
leaq 0x7d1fd(%rip), %rax     # 0x95d40
movzbl (%rax,%rcx), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x18b73
movl -0x7c(%rbp), %eax
movl %eax, %ecx
leaq 0x7d2e5(%rip), %rax     # 0x95e40
movb (%rax,%rcx), %dl
movq -0x58(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x78(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x18b75
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x18aff
movq -0x58(%rbp), %rax
movslq -0x78(%rbp), %rcx
movl 0x81859(%rip), %edx     # 0x9a3ea
movl %edx, (%rax,%rcx)
movw 0x81853(%rip), %dx      # 0x9a3ee
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 0x4fec0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x18c4f
cmpq $0x0, -0x28(%rbp)
je 0x18c2d
movq -0x50(%rbp), %rdi
callq 0xbcc0
addl -0x64(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %edi
callq 0xd020
movq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x48(%rbp)
je 0x18c2b
movl -0x64(%rbp), %edi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq 0x8180f(%rip), %rdx     # 0x9a420
movb $0x0, %al
callq 0xf220
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %esi
subl $0x1, %esi
movq -0x48(%rbp), %rdx
callq 0x4fe90
jmp 0x18c2d
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4fef0
movq -0x58(%rbp), %rdi
callq 0xd0d0
movl $0x1, -0x4(%rbp)
jmp 0x18d71
movq -0x58(%rbp), %rdi
callq 0xd0d0
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq 0x9827d(%rip), %rdx     # 0xb0ee8
callq *%rax
cmpl $0x0, %eax
je 0x18cb7
cmpq $0x0, -0x28(%rbp)
je 0x18c95
movq -0x48(%rbp), %rsi
leaq 0x817c7(%rip), %rdi     # 0x9a44b
movb $0x0, %al
callq 0xf0e0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rdi
callq 0xd0d0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4fef0
movl $0x1, -0x4(%rbp)
jmp 0x18d71
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xac(%rax), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movl %eax, %esi
callq 0x14d30
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x18cec
movl $0x7, -0x4(%rbp)
jmp 0x18d71
movq -0x10(%rbp), %rax
cmpl $0x0, 0xac(%rax)
jle 0x18d1c
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0xac(%rax), %rdx
shlq $0x3, %rdx
callq 0x7260
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rsi
callq 0xc760
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x10(%rbp), %rsi
movl 0xac(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0xac(%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)