// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/sqlite3.c
// Function: columnTypeImpl
static const char *columnTypeImpl(
  NameContext *pNC, 
  Expr *pExpr,
  u8 *pEstWidth
){
#endif /* !defined(SQLITE_ENABLE_COLUMN_METADATA) */
  char const *zType = 0;
  int j;
  u8 estWidth = 1;

  if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
  switch( pExpr->op ){
    case TK_AGG_COLUMN:
    case TK_COLUMN: {
      /* The expression is a column. Locate the table the column is being
      ** extracted from in NameContext.pSrcList. This table may be real
      ** database table or a subquery.
      */
      Table *pTab = 0;            /* Table structure column is extracted from */
      Select *pS = 0;             /* Select the column is extracted from */
      int iCol = pExpr->iColumn;  /* Index of column in pTab */
      testcase( pExpr->op==TK_AGG_COLUMN );
      testcase( pExpr->op==TK_COLUMN );
      while( pNC && !pTab ){
        SrcList *pTabList = pNC->pSrcList;
        for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
        if( j<pTabList->nSrc ){
          pTab = pTabList->a[j].pTab;
          pS = pTabList->a[j].pSelect;
        }else{
          pNC = pNC->pNext;
        }
      }

      if( pTab==0 ){
        /* At one time, code such as "SELECT new.x" within a trigger would
        ** cause this condition to run.  Since then, we have restructured how
        ** trigger code is generated and so this condition is no longer 
        ** possible. However, it can still be true for statements like
        ** the following:
        **
        **   CREATE TABLE t1(col INTEGER);
        **   SELECT (SELECT t1.col) FROM FROM t1;
        **
        ** when columnType() is called on the expression "t1.col" in the 
        ** sub-select. In this case, set the column type to NULL, even
        ** though it should really be "INTEGER".
        **
        ** This is not a problem, as the column type of "t1.col" is never
        ** used. When columnType() is called on the expression 
        ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
        ** branch below.  */
        break;
      }

      assert( pTab && pExpr->pTab==pTab );
      if( pS ){
        /* The "table" is actually a sub-select or a view in the FROM clause
        ** of the SELECT statement. Return the declaration type and origin
        ** data for the result-set column of the sub-select.
        */
        if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){
          /* If iCol is less than zero, then the expression requests the
          ** rowid of the sub-select or view. This expression is legal (see 
          ** test case misc2.2.2) - it always evaluates to NULL.
          */
          NameContext sNC;
          Expr *p = pS->pEList->a[iCol].pExpr;
          sNC.pSrcList = pS->pSrc;
          sNC.pNext = pNC;
          sNC.pParse = pNC->pParse;
          zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol, &estWidth); 
        }
      }else if( ALWAYS(pTab->pSchema) ){
        /* A real table */
        assert( !pS );
        if( iCol<0 ) iCol = pTab->iPKey;
        assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
#ifdef SQLITE_ENABLE_COLUMN_METADATA
        if( iCol<0 ){
          zType = "INTEGER";
          zOrigCol = "rowid";
        }else{
          zType = pTab->aCol[iCol].zType;
          zOrigCol = pTab->aCol[iCol].zName;
          estWidth = pTab->aCol[iCol].szEst;
        }
        zOrigTab = pTab->zName;
        if( pNC->pParse ){
          int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);
          zOrigDb = pNC->pParse->db->aDb[iDb].zName;
        }
#else
        if( iCol<0 ){
          zType = "INTEGER";
        }else{
          zType = pTab->aCol[iCol].zType;
          estWidth = pTab->aCol[iCol].szEst;
        }
#endif
      }
      break;
    }
#ifndef SQLITE_OMIT_SUBQUERY
    case TK_SELECT: {
      /* The expression is a sub-select. Return the declaration type and
      ** origin info for the single column in the result set of the SELECT
      ** statement.
      */
      NameContext sNC;
      Select *pS = pExpr->x.pSelect;
      Expr *p = pS->pEList->a[0].pExpr;
      assert( ExprHasProperty(pExpr, EP_xIsSelect) );
      sNC.pSrcList = pS->pSrc;
      sNC.pNext = pNC;
      sNC.pParse = pNC->pParse;
      zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol, &estWidth); 
      break;
    }
#endif
  }

#ifdef SQLITE_ENABLE_COLUMN_METADATA  
  if( pzOrigDb ){
    assert( pzOrigTab && pzOrigCol );
    *pzOrigDb = zOrigDb;
    *pzOrigTab = zOrigTab;
    *pzOrigCol = zOrigCol;
  }
#endif
  if( pEstWidth ) *pEstWidth = estWidth;
  return zType;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movb $0x1, -0x2d(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x70b65
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x70b72
movq $0x0, -0x8(%rbp)
jmp 0x70e28
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0xdc(%rbp)
subl $0x75, %eax
je 0x70da3
jmp 0x70b8a
movl -0xdc(%rbp), %eax
subl $0x99, %eax
je 0x70bac
jmp 0x70b99
movl -0xdc(%rbp), %eax
subl $0x9b, %eax
jne 0x70e10
jmp 0x70bac
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x18(%rbp), %rax
movswl 0x30(%rax), %eax
movl %eax, -0x44(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0xdd(%rbp)
je 0x70be6
cmpq $0x0, -0x38(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0xdd(%rbp)
movb -0xdd(%rbp), %al
testb $0x1, %al
jne 0x70bf5
jmp 0x70cb4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x50(%rbp), %rax
movzbl (%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0xde(%rbp)
jge 0x70c44
movq -0x50(%rbp), %rax
addq $0x8, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x3c(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
setne %al
movb %al, -0xde(%rbp)
movb -0xde(%rbp), %al
testb $0x1, %al
jne 0x70c50
jmp 0x70c5d
jmp 0x70c52
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x70c08
movl -0x2c(%rbp), %eax
movq -0x50(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x70ca3
movq -0x50(%rbp), %rax
addq $0x8, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
addq $0x8, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x70caf
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x70bc7
cmpq $0x0, -0x38(%rbp)
jne 0x70cc0
jmp 0x70e10
cmpq $0x0, -0x40(%rbp)
je 0x70d3a
cmpl $0x0, -0x44(%rbp)
jl 0x70d38
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x70d38
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x90(%rbp), %rsi
leaq -0x88(%rbp), %rdi
leaq -0x2d(%rbp), %rdx
callq 0x70b30
movq %rax, -0x28(%rbp)
jmp 0x70da1
movq -0x38(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x70d9f
cmpl $0x0, -0x44(%rbp)
jge 0x70d56
movq -0x38(%rbp), %rax
movswl 0x40(%rax), %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x70d69
leaq 0x29ffb(%rip), %rax     # 0x9ad5e
movq %rax, -0x28(%rbp)
jmp 0x70d9d
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movb 0x2a(%rax), %al
movb %al, -0x2d(%rbp)
jmp 0x70d9f
jmp 0x70da1
jmp 0x70e10
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xd8(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
leaq -0x2d(%rbp), %rdx
callq 0x70b30
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x70e20
movb -0x2d(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)