// File: /workspace/github_c_makefile_star2_O1/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 %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x58(%rsi), %rcx
movl 0x54(%rsi), %edx
movq $0x0, 0x30(%rsp)
movq 0x208(%rdi), %rax
testq %rax, %rax
je 0x2b1540
cmpq %r15, 0x8(%rax)
je 0x2b15e2
movq 0x10(%rax), %rax
jmp 0x2b152b
movl %edx, 0x28(%rsp)
movq %rcx, 0x10(%rsp)
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x283365
movl $0x7, %ebp
testq %rax, %rax
je 0x2b1895
movq %r13, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl $0x30, %edi
callq 0x27c381
testq %rax, %rax
je 0x2b1604
movq %rax, %r13
movq %r12, (%rsp)
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movups %xmm0, 0x10(%r13)
movups %xmm0, 0x20(%r13)
movq %rbx, (%r13)
movq %r14, 0x8(%r13)
movb $0x1, 0x1d(%r13)
movq 0x70(%r15), %rcx
testq %rcx, %rcx
je 0x2b1611
movq 0x20(%rbx), %rdx
addq $0x18, %rdx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %rsi      # imm = 0x100000000
addq %rsi, %rax
leaq 0x20(%rdx), %rdi
cmpq %rcx, (%rdx)
movq %rdi, %rdx
jne 0x2b15cd
sarq $0x20, %rax
jmp 0x2b1618
movq (%r15), %rdx
leaq 0x12ee92(%rip), %rsi    # 0x3e047e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x284f95
movq %rax, (%r12)
movl $0x6, %ebp
jmp 0x2b1895
movq %rbx, %rdi
callq 0x2824bb
jmp 0x2b1888
movq $-0x8000, %rax          # imm = 0x8000
movq 0x20(%rbx), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rax
movq 0x58(%r15), %rcx
movq %rax, 0x8(%rcx)
movq %rbx, 0x8(%rsp)
leaq 0x38(%rsp), %rbx
movq %r15, 0x8(%rbx)
movq %r12, (%rbx)
movq 0x8(%rsp), %rax
movq 0x208(%rax), %rax
movq %rax, 0x10(%rbx)
movl $0x0, 0x18(%rbx)
movq 0x8(%rsp), %rax
movq %rbx, 0x208(%rax)
movq 0x18(%r14), %rsi
addq $0x10, %r13
leaq 0x30(%rsp), %r9
movq 0x8(%rsp), %rdi
movl 0x28(%rsp), %edx
movq 0x10(%rsp), %rcx
movq %r13, %r8
callq *0x18(%rsp)
movl %eax, %ebp
movq 0x10(%rbx), %rax
movq 0x8(%rsp), %rbx
movq %rax, 0x208(%rbx)
testl %ebp, %ebp
je 0x2b16da
cmpl $0x7, %ebp
jne 0x2b16a5
movq %rbx, %rdi
callq 0x2824bb
movq 0x30(%rsp), %rdx
testq %rdx, %rdx
je 0x2b1860
leaq 0x120b17(%rip), %rsi    # 0x3d21d1
movq %rbx, %rdi
xorl %eax, %eax
callq 0x284f95
movq (%rsp), %rcx
movq %rax, (%rcx)
movq 0x30(%rsp), %rdi
callq 0x27c490
jmp 0x2b187d
movq (%r13), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0x2b1888
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%r14), %rax
movq 0x10(%r12), %rcx
movq %rax, (%rcx)
incl 0x10(%r14)
movl $0x1, 0x18(%r12)
cmpl $0x0, 0x50(%rsp)
je 0x2b18a6
movq 0x60(%r15), %rax
movq %rax, 0x28(%r12)
movq %r12, 0x60(%r15)
cmpw $0x0, 0x46(%r15)
jle 0x2b1888
xorl %ecx, %ecx
movq $0x0, (%rsp)
movq 0x8(%r15), %rax
movq %rcx, 0x10(%rsp)
movq %rcx, %rbx
shlq $0x5, %rbx
testb $0x4, 0x1c(%rax,%rbx)
leaq 0x122137(%rip), %r14    # 0x3d3890
je 0x2b176f
addq %rbx, %rax
movq (%rax), %r14
movq %r14, %rdi
callq 0x172f0
addq %rax, %r14
incq %r14
movq %rbx, 0x28(%rsp)
movq %r14, %rdi
callq 0x172f0
movq %rax, %rbx
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, 0x18(%rsp)
je 0x2b17d3
movl %ebx, %r13d
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
negq %r13
movq %r14, %rbp
xorl %r12d, %r12d
leaq 0x12ed50(%rip), %rdi    # 0x3e04f4
movq %rbp, %rsi
movl $0x6, %edx
callq 0x27e951
testl %eax, %eax
jne 0x2b17c8
testq %r12, %r12
je 0x2b17c0
cmpb $0x20, -0x1(%rbp)
jne 0x2b17c8
movzbl 0x6(%rbp), %eax
testb $-0x21, %al
je 0x2b17dd
decq %r12
incq %rbp
cmpq %r12, %r13
jne 0x2b179d
movzwl (%rsp), %eax
orl %eax, 0x40(%r15)
jmp 0x2b1841
cmpb $0x1, %al
movl $0x7, %ecx
sbbl $0x0, %ecx
movl %ecx, %eax
subl %r12d, %eax
cmpl 0x18(%rsp), %eax
ja 0x2b181b
movq %r12, %rax
negq %rax
movl %ecx, %ecx
andl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
leaq (%r14,%rcx), %rdx
movb (%rdx,%rax), %sil
movb %sil, (%r14,%rax)
leaq (%rcx,%rax), %rsi
incq %rsi
incq %rax
cmpq %rbx, %rsi
jbe 0x2b1804
testq %r12, %r12
je 0x2b182a
cmpb $0x0, (%rbp)
jne 0x2b182a
movb $0x0, -0x1(%rbp)
movq 0x8(%r15), %rax
movq 0x28(%rsp), %rcx
orw $0x2, 0x1c(%rax,%rcx)
movw $0x400, %ax             # imm = 0x400
movq %rax, (%rsp)
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %rcx
incq %rcx
movswq 0x46(%r15), %rax
cmpq %rax, %rcx
jl 0x2b173d
xorl %ebp, %ebp
jmp 0x2b1888
leaq 0x12ec41(%rip), %rsi    # 0x3e04a8
movq %rbx, %rdi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x284f95
movq (%rsp), %rcx
movq %rax, (%rcx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x28c3e7
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x28c3e7
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rdx
leaq 0x12ec16(%rip), %rsi    # 0x3e04c6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x284f95
movq (%rsp), %rcx
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x2999f3
movl $0x1, %ebp
jmp 0x2b1888