// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/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 */
  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");
    sqlite3SelectDelete(db, pSelect);
    return;
  }
  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);
  p = pParse->pNewTable;
  if( p==0 || pParse->nErr ){
    sqlite3SelectDelete(db, pSelect);
    return;
  }
  sqlite3TwoPartName(pParse, pName1, pName2, &pName);
  iDb = sqlite3SchemaToIndex(db, p->pSchema);
  if( sqlite3FixInit(&sFix, pParse, iDb, "view", pName)
    && sqlite3FixSelect(&sFix, pSelect)
  ){
    sqlite3SelectDelete(db, pSelect);
    return;
  }

  /* 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.
  */
  p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
  sqlite3SelectDelete(db, pSelect);
  if( db->mallocFailed ){
    return;
  }
  if( !db->init.busy ){
    sqlite3ViewGetColumnNames(pParse, p);
  }

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r15
movq %rdi, %rbx
movl 0x10(%rbp), %eax
movq $0x0, -0x38(%rbp)
movq (%rdi), %r12
cmpl $0x0, 0x1f8(%rdi)
jle 0x3be56
leaq 0x3fa88(%rip), %rsi     # 0x7b8bb
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11842
movq %r12, %rdi
movq %r15, %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x34827
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, -0x30(%rbp)
movl %eax, (%rsp)
movq %rbx, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movl %r9d, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x39a76
movq 0x238(%rbx), %rax
testq %rax, %rax
je 0x3be3d
cmpl $0x0, 0x50(%rbx)
jne 0x3be3d
leaq -0x38(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rax, %r13
callq 0x46237
movq %r13, %r14
movq 0x68(%r13), %rcx
testq %rcx, %rcx
je 0x3bf36
movl 0x28(%r12), %edx
testl %edx, %edx
jle 0x3bedd
movq 0x20(%r12), %rsi
addq $0x18, %rsi
xorl %eax, %eax
cmpq %rcx, (%rsi)
je 0x3bedf
incq %rax
addq $0x20, %rsi
cmpq %rax, %rdx
jne 0x3bec8
movl %edx, %eax
jmp 0x3bedf
xorl %eax, %eax
testl %eax, %eax
sets %cl
cmpl $0x1, %eax
sete %dl
orb %cl, %dl
jne 0x3bf36
movq -0x38(%rbp), %rcx
movq (%rbx), %rdx
leaq -0x78(%rbp), %rdi
movq %rbx, (%rdi)
movq 0x20(%rdx), %rdx
movl %eax, %eax
shlq $0x5, %rax
movq (%rdx,%rax), %rsi
movq %rsi, 0x10(%rdi)
movq 0x18(%rdx,%rax), %rax
movq %rax, 0x8(%rdi)
leaq 0x40dda(%rip), %rax     # 0x7ccf8
movq %rax, 0x18(%rdi)
movq %rcx, 0x20(%rdi)
movq %r15, %rsi
callq 0x4c1c9
testl %eax, %eax
jne 0x3be3d
movq %r12, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x48744
movq %rax, 0x18(%r14)
movq %r12, %rdi
movq %r15, %rsi
callq 0x34827
cmpb $0x0, 0x50(%r12)
jne 0x3bfed
cmpb $0x0, 0x99(%r12)
jne 0x3bf77
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4a4d2
movups 0x260(%rbx), %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x3bf9e
cmpl $0x3b, %ecx
movq -0x30(%rbp), %rdx
je 0x3bfa2
movl -0x48(%rbp), %ecx
addq %rcx, %rax
jmp 0x3bfa2
movq -0x30(%rbp), %rdx
movq (%rdx), %rcx
subl %ecx, %eax
testl %eax, %eax
jle 0x3bfcb
leaq 0x39ffe(%rip), %rdx     # 0x75fb0
movl %eax, %esi
movzbl -0x1(%rcx,%rsi), %esi
testb $0x1, (%rsi,%rdx)
je 0x3bfcb
leal -0x1(%rax), %esi
cmpl $0x1, %eax
movl %esi, %eax
jg 0x3bfb2
xorl %eax, %eax
cltq
addq %rcx, %rax
decq %rax
leaq -0x50(%rbp), %rdx
movq %rax, (%rdx)
movl $0x1, 0x8(%rdx)
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x39f35
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq