// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3CreateView
SQLITE_PRIVATE void sqlite3CreateView(
  Parse *pParse,     /* The parsing context */
  Token *pBegin,     /* The CREATE token that begins the statement */
  Token *pName1,     /* The token that holds the name of the view */
  Token *pName2,     /* The token that holds the name of the view */
  ExprList *pCNames, /* Optional list of view column names */
  Select *pSelect,   /* A SELECT statement that will become the new view */
  int isTemp,        /* TRUE for a TEMPORARY view */
  int noErr          /* Suppress error messages if VIEW already exists */
){
  Table *p;
  int n;
  const char *z;
  Token sEnd;
  DbFixer sFix;
  Token *pName = 0;
  int iDb;
  sqlite3 *db = pParse->db;

  if( pParse->nVar>0 ){
    sqlite3ErrorMsg(pParse, "parameters are not allowed in views");
    goto create_view_fail;
  }
  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);
  p = pParse->pNewTable;
  if( p==0 || pParse->nErr ) goto create_view_fail;
  sqlite3TwoPartName(pParse, pName1, pName2, &pName);
  iDb = sqlite3SchemaToIndex(db, p->pSchema);
  sqlite3FixInit(&sFix, pParse, iDb, "view", pName);
  if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;

  /* Make a copy of the entire SELECT statement that defines the view.
  ** This will force all the Expr.token.z values to be dynamically
  ** allocated rather than point to the input string - which means that
  ** they will persist after the current sqlite3_exec() call returns.
  */
  pSelect->selFlags |= SF_View;
  if( IN_RENAME_OBJECT ){
    p->pSelect = pSelect;
    pSelect = 0;
  }else{
    p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
  }
  p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
  if( db->mallocFailed ) goto create_view_fail;

  /* Locate the end of the CREATE VIEW statement.  Make sEnd point to
  ** the end.
  */
  sEnd = pParse->sLastToken;
  assert( sEnd.z[0]!=0 || sEnd.n==0 );
  if( sEnd.z[0]!=';' ){
    sEnd.z += sEnd.n;
  }
  sEnd.n = 0;
  n = (int)(sEnd.z - pBegin->z);
  assert( n>0 );
  z = pBegin->z;
  while( sqlite3Isspace(z[n-1]) ){ n--; }
  sEnd.z = &z[n-1];
  sEnd.n = 1;

  /* Use sqlite3EndTable() to add the view to the schema table */
  sqlite3EndTable(pParse, 0, &sEnd, 0, 0);

create_view_fail:
  sqlite3SelectDelete(db, pSelect);
  if( IN_RENAME_OBJECT ){
    sqlite3RenameExprlistUnmap(pParse, pCNames);
  }
  sqlite3ExprListDelete(db, pCNames);
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r12
movq %r8, %rbx
movq %rdi, %r15
movq $0x0, 0x8(%rsp)
movq (%rdi), %r14
cmpw $0x0, 0x118(%rdi)
jle 0x2af4b2
leaq 0x129279(%rip), %rsi    # 0x3d86d8
movq %r15, %rdi
xorl %eax, %eax
callq 0x27b48d
testq %r12, %r12
je 0x2af47e
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x2a62e6
cmpb $0x2, 0x11c(%r15)
jb 0x2af493
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2c9b69
testq %rbx, %rbx
je 0x2af4a3
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a65a3
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, 0x20(%rsp)
movl 0x98(%rsp), %eax
movl 0x90(%rsp), %ecx
movl %eax, (%rsp)
movq %r15, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x2ac327
movq 0x148(%r15), %rax
testq %rax, %rax
je 0x2af469
cmpl $0x0, 0x30(%r15)
jne 0x2af469
leaq 0x8(%rsp), %rcx
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rax, %rbp
callq 0x2c3833
movq %rbp, %r13
movq 0x70(%rbp), %rcx
testq %rcx, %rcx
je 0x2af53f
movq 0x20(%r14), %rdx
addq $0x18, %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
leaq 0x20(%rdx), %rsi
cmpq %rcx, (%rdx)
movq %rsi, %rdx
jne 0x2af52f
jmp 0x2af544
movl $0xffff8000, %eax       # imm = 0xFFFF8000
movq 0x8(%rsp), %rcx
movq (%r15), %rdx
leaq 0x28(%rsp), %rdi
movq %r15, (%rdi)
movq 0x20(%rdx), %rdx
cltq
movq %rax, %rsi
shlq $0x5, %rsi
movq (%rdx,%rsi), %r8
movq %r8, 0x18(%rdi)
movq 0x18(%rdx,%rsi), %rdx
movq %rdx, 0x8(%rdi)
leaq 0x129915(%rip), %rdx    # 0x3d8e8e
movq %rdx, 0x20(%rdi)
movq %rcx, 0x28(%rdi)
cmpl $0x1, %eax
sete 0x10(%rdi)
movq %r12, %rsi
callq 0x2ca34d
testl %eax, %eax
jne 0x2af469
orb $0x20, 0x6(%r12)
cmpb $0x1, 0x11c(%r15)
jbe 0x2af5b0
movq %r12, %rax
xorl %r12d, %r12d
jmp 0x2af5c0
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x2c2b4a
movq %rax, 0x18(%r13)
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x2c2deb
movq %rax, 0x30(%r13)
cmpb $0x0, 0x61(%r14)
jne 0x2af469
movups 0x108(%r15), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rsp), %rax
xorl %ecx, %ecx
cmpb $0x3b, (%rax)
je 0x2af600
movl 0x18(%rsp), %ecx
addl %ecx, %eax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
subl %ecx, %eax
cltq
addq %rcx, %rax
leaq 0x121e28(%rip), %rcx    # 0x3d1440
movzbl -0x1(%rax), %edx
decq %rax
testb $0x1, (%rdx,%rcx)
jne 0x2af618
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movl $0x1, 0x8(%rdx)
movq %r15, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2ac848
jmp 0x2af469