// File: /workspace/github_c_makefile_star2_O0/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
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movl 0x4c(%rax), %eax
movl %eax, -0x64(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq 0x64df1(%rip), %rsi     # 0xae1d0
movb $0x0, %al
callq 0x137f0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x493fd
movl $0x7, -0x4(%rbp)
jmp 0x49868
movq -0x10(%rbp), %rdi
movl $0x30, %esi
callq 0x11ca0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x4942f
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x9cd0
movl $0x7, -0x4(%rbp)
jmp 0x49868
movq -0x10(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x13940
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x7c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x1c0(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
leaq -0x40(%rbp), %rcx
movq %rcx, 0x1c0(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rsi
movl -0x64(%rbp), %edx
movq -0x60(%rbp), %rcx
movq -0x50(%rbp), %r8
addq $0x10, %r8
leaq -0x70(%rbp), %r9
callq *%rax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1c0(%rax)
cmpl $0x7, -0x54(%rbp)
jne 0x494ef
movq -0x10(%rbp), %rax
movb $0x1, 0x50(%rax)
xorl %eax, %eax
cmpl -0x54(%rbp), %eax
je 0x4955a
cmpq $0x0, -0x70(%rbp)
jne 0x4951f
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rdx
leaq 0x65f08(%rip), %rsi     # 0xaf414
movb $0x0, %al
callq 0x137f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0x49548
movq -0x10(%rbp), %rdi
movq -0x70(%rbp), %rdx
leaq 0x64ca2(%rip), %rsi     # 0xae1d0
movb $0x0, %al
callq 0x137f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rdi
callq 0xa420
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x9cd0
jmp 0x49855
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x49853
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl $0x1, 0x18(%rax)
cmpq $0x0, -0x38(%rbp)
je 0x495d3
leaq 0x65e9e(%rip), %rax     # 0xaf432
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movb $0x0, %al
callq 0x137f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rdi
callq 0x2e700
movl $0x1, -0x54(%rbp)
jmp 0x49851
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x58(%rax)
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x42(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4984f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x8c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0xa0(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x49649
jmp 0x4983b
movq -0x98(%rbp), %rdi
callq 0x92f0
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rsi
leaq 0x65df8(%rip), %rdi     # 0xaf461
movl $0x6, %edx
callq 0x9210
cmpl $0x0, %eax
jne 0x496a0
movq -0x98(%rbp), %rax
movsbl 0x6(%rax), %eax
cmpl $0x0, %eax
je 0x49747
movq -0x98(%rbp), %rax
movsbl 0x6(%rax), %eax
cmpl $0x20, %eax
je 0x49747
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jge 0x49745
movq -0x98(%rbp), %rsi
movslq -0xa0(%rbp), %rax
addq %rax, %rsi
leaq 0x65d8c(%rip), %rdi     # 0xaf460
movl $0x7, %edx
callq 0x9210
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x4972f
movq -0x98(%rbp), %rax
movl -0xa0(%rbp), %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x4971e
movq -0x98(%rbp), %rax
movl -0xa0(%rbp), %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x4972f
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x49745
jmp 0x49731
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x496aa
jmp 0x49747
movl -0xa0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jge 0x49839
movq -0x98(%rbp), %rax
movl -0xa0(%rbp), %ecx
addl $0x6, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
addl $0x6, %eax
movl %eax, -0xa8(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
addl -0xa8(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jg 0x497e1
movq -0x98(%rbp), %rax
movl -0xa4(%rbp), %ecx
addl -0xa8(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x98(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x49792
movq -0x98(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x49818
cmpl $0x0, -0xa0(%rbp)
jle 0x49818
movq -0x98(%rbp), %rax
movl -0xa0(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x8c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movzwl 0x2a(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x2a(%rax)
jmp 0x4983b
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x495f9
jmp 0x49851
jmp 0x49853
jmp 0x49855
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x9cd0
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)