// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/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_schema) then
  ** do additional initialization work and store the statement text
  ** in the sqlite_schema table.
  */
  if( !db->init.busy ){
    char *zStmt;
    char *zWhere;
    int iDb;
    int iReg;
    Vdbe *v;

    sqlite3MayAbort(pParse);

    /* 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
    ** schema 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_schema table tht was created for this vtab
    ** by sqlite3StartTable().
    */
    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
    sqlite3NestedParse(pParse,
      "UPDATE %Q." DFLT_SCHEMA_TABLE " "
         "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
       "WHERE rowid=#%d",
      db->aDb[iDb].zDbSName,
      pTab->zName,
      pTab->zName,
      zStmt,
      pParse->regRowid
    );
    v = sqlite3GetVdbe(pParse);
    sqlite3ChangeCookie(pParse, iDb);

    sqlite3VdbeAddOp0(v, OP_Expire);
    zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt);
    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
    sqlite3DbFree(db, zStmt);

    iReg = ++pParse->nMem;
    sqlite3VdbeLoadString(v, iReg, pTab->zName);
    sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
  }

  /* If we are rereading the sqlite_schema 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;
    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );
    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab);
    if( pOld ){
      sqlite3OomFault(db);
      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */
      return;
    }
    pParse->pNewTable = 0;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x148(%rdi), %r14
testq %r14, %r14
je 0x26423a
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdi), %r15
callq 0x28552d
andq $0x0, 0x168(%rbx)
cmpl $0x0, 0x54(%r14)
jle 0x26423a
cmpb $0x0, 0xb5(%r15)
je 0x264120
movq (%r14), %rsi
movq 0x70(%r14), %rdi
addq $0x8, %rdi
movq %r14, %rdx
callq 0x24a8f4
testq %rax, %rax
je 0x264232
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x224bb1
movq 0xa0(%rbx), %rax
testq %rax, %rax
cmoveq %rbx, %rax
movb $0x1, 0x21(%rax)
testq %r12, %r12
je 0x26414c
movl (%r12), %eax
subl 0xf8(%rbx), %eax
addl 0x8(%r12), %eax
movl %eax, 0x100(%rbx)
leaq 0xf8(%rbx), %rdx
leaq 0x116111(%rip), %rsi    # 0x37a26b
movq %r15, %rdi
xorl %eax, %eax
callq 0x226ec3
movq %rax, %r13
movq 0x70(%r14), %rsi
movq %r15, %rdi
callq 0x226e9e
movq 0x20(%r15), %rcx
movslq %eax, %r12
movq %r12, %rax
shlq $0x5, %rax
movq (%rcx,%rax), %rdx
movq (%r14), %rcx
movl 0x78(%rbx), %eax
movl %eax, (%rsp)
leaq 0x1160ee(%rip), %rsi    # 0x37a283
movq %rbx, %rdi
movq %rcx, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x26ac90
movq %rbx, %rdi
callq 0x2645be
movq %rax, %rbp
movq %rbx, %rdi
movl %r12d, %esi
callq 0x26add3
movq %rbp, %rdi
movl $0x9e, %esi
callq 0x2645ec
movq (%r14), %rdx
leaq 0x116114(%rip), %rsi    # 0x37a2e6
movq %r15, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x226ec3
movq %rbp, %rdi
movl %r12d, %esi
movq %rax, %rdx
callq 0x26adfe
movq %r15, %rdi
movq %r13, %rsi
callq 0x21f26b
movl 0x38(%rbx), %r15d
incl %r15d
movl %r15d, 0x38(%rbx)
movq (%r14), %rdx
movq %rbp, %rdi
movl %r15d, %esi
callq 0x26475f
movq %rbp, %rdi
movl $0xa3, %esi
movl %r12d, %edx
movl %r15d, %ecx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24d51a
andq $0x0, 0x148(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq