// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3InitCallback
SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
  InitData *pData = (InitData*)pInit;
  sqlite3 *db = pData->db;
  int iDb = pData->iDb;

  assert( argc==3 );
  UNUSED_PARAMETER2(NotUsed, argc);
  assert( sqlite3_mutex_held(db->mutex) );
  DbClearProperty(db, iDb, DB_Empty);
  if( db->mallocFailed ){
    corruptSchema(pData, argv[0], 0);
    return 1;
  }

  assert( iDb>=0 && iDb<db->nDb );
  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */
  if( argv[1]==0 ){
    corruptSchema(pData, argv[0], 0);
  }else if( argv[2] && argv[2][0] ){
    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
    ** But because db->init.busy is set to 1, no VDBE code is generated
    ** or executed.  All the parser does is build the internal data
    ** structures that describe the table, index, or view.
    */
    int rc;
    sqlite3_stmt *pStmt;
    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */

    assert( db->init.busy );
    db->init.iDb = iDb;
    db->init.newTnum = sqlite3Atoi(argv[1]);
    db->init.orphanTrigger = 0;
    TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
    rc = db->errCode;
    assert( (rc&0xFF)==(rcp&0xFF) );
    db->init.iDb = 0;
    if( SQLITE_OK!=rc ){
      if( db->init.orphanTrigger ){
        assert( iDb==1 );
      }else{
        pData->rc = rc;
        if( rc==SQLITE_NOMEM ){
          db->mallocFailed = 1;
        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
          corruptSchema(pData, argv[0], sqlite3_errmsg(db));
        }
      }
    }
    sqlite3_finalize(pStmt);
  }else if( argv[0]==0 ){
    corruptSchema(pData, 0, 0);
  }else{
    /* If the SQL column is blank it means this is an index that
    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
    ** constraint for a CREATE TABLE.  The index should have already
    ** been created when we processed the CREATE TABLE.  All we have
    ** to do here is record the root page number for that index.
    */
    Index *pIndex;
    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zName);
    if( pIndex==0 ){
      /* This can occur if there exists an index on a TEMP table which
      ** has the same name as another index on a permanent index.  Since
      ** the permanent table is hidden by the TEMP table, we can also
      ** safely ignore the index on the permanent table.
      */
      /* Do Nothing */;
    }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){
      corruptSchema(pData, argv[0], "invalid rootpage");
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq (%rdi), %r12
movslq 0x10(%rdi), %rsi
movq 0x20(%r12), %rax
movq %rsi, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rdi
andw $-0x5, 0x72(%rdi)
movq %rdx, %r15
cmpb $0x0, 0x50(%r12)
je 0x2b561
movq (%r15), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x2ec41
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
testq %r15, %r15
je 0x2b550
movq 0x8(%r15), %r13
testq %r13, %r13
je 0x2b62a
movq 0x10(%r15), %rdx
testq %rdx, %rdx
je 0x2b5e7
cmpb $0x0, (%rdx)
je 0x2b5e7
movb %sil, 0x98(%r12)
movq %r13, %rdi
movq %rdx, %r13
callq 0x2ecd6
movl %eax, 0x94(%r12)
xorl %ebx, %ebx
movb %bl, 0x9a(%r12)
pushq $-0x1
popq %rdx
leaq -0x30(%rbp), %rcx
movq %r12, %rdi
movq %r13, %rsi
xorl %r8d, %r8d
callq 0x118d8
movl 0x44(%r12), %eax
movb %bl, 0x98(%r12)
testl %eax, %eax
je 0x2b5d9
cmpb $0x0, 0x9a(%r12)
je 0x2b647
movq -0x30(%rbp), %rdi
callq 0xdbaa
jmp 0x2b550
movq (%r15), %rsi
testq %rsi, %rsi
je 0x2b634
movq (%rax,%rcx), %rdx
movq %r12, %rdi
callq 0x2ecfe
testq %rax, %rax
je 0x2b550
addq $0x50, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0x2ed95
testl %eax, %eax
jne 0x2b550
movq (%r15), %rsi
leaq 0x40a17(%rip), %rdx     # 0x6c03c
movq %r14, %rdi
jmp 0x2b63d
movq (%r15), %rsi
xorl %ebx, %ebx
movq %r14, %rdi
jmp 0x2b63b
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2ec41
jmp 0x2b550
movl %eax, 0x14(%r14)
cmpl $0x9, %eax
je 0x2b5d9
cmpl $0x7, %eax
jne 0x2b660
movb $0x1, 0x50(%r12)
jmp 0x2b5d9
cmpb $0x6, %al
je 0x2b5d9
movq (%r15), %r15
movq %r12, %rdi
callq 0x11788
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2ec41
jmp 0x2b5d9