// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movzwl 0x72(%rax), %ecx
andl $-0x5, %ecx
movw %cx, 0x72(%rax)
movq -0x38(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0x3e600
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x464d0
movl $0x1, -0x4(%rbp)
jmp 0x3e7d3
cmpq $0x0, -0x20(%rbp)
jne 0x3e613
movl $0x0, -0x4(%rbp)
jmp 0x3e7d3
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3e637
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x464d0
jmp 0x3e7cc
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x3e744
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x3e744
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x98(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x465c0
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x94(%rax)
movq -0x38(%rbp), %rax
movb $0x0, 0x9a(%rax)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x48(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x15730
movq -0x38(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movb $0x0, 0x98(%rax)
xorl %eax, %eax
cmpl -0x40(%rbp), %eax
je 0x3e736
movq -0x38(%rbp), %rax
cmpb $0x0, 0x9a(%rax)
je 0x3e6d7
jmp 0x3e734
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x14(%rax)
cmpl $0x7, -0x40(%rbp)
jne 0x3e6f1
movq -0x38(%rbp), %rax
movb $0x1, 0x50(%rax)
jmp 0x3e732
cmpl $0x9, -0x40(%rbp)
je 0x3e730
movl -0x40(%rbp), %eax
andl $0xff, %eax
cmpl $0x6, %eax
je 0x3e730
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
callq 0x154c0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x464d0
jmp 0x3e732
jmp 0x3e734
jmp 0x3e736
movq -0x48(%rbp), %rdi
callq 0xfcf0
jmp 0x3e7ca
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x3e760
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x464d0
jmp 0x3e7c8
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
callq 0x465f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x3e793
jmp 0x3e7c6
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x50(%rbp), %rsi
addq $0x50, %rsi
callq 0x466d0
cmpl $0x0, %eax
jne 0x3e7c4
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
leaq 0x70359(%rip), %rdx     # 0xaeb18
callq 0x464d0
jmp 0x3e7c6
jmp 0x3e7c8
jmp 0x3e7ca
jmp 0x3e7cc
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)