// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vtabCallConstructor
static int vtabCallConstructor(
  sqlite3 *db,
  Table *pTab,
  Module *pMod,
  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
  char **pzErr
){
  VtabCtx sCtx;
  VTable *pVTable;
  int rc;
  const char *const*azArg = (const char *const*)pTab->azModuleArg;
  int nArg = pTab->nModuleArg;
  char *zErr = 0;
  char *zModuleName;
  int iDb;
  VtabCtx *pCtx;

  /* Check that the virtual-table is not already being initialized */
  for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){
    if( pCtx->pTab==pTab ){
      *pzErr = sqlite3MPrintf(db,
          "vtable constructor called recursively: %s", pTab->zName
      );
      return SQLITE_LOCKED;
    }
  }

  zModuleName = sqlite3DbStrDup(db, pTab->zName);
  if( !zModuleName ){
    return SQLITE_NOMEM_BKPT;
  }

  pVTable = sqlite3MallocZero(sizeof(VTable));
  if( !pVTable ){
    sqlite3OomFault(db);
    sqlite3DbFree(db, zModuleName);
    return SQLITE_NOMEM_BKPT;
  }
  pVTable->db = db;
  pVTable->pMod = pMod;
  pVTable->eVtabRisk = SQLITE_VTABRISK_Normal;

  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
  pTab->azModuleArg[1] = db->aDb[iDb].zDbSName;

  /* Invoke the virtual table constructor */
  assert( &db->pVtabCtx );
  assert( xConstruct );
  sCtx.pTab = pTab;
  sCtx.pVTable = pVTable;
  sCtx.pPrior = db->pVtabCtx;
  sCtx.bDeclared = 0;
  db->pVtabCtx = &sCtx;
  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
  db->pVtabCtx = sCtx.pPrior;
  if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
  assert( sCtx.pTab==pTab );

  if( SQLITE_OK!=rc ){
    if( zErr==0 ){
      *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
    }else {
      *pzErr = sqlite3MPrintf(db, "%s", zErr);
      sqlite3_free(zErr);
    }
    sqlite3DbFree(db, pVTable);
  }else if( ALWAYS(pVTable->pVtab) ){
    /* Justification of ALWAYS():  A correct vtab constructor must allocate
    ** the sqlite3_vtab object if successful.  */
    memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
    pVTable->pVtab->pModule = pMod->pModule;
    pMod->nRefModule++;
    pVTable->nRef = 1;
    if( sCtx.bDeclared==0 ){
      const char *zFormat = "vtable constructor did not declare schema: %s";
      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
      sqlite3VtabUnlock(pVTable);
      rc = SQLITE_ERROR;
    }else{
      int iCol;
      u16 oooHidden = 0;
      /* If everything went according to plan, link the new VTable structure
      ** into the linked list headed by pTab->pVTable. Then loop through the
      ** columns of the table to see if any of them contain the token "hidden".
      ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
      ** the type string.  */
      pVTable->pNext = pTab->pVTable;
      pTab->pVTable = pVTable;

      for(iCol=0; iCol<pTab->nCol; iCol++){
        char *zType = sqlite3ColumnType(&pTab->aCol[iCol], "");
        int nType;
        int i = 0;
        nType = sqlite3Strlen30(zType);
        for(i=0; i<nType; i++){
          if( 0==sqlite3StrNICmp("hidden", &zType[i], 6)
           && (i==0 || zType[i-1]==' ')
           && (zType[i+6]=='\0' || zType[i+6]==' ')
          ){
            break;
          }
        }
        if( i<nType ){
          int j;
          int nDel = 6 + (zType[i+6] ? 1 : 0);
          for(j=i; (j+nDel)<=nType; j++){
            zType[j] = zType[j+nDel];
          }
          if( zType[i]=='\0' && i>0 ){
            assert(zType[i-1]==' ');
            zType[i-1] = '\0';
          }
          pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;
          oooHidden = TF_OOOHidden;
        }else{
          pTab->tabFlags |= oooHidden;
        }
      }
    }
  }

  sqlite3DbFree(db, zModuleName);
  return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r12
movq %rcx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movq 0x58(%rsi), %rcx
movl 0x54(%rsi), %esi
movq $0x0, 0x30(%rsp)
movq 0x208(%rdi), %rax
testq %rax, %rax
je 0x2a7925
cmpq %r15, 0x8(%rax)
je 0x2a79ce
movq 0x10(%rax), %rax
jmp 0x2a7910
movl %esi, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, (%rsp)
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x279928
movl $0x7, %ebp
testq %rax, %rax
je 0x2a7c95
movq %rax, %r14
movq %r13, 0x28(%rsp)
movl $0x30, %edi
callq 0x272ae6
testq %rax, %rax
je 0x2a79f0
movq %rax, %r13
movq %r12, 0x18(%rsp)
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r13)
movups %xmm0, 0x20(%r13)
movq %rbx, (%r13)
movq (%rsp), %r9
movq %r9, 0x8(%r13)
movb $0x1, 0x1d(%r13)
movq 0x70(%r15), %rdx
movq 0x20(%rbx), %rax
testq %rdx, %rdx
movq %r14, 0x20(%rsp)
je 0x2a79fd
leaq 0x18(%rax), %rsi
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %rdi, %rcx
leaq 0x20(%rsi), %r8
cmpq %rdx, (%rsi)
movq %r8, %rsi
jne 0x2a79b9
sarq $0x20, %rcx
jmp 0x2a7a04
movq (%r15), %rdx
leaq 0x12f351(%rip), %rsi    # 0x3d6d29
movq %rbx, %rdi
xorl %eax, %eax
callq 0x27b56a
movq %rax, (%r12)
movl $0x6, %ebp
jmp 0x2a7c95
movq %rbx, %rdi
callq 0x278b1c
jmp 0x2a7c8a
movq $-0x8000, %rcx          # imm = 0x8000
shlq $0x5, %rcx
movq (%rax,%rcx), %rax
movq 0x58(%r15), %rcx
movq %rax, 0x8(%rcx)
leaq 0x38(%rsp), %r14
movq %r15, 0x8(%r14)
movq %r12, (%r14)
movq 0x208(%rbx), %rax
movq %rax, 0x10(%r14)
movl $0x0, 0x18(%r14)
movq %r14, 0x208(%rbx)
movq 0x18(%r9), %rsi
addq $0x10, %r13
leaq 0x30(%rsp), %r9
movq %rbx, %rdi
movl 0x8(%rsp), %edx
movq 0x10(%rsp), %rcx
movq %r13, %r8
callq *0x28(%rsp)
movl %eax, %ebp
movq 0x10(%r14), %rax
movq %rax, 0x208(%rbx)
testl %ebp, %ebp
je 0x2a7ab3
cmpl $0x7, %ebp
movq 0x20(%rsp), %r14
jne 0x2a7a7d
movq %rbx, %rdi
callq 0x278b1c
movq 0x30(%rsp), %rdx
testq %rdx, %rdx
je 0x2a7c63
leaq 0x121017(%rip), %rsi    # 0x3c8aa9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x27b56a
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movq 0x30(%rsp), %rdi
callq 0x272c00
jmp 0x2a7c7f
movq (%r13), %rax
xorl %ebp, %ebp
testq %rax, %rax
movq 0x20(%rsp), %r14
je 0x2a7c8a
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rsp), %rdx
movq (%rdx), %rax
movq 0x10(%r12), %rcx
movq %rax, (%rcx)
incl 0x10(%rdx)
movl $0x1, 0x18(%r12)
cmpl $0x0, 0x50(%rsp)
je 0x2a7ca6
movq 0x60(%r15), %rax
movq %rax, 0x28(%r12)
movq %r12, 0x60(%r15)
movzwl 0x46(%r15), %eax
movw %ax, 0x10(%rsp)
testw %ax, %ax
jle 0x2a7c8a
movq %rbx, 0x28(%rsp)
movq 0x8(%r15), %rax
movq %rax, (%rsp)
xorl %r12d, %r12d
leaq 0x12f26d(%rip), %rbp    # 0x3d6d9f
leaq 0x1297a7(%rip), %r13    # 0x3d12e0
movq $0x0, 0x8(%rsp)
movq %r12, %rbx
shlq $0x5, %rbx
movq (%rsp), %rax
testb $0x4, 0x1c(%rax,%rbx)
leaq 0x122617(%rip), %r14    # 0x3ca170
je 0x2a7b73
movq (%rsp), %rax
addq %rbx, %rax
movq (%rax), %r14
movq %r14, %rdi
callq 0x172f0
addq %rax, %r14
incq %r14
movq %r14, %rdi
callq 0x172f0
movl %eax, %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
je 0x2a7bd2
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq %r14, %rsi
xorl %ecx, %ecx
xorl %edi, %edi
movzbl (%rdi,%rbp), %r8d
movb (%r8,%r13), %r8b
movzbl (%rsi,%rdi), %r9d
cmpb (%r9,%r13), %r8b
jne 0x2a7bc7
incq %rdi
cmpq $0x6, %rdi
jne 0x2a7b91
testq %rcx, %rcx
je 0x2a7bbb
cmpb $0x20, -0x1(%r14,%rcx)
jne 0x2a7bc7
movzbl 0x6(%r14,%rcx), %edi
testb $-0x21, %dil
je 0x2a7bdd
incq %rcx
incq %rsi
cmpq %rax, %rcx
jne 0x2a7b8f
movzwl 0x8(%rsp), %eax
orl %eax, 0x40(%r15)
jmp 0x2a7c43
cmpb $0x1, %dil
movl $0x7, %esi
sbbl $0x0, %esi
leal (%rsi,%rcx), %edi
cmpl %edx, %edi
ja 0x2a7c10
movl %esi, %edx
leaq (%r14,%rdx), %rsi
movq %rcx, %rdi
movb (%rsi,%rdi), %r8b
movb %r8b, (%r14,%rdi)
leaq (%rdx,%rdi), %r8
incq %r8
incq %rdi
cmpq %rax, %r8
jbe 0x2a7bf9
testq %rcx, %rcx
je 0x2a7c22
cmpb $0x0, (%r14,%rcx)
jne 0x2a7c22
movb $0x0, -0x1(%r14,%rcx)
movq 0x8(%r15), %rax
movq %rax, (%rsp)
orw $0x2, 0x1c(%rax,%rbx)
movzwl 0x46(%r15), %eax
movw %ax, 0x10(%rsp)
movw $0x400, %ax             # imm = 0x400
movq %rax, 0x8(%rsp)
incq %r12
movswq 0x10(%rsp), %rax
cmpq %rax, %r12
jl 0x2a7b42
xorl %ebp, %ebp
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r14
jmp 0x2a7c8a
leaq 0x12f0e9(%rip), %rsi    # 0x3d6d53
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x27b56a
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x282904
movq %rbx, %rdi
movq %r14, %rsi
callq 0x282904
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rdx
leaq 0x12f0c1(%rip), %rsi    # 0x3d6d71
movq %rbx, %rdi
xorl %eax, %eax
callq 0x27b56a
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x28fc3f
movl $0x1, %ebp
jmp 0x2a7c8a