// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
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 0x2e69f
movq (%r15), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x336af
movl $0x1, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
testq %r15, %r15
je 0x2e68e
movq 0x8(%r15), %r13
testq %r13, %r13
je 0x2e787
movq 0x10(%r15), %rdx
testq %rdx, %rdx
je 0x2e744
cmpb $0x0, (%rdx)
je 0x2e744
movb %sil, 0x98(%r12)
leaq -0x34(%rbp), %rbx
movl $0x0, (%rbx)
movq %r13, %rdi
movq %rbx, %rsi
movq %rdx, %r13
callq 0x33854
movl (%rbx), %eax
movl %eax, 0x94(%r12)
xorl %ebx, %ebx
movb %bl, 0x9a(%r12)
movq $0x0, (%rsp)
leaq -0x30(%rbp), %r9
movq %r12, %rdi
movq %r13, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x12dde
movl 0x44(%r12), %eax
movb %bl, 0x98(%r12)
testl %eax, %eax
je 0x2e736
cmpb $0x0, 0x9a(%r12)
je 0x2e7a4
movq -0x30(%rbp), %rdi
callq 0xe974
jmp 0x2e68e
movq (%r15), %rsi
testq %rsi, %rsi
je 0x2e791
movq (%rax,%rcx), %rdx
movq %r12, %rdi
callq 0x3375e
testq %rax, %rax
je 0x2e68e
addq $0x50, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0x33854
testl %eax, %eax
jne 0x2e68e
movq (%r15), %rsi
leaq 0x4b89a(%rip), %rdx     # 0x7a01c
movq %r14, %rdi
jmp 0x2e79a
movq (%r15), %rsi
xorl %ebx, %ebx
movq %r14, %rdi
jmp 0x2e798
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x336af
jmp 0x2e68e
movl %eax, 0x14(%r14)
cmpl $0x9, %eax
je 0x2e736
cmpl $0x7, %eax
jne 0x2e7bd
movb $0x1, 0x50(%r12)
jmp 0x2e736
cmpb $0x6, %al
je 0x2e736
movq (%r15), %r15
movq %r12, %rdi
callq 0x12bfd
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x336af
jmp 0x2e736