// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3ViewGetColumnNames
SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
  Table *pSelTab;   /* A fake table from which we get the result set */
  Select *pSel;     /* Copy of the SELECT that implements the view */
  int nErr = 0;     /* Number of errors encountered */
  int n;            /* Temporarily holds the number of cursors assigned */
  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */
  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);

  assert( pTable );

#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( sqlite3VtabCallConnect(pParse, pTable) ){
    return SQLITE_ERROR;
  }
  if( IsVirtual(pTable) ) return 0;
#endif

#ifndef SQLITE_OMIT_VIEW
  /* A positive nCol means the columns names for this view are
  ** already known.
  */
  if( pTable->nCol>0 ) return 0;

  /* A negative nCol is a special marker meaning that we are currently
  ** trying to compute the column names.  If we enter this routine with
  ** a negative nCol, it means two or more views form a loop, like this:
  **
  **     CREATE VIEW one AS SELECT * FROM two;
  **     CREATE VIEW two AS SELECT * FROM one;
  **
  ** Actually, the error above is now caught prior to reaching this point.
  ** But the following test is still important as it does come up
  ** in the following:
  ** 
  **     CREATE TABLE main.ex1(a);
  **     CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;
  **     SELECT * FROM temp.ex1;
  */
  if( pTable->nCol<0 ){
    sqlite3ErrorMsg(pParse, "view %s is circularly defined", pTable->zName);
    return 1;
  }
  assert( pTable->nCol>=0 );

  /* If we get this far, it means we need to compute the table names.
  ** Note that the call to sqlite3ResultSetOfSelect() will expand any
  ** "*" elements in the results set of the view and will assign cursors
  ** to the elements of the FROM clause.  But we do not want these changes
  ** to be permanent.  So the computation is done on a copy of the SELECT
  ** statement that defines the view.
  */
  assert( pTable->pSelect );
  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
  if( pSel ){
    u8 enableLookaside = db->lookaside.bEnabled;
    n = pParse->nTab;
    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
    pTable->nCol = -1;
    db->lookaside.bEnabled = 0;
#ifndef SQLITE_OMIT_AUTHORIZATION
    xAuth = db->xAuth;
    db->xAuth = 0;
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
    db->xAuth = xAuth;
#else
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);
#endif
    db->lookaside.bEnabled = enableLookaside;
    pParse->nTab = n;
    if( pSelTab ){
      assert( pTable->aCol==0 );
      pTable->nCol = pSelTab->nCol;
      pTable->aCol = pSelTab->aCol;
      pSelTab->nCol = 0;
      pSelTab->aCol = 0;
      sqlite3DeleteTable(db, pSelTab);
      assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
      pTable->pSchema->flags |= DB_UnresetViews;
    }else{
      pTable->nCol = 0;
      nErr++;
    }
    sqlite3SelectDelete(db, pSel);
  } else {
    nErr++;
  }
#endif /* SQLITE_OMIT_VIEW */
  return nErr;  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x64910
cmpl $0x0, %eax
je 0x641c0
movl $0x1, -0x4(%rbp)
jmp 0x6436b
movq -0x18(%rbp), %rax
movzbl 0x46(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x641dc
movl $0x0, -0x4(%rbp)
jmp 0x6436b
movq -0x18(%rbp), %rax
movswl 0x42(%rax), %eax
cmpl $0x0, %eax
jle 0x641f5
movl $0x0, -0x4(%rbp)
jmp 0x6436b
movq -0x18(%rbp), %rax
movswl 0x42(%rax), %eax
cmpl $0x0, %eax
jge 0x64227
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq 0x4ba7f(%rip), %rsi     # 0xafc93
movb $0x0, %al
callq 0x136f0
movl $0x1, -0x4(%rbp)
jmp 0x6436b
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rsi
xorl %edx, %edx
callq 0x61ba0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6435c
movq -0x38(%rbp), %rax
movb 0x152(%rax), %al
movb %al, -0x41(%rbp)
movq -0x10(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x63c40
movq -0x18(%rbp), %rax
movw $0xffff, 0x42(%rax)     # imm = 0xFFFF
movq -0x38(%rbp), %rax
movb $0x0, 0x152(%rax)
movq -0x38(%rbp), %rax
movq 0x180(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq $0x0, 0x180(%rax)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5ef70
movq %rax, -0x20(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x180(%rax)
movb -0x41(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, 0x152(%rax)
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x54(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x6433a
movq -0x20(%rbp), %rax
movw 0x42(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x42(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movw $0x0, 0x42(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x9a30
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movzwl 0x72(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x72(%rax)
jmp 0x6434d
movq -0x18(%rbp), %rax
movw $0x0, 0x42(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47420
jmp 0x64365
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)