// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movq %r9, %r12
movq %r8, %rbx
movq %rdi, %r15
movq $0x0, 0x28(%rsp)
movq (%rdi), %r14
cmpw $0x0, 0x118(%rdi)
jle 0x2b90c0
leaq 0x128dc0(%rip), %rsi    # 0x3e1e2d
movq %r15, %rdi
xorl %eax, %eax
callq 0x284eb8
testq %r12, %r12
je 0x2b908c
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x2afecb
cmpb $0x2, 0x11c(%r15)
jb 0x2b90a1
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2d3412
testq %rbx, %rbx
je 0x2b90b1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2b0183
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, 0x30(%rsp)
movl 0xa8(%rsp), %eax
movl 0xa0(%rsp), %ecx
movl %eax, (%rsp)
movq %r15, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x2b5f23
movq 0x148(%r15), %rax
testq %rax, %rax
je 0x2b9077
cmpl $0x0, 0x30(%r15)
jne 0x2b9077
leaq 0x28(%rsp), %rcx
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rax, %rbp
callq 0x2ccf63
movq %rbp, %r13
movq 0x70(%rbp), %rcx
testq %rcx, %rcx
je 0x2b914d
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 0x2b913d
jmp 0x2b9152
movl $0xffff8000, %eax       # imm = 0xFFFF8000
movq 0x28(%rsp), %rcx
movq (%r15), %rdx
leaq 0x38(%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 0x12945c(%rip), %rdx    # 0x3e25e3
movq %rdx, 0x20(%rdi)
movq %rcx, 0x28(%rdi)
cmpl $0x1, %eax
sete 0x10(%rdi)
movq %r12, %rsi
callq 0x2d3c19
testl %eax, %eax
jne 0x2b9077
orb $0x20, 0x6(%r12)
cmpb $0x1, 0x11c(%r15)
jbe 0x2b91be
movq %r12, %rax
xorl %r12d, %r12d
jmp 0x2b91ce
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x2cc285
movq %rax, 0x18(%r13)
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x2cc525
movq %rax, 0x30(%r13)
cmpb $0x0, 0x61(%r14)
jne 0x2b9077
movups 0x108(%r15), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpb $0x3b, (%rax)
je 0x2b9214
movl 0x18(%rsp), %ecx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl 0x10(%rsp), %eax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
subl %ecx, %eax
cltq
addq %rcx, %rax
leaq 0x12198a(%rip), %rcx    # 0x3dabc0
movzbl -0x1(%rax), %edx
decq %rax
testb $0x1, (%rdx,%rcx)
jne 0x2b9236
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movl $0x1, 0x8(%rdx)
movq %r15, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b642a
jmp 0x2b9077