// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VtabFinishParse
SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
  Table *pTab = pParse->pNewTable;  /* The table being constructed */
  sqlite3 *db = pParse->db;         /* The database connection */

  if( pTab==0 ) return;
  addArgumentToVtab(pParse);
  pParse->sArg.z = 0;
  if( pTab->nModuleArg<1 ) return;
  
  /* If the CREATE VIRTUAL TABLE statement is being entered for the
  ** first time (in other words if the virtual table is actually being
  ** created now instead of just being read out of sqlite_master) then
  ** do additional initialization work and store the statement text
  ** in the sqlite_master table.
  */
  if( !db->init.busy ){
    char *zStmt;
    char *zWhere;
    int iDb;
    Vdbe *v;

    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
    if( pEnd ){
      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
    }
    zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);

    /* A slot for the record has already been allocated in the 
    ** SQLITE_MASTER table.  We just need to update that slot with all
    ** the information we've collected.  
    **
    ** The VM register number pParse->regRowid holds the rowid of an
    ** entry in the sqlite_master table tht was created for this vtab
    ** by sqlite3StartTable().
    */
    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
    sqlite3NestedParse(pParse,
      "UPDATE %Q.%s "
         "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
       "WHERE rowid=#%d",
      db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
      pTab->zName,
      pTab->zName,
      zStmt,
      pParse->regRowid
    );
    sqlite3DbFree(db, zStmt);
    v = sqlite3GetVdbe(pParse);
    sqlite3ChangeCookie(pParse, iDb);

    sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
    zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
    sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, 
                         pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
  }

  /* If we are rereading the sqlite_master table create the in-memory
  ** record of the table. The xConnect() method is not called until
  ** the first time the virtual table is used in an SQL statement. This
  ** allows a schema that contains virtual tables to be loaded before
  ** the required virtual table implementations are registered.  */
  else {
    Table *pOld;
    Schema *pSchema = pTab->pSchema;
    const char *zName = pTab->zName;
    int nName = sqlite3Strlen30(zName);
    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );
    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab);
    if( pOld ){
      db->mallocFailed = 1;
      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */
      return;
    }
    pParse->pNewTable = 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x238(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5db39
jmp 0x5dd45
movq -0x8(%rbp), %rdi
callq 0x84dc0
movq -0x8(%rbp), %rax
movq $0x0, 0x270(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x4c(%rax)
jge 0x5db60
jmp 0x5dd45
movq -0x20(%rbp), %rax
cmpb $0x0, 0x99(%rax)
jne 0x5dce6
cmpq $0x0, -0x10(%rbp)
je 0x5dba0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x250(%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x258(%rax)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x250, %rdx            # imm = 0x250
leaq 0x53c56(%rip), %rsi     # 0xb180c
movb $0x0, %al
callq 0x137f0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x13940
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movl -0x34(%rbp), %esi
leaq 0x50e2f(%rip), %rcx     # 0xaea28
leaq 0x50e15(%rip), %rax     # 0xaea15
cmpl $0x1, %esi
cmoveq %rax, %rcx
movq -0x18(%rbp), %rax
movq (%rax), %r8
movq -0x18(%rbp), %rax
movq (%rax), %r9
movq -0x28(%rbp), %r10
movq -0x8(%rbp), %rax
movl 0x1a0(%rax), %eax
leaq 0x53bfa(%rip), %rsi     # 0xb1824
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x5f320
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x9cd0
movq -0x8(%rbp), %rdi
callq 0x5e000
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x5f4a0
movq -0x40(%rbp), %rdi
movl $0x84, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x5e0c0
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq 0x53bf9(%rip), %rsi     # 0xb187c
movb $0x0, %al
callq 0x137f0
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x5f530
movq -0x40(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x92f0
movq -0x78(%rbp), %rdi
movl -0x6c(%rbp), %edx
movq -0x68(%rbp), %r9
addl $0x1, %eax
movl $0x87, %esi
xorl %r8d, %r8d
movl %r8d, %ecx
movl %eax, (%rsp)
callq 0x5e1b0
jmp 0x5dd45
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x92f0
movl %eax, -0x5c(%rbp)
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
movq -0x58(%rbp), %rsi
movl -0x5c(%rbp), %edx
movq -0x18(%rbp), %rcx
callq 0x46e00
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x5dd36
movq -0x20(%rbp), %rax
movb $0x1, 0x50(%rax)
jmp 0x5dd45
movq -0x8(%rbp), %rax
movq $0x0, 0x238(%rax)
addq $0x90, %rsp
popq %rbp
retq
nop