// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/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 */
#ifndef SQLITE_OMIT_VIRTUALTABLE
  int rc;
#endif
#ifndef SQLITE_OMIT_AUTHORIZATION
  sqlite3_xauth xAuth;       /* Saved xAuth pointer */
#endif

  assert( pTable );

#ifndef SQLITE_OMIT_VIRTUALTABLE
  db->nSchemaLock++;
  rc = sqlite3VtabCallConnect(pParse, pTable);
  db->nSchemaLock--;
  if( rc ){
    return 1;
  }
  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 eParseMode = pParse->eParseMode;
    pParse->eParseMode = PARSE_MODE_NORMAL;
    n = pParse->nTab;
    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);
    pTable->nCol = -1;
    DisableLookaside;
#ifndef SQLITE_OMIT_AUTHORIZATION
    xAuth = db->xAuth;
    db->xAuth = 0;
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
    db->xAuth = xAuth;
#else
    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);
#endif
    pParse->nTab = n;
    if( pSelTab==0 ){
      pTable->nCol = 0;
      nErr++;
    }else if( pTable->pCheck ){
      /* CREATE VIEW name(arglist) AS ...
      ** The names of the columns in the table are taken from
      ** arglist which is stored in pTable->pCheck.  The pCheck field
      ** normally holds CHECK constraints on an ordinary table, but for
      ** a VIEW it holds the list of column names.
      */
      sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
                                 &pTable->nCol, &pTable->aCol);
      if( db->mallocFailed==0
       && pParse->nErr==0
       && pTable->nCol==pSel->pEList->nExpr
      ){
        sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,
                                               SQLITE_AFF_NONE);
      }
    }else{
      /* CREATE VIEW name AS...  without an argument list.  Construct
      ** the column names from the SELECT statement that defines the view.
      */
      assert( pTable->aCol==0 );
      pTable->nCol = pSelTab->nCol;
      pTable->aCol = pSelTab->aCol;
      pSelTab->nCol = 0;
      pSelTab->aCol = 0;
      assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );
    }
    pTable->nNVCol = pTable->nCol;
    sqlite3DeleteTable(db, pSelTab);
    sqlite3SelectDelete(db, pSel);
    EnableLookaside;
    pParse->eParseMode = eParseMode;
  } else {
    nErr++;
  }
  pTable->pSchema->schemaFlags |= DB_UnresetViews;
  if( db->mallocFailed ){
    sqlite3DeleteColumnNames(db, pTable);
    pTable->aCol = 0;
    pTable->nCol = 0;
  }
#endif /* SQLITE_OMIT_VIEW */
  return nErr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rbx
movl 0x48(%rbx), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x48(%rbx)
movl 0x54(%rsi), %eax
testl %eax, %eax
je 0x2c8551
movq 0x60(%r14), %rdx
testq %rdx, %rdx
je 0x2c8666
cmpq %rbx, (%rdx)
je 0x2c8551
movq 0x28(%rdx), %rdx
jmp 0x2c853d
movl %ecx, 0x48(%rbx)
xorl %ebp, %ebp
testl %eax, %eax
jne 0x2c870e
leaq 0x46(%r14), %r13
cmpw $0x0, 0x46(%r14)
jg 0x2c870e
js 0x2c871f
movq 0x18(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2c2b4a
testq %rax, %rax
je 0x2c8735
movq %rax, %r12
movb 0x11c(%r15), %al
movb %al, 0x7(%rsp)
movb $0x0, 0x11c(%r15)
movl 0x34(%r15), %eax
movl %eax, 0x8(%rsp)
movq 0x28(%r12), %rsi
movq %r15, %rdi
callq 0x2c8465
movw $0xffff, (%r13)         # imm = 0xFFFF
incl 0x170(%rbx)
movw $0x0, 0x174(%rbx)
movq 0x1c8(%rbx), %rbp
movq $0x0, 0x1c8(%rbx)
movq %r15, %rdi
movq %r12, %rsi
movl $0x40, %edx
callq 0x2c4234
movq %rbp, 0x1c8(%rbx)
movl 0x8(%rsp), %ecx
movl %ecx, 0x34(%r15)
testq %rax, %rax
je 0x2c873c
movq 0x30(%r14), %rsi
testq %rsi, %rsi
je 0x2c874a
movq %rax, 0x8(%rsp)
leaq 0x8(%r14), %rcx
movq (%r15), %rdi
movq %r13, %rdx
callq 0x2c8c0a
xorl %ebp, %ebp
cmpb $0x0, 0x61(%rbx)
jne 0x2c8657
cmpl $0x0, 0x30(%r15)
jne 0x2c8657
movswl (%r13), %eax
movq 0x20(%r12), %rcx
cmpl %eax, (%rcx)
jne 0x2c8657
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl $0x40, %ecx
callq 0x2c8fcf
movb 0x7(%rsp), %r13b
movq 0x8(%rsp), %rax
jmp 0x2c8770
movq 0x58(%r14), %rax
movq (%rax), %r12
leaq 0x1f0(%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2a547e
movq 0x10(%rax), %rdx
testq %rdx, %rdx
je 0x2c86f2
leaq 0x10(%rsp), %r13
movq $0x0, (%r13)
movq (%rdx), %rax
movq 0x10(%rax), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %r8
callq 0x2a78df
movl %eax, %r12d
movq (%r13), %r13
testl %eax, %eax
je 0x2c86cc
leaq 0x1003ee(%rip), %rsi    # 0x3c8aa9
movq %r15, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x27b48d
movl %r12d, 0x18(%r15)
testq %r13, %r13
je 0x2c86dc
movq %rbx, %rdi
movq %r13, %rsi
callq 0x282904
decl 0x48(%rbx)
movl $0x1, %ebp
testl %r12d, %r12d
jne 0x2c870e
movl 0x54(%r14), %eax
jmp 0x2c8554
leaq 0x10e61d(%rip), %rsi    # 0x3d6d16
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x27b48d
decl 0x48(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdx
leaq 0x10f751(%rip), %rsi    # 0x3d7e7a
movq %r15, %rdi
xorl %eax, %eax
callq 0x27b48d
jmp 0x2c8709
movl $0x1, %ebp
jmp 0x2c87b6
movw $0x0, (%r13)
movl $0x1, %ebp
jmp 0x2c876b
movzwl 0x46(%rax), %ecx
movw %cx, 0x46(%r14)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%r14)
movw $0x0, 0x46(%rax)
movq $0x0, 0x8(%rax)
xorl %ebp, %ebp
movb 0x7(%rsp), %r13b
movzwl 0x46(%r14), %ecx
movw %cx, 0x48(%r14)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x272447
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x2a62e6
decl 0x170(%rbx)
je 0x2c87a1
xorl %eax, %eax
jmp 0x2c87a8
movzwl 0x176(%rbx), %eax
movw %ax, 0x174(%rbx)
movb %r13b, 0x11c(%r15)
movq 0x70(%r14), %rax
orw $0x2, 0x72(%rax)
cmpb $0x0, 0x61(%rbx)
je 0x2c870e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a9368
movq $0x0, 0x8(%r14)
movw $0x0, 0x46(%r14)
jmp 0x2c870e