// File: /workspace/github_c_makefile_star2_O0/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
subq $0xb0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1f8(%rax)
jle 0x52773
movq -0x8(%rbp), %rdi
leaq 0x5dc60(%rip), %rsi     # 0xb03b7
movb $0x0, %al
callq 0x136f0
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47420
jmp 0x5298f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movl 0x10(%rbp), %eax
movl $0x1, %r8d
xorl %r9d, %r9d
movl %eax, (%rsp)
callq 0x4fb10
movq -0x8(%rbp), %rax
movq 0x238(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x527b6
movq -0x8(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x527cb
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47420
jmp 0x5298f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x5e9c0
movq -0x98(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x13940
movl %eax, -0x8c(%rbp)
movq -0x8(%rbp), %rsi
movl -0x8c(%rbp), %edx
movq -0x88(%rbp), %r8
leaq -0x80(%rbp), %rdi
leaq 0x5efdb(%rip), %rcx     # 0xb17f4
callq 0x66d20
cmpl $0x0, %eax
je 0x5284a
movq -0x28(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x67320
cmpl $0x0, %eax
je 0x5284a
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47420
jmp 0x5298f
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0x61ba0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x98(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47420
movq -0x98(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0x5288c
jmp 0x5298f
movq -0x98(%rbp), %rax
cmpb $0x0, 0x99(%rax)
jne 0x528a9
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x64180
movq -0x8(%rbp), %rax
movq 0x260(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x268(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x528eb
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
je 0x528eb
movl -0x50(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x3c(%rbp)
movb %al, -0x99(%rbp)
jle 0x52949
movq -0x48(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x5810a(%rip), %rax     # 0xaaa40
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x52955
jmp 0x52960
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5290e
movq -0x48(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x1, -0x50(%rbp)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x58(%rbp), %rdx
movq %rcx, %rsi
callq 0x50070
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)