// File: /workspace/github_c_makefile_star2_O2/jkbenaim[P]psfrag/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==5 );
  UNUSED_PARAMETER2(NotUsed, argc);
  assert( sqlite3_mutex_held(db->mutex) );
  DbClearProperty(db, iDb, DB_Empty);
  pData->nInitRow++;
  if( db->mallocFailed ){
    corruptSchema(pData, argv[1], 0);
    return 1;
  }

  assert( iDb>=0 && iDb<db->nDb );
  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */
  if( argv[3]==0 ){
    corruptSchema(pData, argv[1], 0);
  }else if( sqlite3_strnicmp(argv[4],"create ",7)==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;
    u8 saved_iDb = db->init.iDb;
    sqlite3_stmt *pStmt;
    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */

    assert( db->init.busy );
    db->init.iDb = iDb;
    db->init.newTnum = sqlite3Atoi(argv[3]);
    db->init.orphanTrigger = 0;
    db->init.azInit = argv;
    TESTONLY(rcp = ) sqlite3_prepare(db, argv[4], -1, &pStmt, 0);
    rc = db->errCode;
    assert( (rc&0xFF)==(rcp&0xFF) );
    db->init.iDb = saved_iDb;
    /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
    if( SQLITE_OK!=rc ){
      if( db->init.orphanTrigger ){
        assert( iDb==1 );
      }else{
        if( rc > pData->rc ) pData->rc = rc;
        if( rc==SQLITE_NOMEM ){
          sqlite3OomFault(db);
        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
          corruptSchema(pData, argv[1], sqlite3_errmsg(db));
        }
      }
    }
    sqlite3_finalize(pStmt);
  }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){
    corruptSchema(pData, argv[1], 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[1], db->aDb[iDb].zDbSName);
    if( pIndex==0
     || sqlite3GetInt32(argv[3],&pIndex->tnum)==0
     || pIndex->tnum<2
     || sqlite3IndexHasDuplicateRootPage(pIndex)
    ){
      corruptSchema(pData, argv[1], pIndex?"invalid rootpage":"orphan index");
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq (%rdi), %r12
movslq 0x10(%rdi), %r13
movq 0x20(%r12), %rbp
movq %r13, %rbx
shlq $0x5, %rbx
movq 0x18(%rbp,%rbx), %rax
andw $-0x5, 0x72(%rax)
incl 0x1c(%rdi)
movq %rdx, %r15
cmpb $0x0, 0x61(%r12)
je 0x30659
movq 0x8(%r15), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x36c43
pushq $0x1
popq %r13
jmp 0x307e1
testq %r15, %r15
je 0x307b4
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x30702
movq %rax, (%rsp)
movq 0x20(%r15), %rdi
leaq 0x4a894(%rip), %rsi     # 0x7af12
pushq $0x7
popq %rdx
movq %rdi, 0x8(%rsp)
callq 0xc87e
testl %eax, %eax
je 0x30718
movq 0x8(%r15), %rsi
testq %rsi, %rsi
movq 0x8(%rsp), %rax
je 0x30706
testq %rax, %rax
je 0x306ab
cmpb $0x0, (%rax)
jne 0x30706
movq (%rbp,%rbx), %rdx
movq %r12, %rdi
callq 0x36d1c
testq %rax, %rax
je 0x3079e
movq %rax, %r13
movq 0x18(%r15), %rdi
leaq 0x58(%rax), %rbp
movq %rbp, %rsi
callq 0x36d97
leaq 0x4a83f(%rip), %r12     # 0x7af1a
testl %eax, %eax
je 0x307a5
cmpl $0x2, (%rbp)
jl 0x307a5
movq %r13, %rdi
callq 0x36eb5
testl %eax, %eax
jne 0x307a5
jmp 0x307b4
movq 0x8(%r15), %rsi
xorl %r13d, %r13d
movq %r14, %rdi
xorl %edx, %edx
callq 0x36c43
jmp 0x307e1
movb 0xb4(%r12), %bl
movb %r13b, 0xb4(%r12)
movq (%rsp), %rdi
callq 0x36cf4
movl %eax, 0xb0(%r12)
andb $-0x2, 0xb6(%r12)
movq %r15, 0xb8(%r12)
movq 0x20(%r15), %rsi
xorl %r13d, %r13d
pushq $-0x1
popq %rdx
leaq 0x10(%rsp), %rcx
movq %r12, %rdi
xorl %r8d, %r8d
callq 0x13c24
movl 0x50(%r12), %eax
movb %bl, 0xb4(%r12)
testl %eax, %eax
je 0x307d7
testb $0x1, 0xb6(%r12)
jne 0x307d7
cmpl 0x14(%r14), %eax
jle 0x3078a
movl %eax, 0x14(%r14)
cmpl $0x9, %eax
je 0x307d7
cmpl $0x7, %eax
jne 0x307b9
movq %r12, %rdi
callq 0xfde0
jmp 0x307d7
leaq 0x4a786(%rip), %r12     # 0x7af2b
movq 0x8(%r15), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x36c43
xorl %r13d, %r13d
jmp 0x307e1
cmpb $0x6, %al
je 0x307d7
movq 0x8(%r15), %r15
movq %r12, %rdi
callq 0x1359a
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x36c43
movq 0x10(%rsp), %rdi
callq 0xf24e
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq