// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/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, *pPriorCtx;
  VTable *pVTable;
  int rc;
  const char *const*azArg = (const char *const*)pTab->azModuleArg;
  int nArg = pTab->nModuleArg;
  char *zErr = 0;
  char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
  int iDb;

  if( !zModuleName ){
    return SQLITE_NOMEM;
  }

  pVTable = sqlite3DbMallocZero(db, sizeof(VTable));
  if( !pVTable ){
    sqlite3DbFree(db, zModuleName);
    return SQLITE_NOMEM;
  }
  pVTable->db = db;
  pVTable->pMod = pMod;

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

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

  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.  */
    pVTable->pVtab->pModule = pMod->pModule;
    pVTable->nRef = 1;
    if( sCtx.pTab ){
      const char *zFormat = "vtable constructor did not declare schema: %s";
      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
      sqlite3VtabUnlock(pVTable);
      rc = SQLITE_ERROR;
    }else{
      int iCol;
      /* 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 = pTab->aCol[iCol].zType;
        int nType;
        int i = 0;
        if( !zType ) continue;
        nType = sqlite3Strlen30(zType);
        if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){
          for(i=0; i<nType; i++){
            if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
             && (zType[i+7]=='\0' || zType[i+7]==' ')
            ){
              i++;
              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;
        }
      }
    }
  }

  sqlite3DbFree(db, zModuleName);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r13
movq %rcx, -0x38(%rbp)
movq %rdx, -0x48(%rbp)
movq %rdi, %r15
movq 0x50(%rsi), %rbx
movl 0x4c(%rsi), %eax
movl %eax, -0x30(%rbp)
movq $0x0, -0x60(%rbp)
movq %rsi, -0x50(%rbp)
movq (%rsi), %rdx
leaq 0x43b18(%rip), %rsi     # 0x796d9
xorl %eax, %eax
callq 0x11900
movl $0x7, %r12d
testq %rax, %rax
je 0x35d91
movq %rax, %r14
movq %r13, -0x40(%rbp)
movq %r15, %rdi
movl $0x30, %esi
callq 0x11721
testq %rax, %rax
je 0x35c53
movq %rax, %r13
movq %rax, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r13)
movups %xmm0, 0x10(%r13)
movq %r15, (%r13)
movq -0x48(%rbp), %r8
movq %r8, 0x8(%r13)
movq -0x50(%rbp), %r9
movq 0x68(%r9), %r11
testq %r11, %r11
movq %r14, -0x58(%rbp)
je 0x35c5b
movl 0x28(%r15), %r12d
testl %r12d, %r12d
movq -0x38(%rbp), %r10
movq %rbx, %rcx
jle 0x35c69
movq 0x20(%r15), %rsi
addq $0x18, %rsi
xorl %eax, %eax
movl -0x30(%rbp), %edx
cmpq %r11, (%rsi)
je 0x35c6e
incq %rax
addq $0x20, %rsi
cmpq %rax, %r12
jne 0x35c3d
movl %r12d, %eax
jmp 0x35c6e
movq %r15, %rdi
jmp 0x35d89
movl $0xfff0bdc0, %eax       # imm = 0xFFF0BDC0
movq -0x38(%rbp), %r10
movq %rbx, %rcx
jmp 0x35c6b
xorl %eax, %eax
movl -0x30(%rbp), %edx
movq 0x20(%r15), %rsi
cltq
shlq $0x5, %rax
movq (%rsi,%rax), %rax
movq 0x50(%r9), %rsi
movq %rax, 0x8(%rsi)
leaq -0x70(%rbp), %rax
movq %r9, 0x8(%rax)
movq %rdi, -0x30(%rbp)
movq %rdi, (%rax)
movq 0x1c0(%r15), %r14
movq %rax, 0x1c0(%r15)
movq 0x10(%r8), %rsi
addq $0x10, %r13
movq %r15, -0x38(%rbp)
leaq -0x60(%rbp), %r9
movq -0x38(%rbp), %rdi
movq %r13, %r8
callq *%r10
movq -0x38(%rbp), %rdi
movq %r14, 0x1c0(%rdi)
testl %eax, %eax
je 0x35d06
movl %eax, %r12d
cmpl $0x7, %eax
movq -0x58(%rbp), %r14
movq -0x40(%rbp), %r15
jne 0x35cde
movb $0x1, 0x50(%rdi)
movq -0x60(%rbp), %rdx
testq %rdx, %rdx
je 0x35d63
leaq 0x439eb(%rip), %rsi     # 0x796d9
xorl %eax, %eax
movq %rdi, %rbx
callq 0x11900
movq %rax, (%r15)
movq -0x60(%rbp), %rdi
callq 0xa3c7
jmp 0x35d7a
movq (%r13), %rax
xorl %r12d, %r12d
testq %rax, %rax
movq -0x58(%rbp), %r14
je 0x35d89
movq -0x48(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %r15
movl $0x1, 0x18(%r15)
cmpq $0x0, -0x68(%rbp)
je 0x35da3
movq -0x50(%rbp), %rax
movq (%rax), %rdx
leaq 0x44bf5(%rip), %rsi     # 0x7a936
xorl %eax, %eax
callq 0x11900
movq -0x40(%rbp), %rcx
movq %rax, (%rcx)
movq %r15, %rdi
callq 0x22dc8
movq -0x38(%rbp), %rdi
movl $0x1, %r12d
jmp 0x35d89
leaq 0x44bae(%rip), %rsi     # 0x7a918
movq %r14, %rdx
xorl %eax, %eax
movq %rdi, %rbx
callq 0x11900
movq %rax, (%r15)
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x9ca4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9ca4
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x50(%rbp), %rdx
movq 0x58(%rdx), %rax
movq %rax, 0x28(%r15)
movq %r15, 0x58(%rdx)
movzwl 0x42(%rdx), %r8d
testw %r8w, %r8w
jle 0x35d89
movq 0x8(%rdx), %rax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
leaq 0x44b96(%rip), %rcx     # 0x7a965
leaq 0x402da(%rip), %rdx     # 0x760b0
leaq 0x44b87(%rip), %rsi     # 0x7a964
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
movq -0x48(%rbp), %r9
movq 0x18(%r9,%rdi), %r9
testq %r9, %r9
je 0x35f26
movw %r8w, -0x30(%rbp)
xorl %r8d, %r8d
movq $-0x1, %r14
movl %r8d, %r11d
leal 0x1(%r11), %r8d
cmpb $0x0, 0x1(%r9,%r14)
leaq 0x1(%r14), %r14
jne 0x35e06
movl %r14d, %r12d
andl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
xorl %r8d, %r8d
movzbl (%r8,%rcx), %r10d
movb (%r10,%rdx), %r10b
movzbl (%r9,%r8), %r13d
cmpb (%r13,%rdx), %r10b
jne 0x35e4f
incq %r8
cmpq $0x6, %r8
jne 0x35e26
movzbl 0x6(%r9), %r8d
testb $-0x21, %r8b
je 0x35e9d
testl %r12d, %r12d
je 0x35e9d
movq %rdi, -0x40(%rbp)
andl $0x3fffffff, %r11d      # imm = 0x3FFFFFFF
movq %r9, %r8
xorl %r13d, %r13d
xorl %r10d, %r10d
movzbl (%r10,%rsi), %edi
movb (%rdi,%rdx), %dil
movzbl (%r8,%r10), %ecx
cmpb (%rcx,%rdx), %dil
jne 0x35e90
incq %r10
cmpq $0x7, %r10
jne 0x35e68
movzbl 0x7(%r9,%r13), %ecx
testb $-0x21, %cl
je 0x35ea2
incq %r13
incq %r8
cmpq %r11, %r13
jne 0x35e65
jmp 0x35ea8
xorl %r11d, %r11d
jmp 0x35eac
incl %r13d
movl %r13d, %r11d
movq -0x40(%rbp), %rdi
cmpl %r12d, %r11d
movzwl -0x30(%rbp), %r8d
jge 0x35f26
movslq %r11d, %r8
cmpb $0x1, 0x6(%r9,%r8)
movl $0x7, %r10d
sbbl $0x0, %r10d
leal (%r11,%r10), %ecx
cmpl %r12d, %ecx
jg 0x35efa
movl %r10d, %r10d
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
leaq (%r9,%r10), %r12
movq %r8, %r13
movb (%r12,%r13), %cl
movb %cl, (%r9,%r13)
leaq (%r10,%r13), %rcx
incq %rcx
incq %r13
cmpq %r14, %rcx
jbe 0x35ee3
testl %r11d, %r11d
jle 0x35f0f
cmpb $0x0, (%r9,%r8)
jne 0x35f0f
movl %r11d, %ecx
movb $0x0, -0x1(%r9,%rcx)
movq -0x50(%rbp), %r8
movq 0x8(%r8), %rcx
movq %rcx, -0x48(%rbp)
orw $0x2, 0x2a(%rcx,%rdi)
movzwl 0x42(%r8), %r8d
incq %rax
movswq %r8w, %rcx
cmpq %rcx, %rax
leaq 0x44a2e(%rip), %rcx     # 0x7a965
jl 0x35ddd
xorl %r12d, %r12d
movq -0x58(%rbp), %r14
movq -0x38(%rbp), %rdi
jmp 0x35d89