// File: /workspace/github_c_makefile_star2_O1/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3StartTable
SQLITE_PRIVATE void sqlite3StartTable(
  Parse *pParse,   /* Parser context */
  Token *pName1,   /* First part of the name of the table or view */
  Token *pName2,   /* Second part of the name of the table or view */
  int isTemp,      /* True if this is a TEMP table */
  int isView,      /* True if this is a VIEW */
  int isVirtual,   /* True if this is a VIRTUAL table */
  int noErr        /* Do nothing if table already exists */
){
  Table *pTable;
  char *zName = 0; /* The name of the new table */
  sqlite3 *db = pParse->db;
  Vdbe *v;
  int iDb;         /* Database number to create the table in */
  Token *pName;    /* Unqualified name of the table to create */

  /* The table or view name to create is passed to this routine via tokens
  ** pName1 and pName2. If the table name was fully qualified, for example:
  **
  ** CREATE TABLE xxx.yyy (...);
  ** 
  ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if
  ** the table name is not fully qualified, i.e.:
  **
  ** CREATE TABLE yyy(...);
  **
  ** Then pName1 is set to "yyy" and pName2 is "".
  **
  ** The call below sets the pName pointer to point at the token (pName1 or
  ** pName2) that stores the unqualified table name. The variable iDb is
  ** set to the index of the database that the table or view is to be
  ** created in.
  */
  iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
  if( iDb<0 ) return;
  if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){
    /* If creating a temp table, the name may not be qualified. Unless 
    ** the database name is "temp" anyway.  */
    sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
    return;
  }
  if( !OMIT_TEMPDB && isTemp ) iDb = 1;

  pParse->sNameToken = *pName;
  zName = sqlite3NameFromToken(db, pName);
  if( zName==0 ) return;
  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
    goto begin_table_error;
  }
  if( db->init.iDb==1 ) isTemp = 1;
#ifndef SQLITE_OMIT_AUTHORIZATION
  assert( (isTemp & 1)==isTemp );
  {
    int code;
    char *zDb = db->aDb[iDb].zName;
    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){
      goto begin_table_error;
    }
    if( isView ){
      if( !OMIT_TEMPDB && isTemp ){
        code = SQLITE_CREATE_TEMP_VIEW;
      }else{
        code = SQLITE_CREATE_VIEW;
      }
    }else{
      if( !OMIT_TEMPDB && isTemp ){
        code = SQLITE_CREATE_TEMP_TABLE;
      }else{
        code = SQLITE_CREATE_TABLE;
      }
    }
    if( !isVirtual && sqlite3AuthCheck(pParse, code, zName, 0, zDb) ){
      goto begin_table_error;
    }
  }
#endif

  /* Make sure the new table name does not collide with an existing
  ** index or table name in the same database.  Issue an error message if
  ** it does. The exception is if the statement being parsed was passed
  ** to an sqlite3_declare_vtab() call. In that case only the column names
  ** and types will be used, so there is no need to test for namespace
  ** collisions.
  */
  if( !IN_DECLARE_VTAB ){
    char *zDb = db->aDb[iDb].zName;
    if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
      goto begin_table_error;
    }
    pTable = sqlite3FindTable(db, zName, zDb);
    if( pTable ){
      if( !noErr ){
        sqlite3ErrorMsg(pParse, "table %T already exists", pName);
      }else{
        assert( !db->init.busy || CORRUPT_DB );
        sqlite3CodeVerifySchema(pParse, iDb);
      }
      goto begin_table_error;
    }
    if( sqlite3FindIndex(db, zName, zDb)!=0 ){
      sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
      goto begin_table_error;
    }
  }

  pTable = sqlite3DbMallocZero(db, sizeof(Table));
  if( pTable==0 ){
    db->mallocFailed = 1;
    pParse->rc = SQLITE_NOMEM;
    pParse->nErr++;
    goto begin_table_error;
  }
  pTable->zName = zName;
  pTable->iPKey = -1;
  pTable->pSchema = db->aDb[iDb].pSchema;
  pTable->nRef = 1;
  pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
  assert( pParse->pNewTable==0 );
  pParse->pNewTable = pTable;

  /* If this is the magic sqlite_sequence table used by autoincrement,
  ** then record a pointer to this table in the main database structure
  ** so that INSERT can find the table easily.
  */
#ifndef SQLITE_OMIT_AUTOINCREMENT
  if( !pParse->nested && strcmp(zName, "sqlite_sequence")==0 ){
    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
    pTable->pSchema->pSeqTab = pTable;
  }
#endif

  /* Begin generating the code that will insert the table record into
  ** the SQLITE_MASTER table.  Note in particular that we must go ahead
  ** and allocate the record number for the table entry now.  Before any
  ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause
  ** indices to be created and the table record must come before the 
  ** indices.  Hence, the record number for the table must be allocated
  ** now.
  */
  if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){
    int addr1;
    int fileFormat;
    int reg1, reg2, reg3;
    /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */
    static const char nullRow[] = { 6, 0, 0, 0, 0, 0 };
    sqlite3BeginWriteOperation(pParse, 1, iDb);

#ifndef SQLITE_OMIT_VIRTUALTABLE
    if( isVirtual ){
      sqlite3VdbeAddOp0(v, OP_VBegin);
    }
#endif

    /* If the file format and encoding in the database have not been set, 
    ** set them now.
    */
    reg1 = pParse->regRowid = ++pParse->nMem;
    reg2 = pParse->regRoot = ++pParse->nMem;
    reg3 = ++pParse->nMem;
    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);
    sqlite3VdbeUsesBtree(v, iDb);
    addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);
    fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?
                  1 : SQLITE_MAX_FILE_FORMAT;
    sqlite3VdbeAddOp2(v, OP_Integer, fileFormat, reg3);
    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3);
    sqlite3VdbeAddOp2(v, OP_Integer, ENC(db), reg3);
    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3);
    sqlite3VdbeJumpHere(v, addr1);

    /* This just creates a place-holder record in the sqlite_master table.
    ** The record created does not contain anything yet.  It will be replaced
    ** by the real entry in code generated at sqlite3EndTable().
    **
    ** The rowid for the new entry is left in register pParse->regRowid.
    ** The root page number of the new table is left in reg pParse->regRoot.
    ** The rowid and root page number values are needed by the code that
    ** sqlite3EndTable will generate.
    */
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
    if( isView || isVirtual ){
      sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);
    }else
#endif
    {
      pParse->addrCrTab = sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2);
    }
    sqlite3OpenMasterTable(pParse, iDb);
    sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);
    sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);
    sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1);
    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
    sqlite3VdbeAddOp0(v, OP_Close);
  }

  /* Normal (non-error) return. */
  return;

  /* If an error occurs, we jump here */
begin_table_error:
  sqlite3DbFree(db, zName);
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, -0x38(%rbp)
movl %r8d, -0x44(%rbp)
movl %ecx, %r13d
movq %rdx, %r15
movq %rdi, %rbx
movl 0x10(%rbp), %eax
movl %eax, -0x34(%rbp)
movq (%rdi), %rax
movq %rax, -0x30(%rbp)
leaq -0x58(%rbp), %rcx
callq 0x56195
testl %eax, %eax
js 0x42f19
movl %eax, %r14d
testl %r13d, %r13d
je 0x42dc4
cmpl $0x1, %r14d
movl $0x1, %r14d
je 0x42dc4
cmpl $0x0, 0x8(%r15)
je 0x42dc4
leaq 0x3bd7f(%rip), %rsi     # 0x7eb2b
movq %rbx, %rdi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14804
movq -0x58(%rbp), %r15
movups (%r15), %xmm0
movups %xmm0, 0x238(%rbx)
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x560d9
testq %rax, %rax
je 0x42f19
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x56205
testl %eax, %eax
jne 0x42e4e
movq -0x30(%rbp), %rcx
cmpb $0x1, 0xa0(%rcx)
movl $0x1, %eax
cmovel %eax, %r13d
movq 0x20(%rcx), %rax
movl %r14d, %ecx
shlq $0x5, %rcx
movq %rcx, -0x40(%rbp)
movq (%rax,%rcx), %r8
cmpl $0x1, %r13d
leaq 0x3aea9(%rip), %rax     # 0x7dcd5
leaq 0x3aeb5(%rip), %rdx     # 0x7dce8
cmoveq %rax, %rdx
movq %rbx, %rdi
movl $0x12, %esi
xorl %ecx, %ecx
movq %r8, -0x50(%rbp)
callq 0x5605b
testl %eax, %eax
je 0x42e68
movq -0x30(%rbp), %rdi
movq %r12, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb6df
cmpl $0x0, -0x38(%rbp)
je 0x42f28
cmpb $0x0, 0x1ee(%rbx)
je 0x42f62
movl $0x78, %esi
movq -0x30(%rbp), %r13
movq %r13, %rdi
callq 0x144ee
testq %rax, %rax
je 0x42fb4
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x60(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x70(%rax)
movq %r12, (%rax)
movw $0xffff, 0x3c(%rax)     # imm = 0xFFFF
movq 0x20(%r13), %rax
movq -0x40(%rbp), %rcx
movq 0x18(%rax,%rcx), %r13
movq %r13, 0x68(%r15)
movl $0xc80001, 0x40(%r15)   # imm = 0xC80001
movq %r15, 0x220(%rbx)
cmpb $0x0, 0x1e(%rbx)
jne 0x42f08
leaq 0x3bc97(%rip), %rsi     # 0x7eb8f
movq %r12, %rdi
callq 0xa2b0
testl %eax, %eax
jne 0x42f08
movq %r15, 0x68(%r13)
movq -0x30(%rbp), %rax
cmpb $0x0, 0xa1(%rax)
je 0x42fc8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
xorl %ecx, %ecx
testl %r13d, %r13d
sete %al
setne %cl
cmpl $0x0, -0x44(%rbp)
leal 0x2(%rcx,%rcx), %ecx
leal 0x6(%rax,%rax), %esi
cmovel %ecx, %esi
movq %rbx, %rdi
movq %r12, %rdx
xorl %ecx, %ecx
movq -0x50(%rbp), %r8
callq 0x5605b
testl %eax, %eax
jne 0x42e4e
jmp 0x42e72
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %r13
movq %rbx, %rdi
callq 0x3fd1e
testl %eax, %eax
jne 0x42e4e
movq -0x30(%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1abce
testq %rax, %rax
je 0x430f9
cmpl $0x0, -0x34(%rbp)
je 0x43229
movq %rbx, %rdi
movl %r14d, %esi
callq 0x55b4e
jmp 0x42e4e
movb $0x1, 0x51(%r13)
movl $0x7, 0x18(%rbx)
incl 0x4c(%rbx)
jmp 0x42e4e
movq %rbx, %rdi
callq 0x507bf
testq %rax, %rax
je 0x42f19
movq %rax, %r15
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x5626d
cmpl $0x0, -0x38(%rbp)
je 0x43006
movq %r15, %rdi
movl $0x96, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl 0x54(%rbx), %r12d
leal 0x1(%r12), %eax
movl %eax, -0x34(%rbp)
movl %eax, 0x1a0(%rbx)
leal 0x2(%r12), %eax
movl %eax, -0x40(%rbp)
movl %eax, 0x1a4(%rbx)
addl $0x3, %r12d
movl %r12d, 0x54(%rbx)
movq %r15, %rdi
movl $0x34, %esi
movl %r14d, %edx
movl %r12d, %ecx
movl $0x2, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl %r14d, %esi
callq 0x14a80
movq %r15, %rdi
movl $0x2e, %esi
movl %r12d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %eax, -0x50(%rbp)
xorl %eax, %eax
movq -0x30(%rbp), %r13
cmpw $0x0, 0x2c(%r13)
setns %al
leal (%rax,%rax,2), %edx
incl %edx
movq %r15, %rdi
movl $0x17, %esi
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl $0x35, %esi
movl %r14d, %edx
movl $0x2, %ecx
movl %r12d, %r8d
callq 0x3fa9e
movzbl 0x4e(%r13), %edx
movq %r15, %rdi
movl $0x17, %esi
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl $0x35, %esi
movl %r14d, %edx
movl $0x5, %ecx
movl %r12d, %r8d
callq 0x3fa9e
movl 0x3c(%r15), %eax
leal -0x1(%rax), %ecx
movq 0x30(%r15), %rdx
movl %ecx, 0x68(%rdx)
movq (%r15), %rdx
cmpb $0x0, 0x51(%rdx)
je 0x43123
leaq 0x523f1(%rip), %rcx     # 0x954e8
jmp 0x4313a
movq -0x30(%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3cfc8
testq %rax, %rax
je 0x42e7f
leaq 0x3ba54(%rip), %rsi     # 0x7eb6c
movq %rbx, %rdi
movq %r12, %rdx
jmp 0x43236
movl -0x50(%rbp), %edx
testl %edx, %edx
cmovnsl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%r15), %rcx
movl %eax, 0x8(%rcx)
movl -0x44(%rbp), %eax
orl %eax, -0x38(%rbp)
je 0x4315c
movq %r15, %rdi
movl $0x17, %esi
xorl %edx, %edx
movl -0x40(%rbp), %ecx
xorl %r8d, %r8d
callq 0x3fa9e
jmp 0x43178
movq %r15, %rdi
movl $0x7b, %esi
movl %r14d, %edx
movl -0x40(%rbp), %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %eax, 0x1d0(%rbx)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x562b0
movq %r15, %rdi
movl $0x54, %esi
xorl %edx, %edx
movl -0x34(%rbp), %ebx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl $0x1c, %esi
movl $0x6, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
leaq 0x39857(%rip), %rdx     # 0x7ca10
movq %r15, %rdi
movl %eax, %esi
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x14ab9
movq %r15, %rdi
movl $0x5f, %esi
xorl %edx, %edx
movl %r12d, %ecx
movl %ebx, %r8d
callq 0x3fa9e
movq (%r15), %rax
cmpb $0x0, 0x51(%rax)
je 0x431ef
leaq 0x522fb(%rip), %rax     # 0x954e8
jmp 0x43203
movslq 0x3c(%r15), %rax
movq 0x8(%r15), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x18, %rax
movb $0x8, 0x3(%rax)
movq %r15, %rdi
movl $0x3e, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3fa9e
leaq 0x3b924(%rip), %rsi     # 0x7eb54
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x14804
jmp 0x42e4e