// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq 0x148(%rdi), %r14
testq %r14, %r14
je 0x2c57c0
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdi), %r15
callq 0x2f32c3
movq $0x0, 0x168(%rbx)
cmpl $0x0, 0x54(%r14)
jle 0x2c57c0
cmpb $0x0, 0xb5(%r15)
je 0x2c574b
movq (%r14), %rsi
movq 0x70(%r14), %rdi
addq $0x8, %rdi
movq %r14, %rdx
callq 0x2aed98
testq %rax, %rax
je 0x2c57b5
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2824bb
movq 0xa0(%rbx), %rax
testq %rax, %rax
cmoveq %rbx, %rax
movb $0x1, 0x21(%rax)
testq %r12, %r12
je 0x2c5777
movl (%r12), %eax
subl 0xf8(%rbx), %eax
addl 0x8(%r12), %eax
movl %eax, 0x100(%rbx)
leaq 0xf8(%rbx), %rdx
leaq 0x11de1b(%rip), %rsi    # 0x3e35a0
movq %r15, %rdi
xorl %eax, %eax
callq 0x284f95
movq 0x70(%r14), %rsi
testq %rsi, %rsi
je 0x2c57cf
movq 0x20(%r15), %rcx
addq $0x18, %rcx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incl %ebp
leaq 0x20(%rcx), %rdx
cmpq %rsi, (%rcx)
movq %rdx, %rcx
jne 0x2c57a5
jmp 0x2c57d4
movq $0x0, 0x148(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffff8000, %ebp       # imm = 0xFFFF8000
movq 0x20(%r15), %rcx
movslq %ebp, %r12
movq %r12, 0x10(%rsp)
shlq $0x5, %r12
movq (%rcx,%r12), %rdx
movq (%r14), %rcx
movl 0x78(%rbx), %esi
movl %esi, (%rsp)
leaq 0x11ddc0(%rip), %rsi    # 0x3e35b8
movq %rbx, %rdi
movq %rcx, %r8
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x2cdd65
movq %rbx, %rdi
callq 0x2c5ddf
movq %rax, %r13
movq (%rbx), %rax
movq 0x10(%rbx), %rdi
movq 0x20(%rax), %rax
movq 0x18(%rax,%r12), %rax
movl (%rax), %r8d
incl %r8d
movl $0x5e, %esi
movq 0x10(%rsp), %r12
movl %r12d, %edx
movl $0x1, %ecx
callq 0x2b200c
movq %r13, %rdi
movl $0x9e, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b200c
movq (%r14), %rdx
leaq 0x11ddb6(%rip), %rsi    # 0x3e361b
movq %r15, %rdi
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x284f95
movq %r13, %rdi
movl %r12d, %esi
movq %rax, %rdx
callq 0x2cdedf
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x2c5894
movq %r15, %rdi
callq 0x28c3e7
movl 0x38(%rbx), %r15d
incl %r15d
movl %r15d, 0x38(%rbx)
movq (%r14), %rbx
movq %r13, %rdi
movl $0x73, %esi
xorl %edx, %edx
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x2b200c
movq %r13, %rdi
movl %eax, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x285198
movq %r13, %rdi
movl $0xa3, %esi
movl %ebp, %edx
movl %r15d, %ecx
xorl %r8d, %r8d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b200c