// File: /workspace/github_c_makefile_star2_O2/skeeto[P]flappy/sqlite3.c
// Function: resolveExprStep
static int resolveExprStep(Walker *pWalker, Expr *pExpr){
  NameContext *pNC;
  Parse *pParse;

  pNC = pWalker->u.pNC;
  assert( pNC!=0 );
  pParse = pNC->pParse;
  assert( pParse==pWalker->pParse );

  if( ExprHasProperty(pExpr, EP_Resolved) ) return WRC_Prune;
  ExprSetProperty(pExpr, EP_Resolved);
#ifndef NDEBUG
  if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){
    SrcList *pSrcList = pNC->pSrcList;
    int i;
    for(i=0; i<pNC->pSrcList->nSrc; i++){
      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);
    }
  }
#endif
  switch( pExpr->op ){

#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
    /* The special operator TK_ROW means use the rowid for the first
    ** column in the FROM clause.  This is used by the LIMIT and ORDER BY
    ** clause processing on UPDATE and DELETE statements.
    */
    case TK_ROW: {
      SrcList *pSrcList = pNC->pSrcList;
      struct SrcList_item *pItem;
      assert( pSrcList && pSrcList->nSrc==1 );
      pItem = pSrcList->a; 
      pExpr->op = TK_COLUMN;
      pExpr->pTab = pItem->pTab;
      pExpr->iTable = pItem->iCursor;
      pExpr->iColumn = -1;
      pExpr->affinity = SQLITE_AFF_INTEGER;
      break;
    }
#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */

    /* A lone identifier is the name of a column.
    */
    case TK_ID: {
      return lookupName(pParse, 0, 0, pExpr->u.zToken, pNC, pExpr);
    }
  
    /* A table name and column name:     ID.ID
    ** Or a database, table and column:  ID.ID.ID
    */
    case TK_DOT: {
      const char *zColumn;
      const char *zTable;
      const char *zDb;
      Expr *pRight;

      /* if( pSrcList==0 ) break; */
      pRight = pExpr->pRight;
      if( pRight->op==TK_ID ){
        zDb = 0;
        zTable = pExpr->pLeft->u.zToken;
        zColumn = pRight->u.zToken;
      }else{
        assert( pRight->op==TK_DOT );
        zDb = pExpr->pLeft->u.zToken;
        zTable = pRight->pLeft->u.zToken;
        zColumn = pRight->pRight->u.zToken;
      }
      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
    }

    /* Resolve function names
    */
    case TK_FUNCTION: {
      ExprList *pList = pExpr->x.pList;    /* The argument list */
      int n = pList ? pList->nExpr : 0;    /* Number of arguments */
      int no_such_func = 0;       /* True if no such function exists */
      int wrong_num_args = 0;     /* True if wrong number of arguments */
      int is_agg = 0;             /* True if is an aggregate function */
      int auth;                   /* Authorization to use the function */
      int nId;                    /* Number of characters in function name */
      const char *zId;            /* The function name. */
      FuncDef *pDef;              /* Information about the function */
      u8 enc = ENC(pParse->db);   /* The database encoding */

      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
      notValidPartIdxWhere(pParse, pNC, "functions");
      zId = pExpr->u.zToken;
      nId = sqlite3Strlen30(zId);
      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
      if( pDef==0 ){
        pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
        if( pDef==0 ){
          no_such_func = 1;
        }else{
          wrong_num_args = 1;
        }
      }else{
        is_agg = pDef->xFunc==0;
        if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){
          ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);
          if( n==2 ){
            pExpr->iTable = exprProbability(pList->a[1].pExpr);
            if( pExpr->iTable<0 ){
              sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
                                      "constant between 0.0 and 1.0");
              pNC->nErr++;
            }
          }else{
            /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
            ** likelihood(X, 0.0625).
            ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for
            ** likelihood(X,0.0625). */
            pExpr->iTable = 62;  /* TUNING:  Default 2nd arg to unlikely() is 0.0625 */
          }             
        }
      }
#ifndef SQLITE_OMIT_AUTHORIZATION
      if( pDef ){
        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
        if( auth!=SQLITE_OK ){
          if( auth==SQLITE_DENY ){
            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
                                    pDef->zName);
            pNC->nErr++;
          }
          pExpr->op = TK_NULL;
          return WRC_Prune;
        }
        if( pDef->funcFlags & SQLITE_FUNC_CONSTANT ) ExprSetProperty(pExpr,EP_Constant);
      }
#endif
      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
        pNC->nErr++;
        is_agg = 0;
      }else if( no_such_func && pParse->db->init.busy==0 ){
        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
        pNC->nErr++;
      }else if( wrong_num_args ){
        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
             nId, zId);
        pNC->nErr++;
      }
      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;
      sqlite3WalkExprList(pWalker, pList);
      if( is_agg ){
        NameContext *pNC2 = pNC;
        pExpr->op = TK_AGG_FUNCTION;
        pExpr->op2 = 0;
        while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){
          pExpr->op2++;
          pNC2 = pNC2->pNext;
        }
        if( pNC2 ) pNC2->ncFlags |= NC_HasAgg;
        pNC->ncFlags |= NC_AllowAgg;
      }
      /* FIX ME:  Compute pExpr->affinity based on the expected return
      ** type of the function 
      */
      return WRC_Prune;
    }
#ifndef SQLITE_OMIT_SUBQUERY
    case TK_SELECT:
    case TK_EXISTS:  testcase( pExpr->op==TK_EXISTS );
#endif
    case TK_IN: {
      testcase( pExpr->op==TK_IN );
      if( ExprHasProperty(pExpr, EP_xIsSelect) ){
        int nRef = pNC->nRef;
        notValidCheckConstraint(pParse, pNC, "subqueries");
        notValidPartIdxWhere(pParse, pNC, "subqueries");
        sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
        assert( pNC->nRef>=nRef );
        if( nRef!=pNC->nRef ){
          ExprSetProperty(pExpr, EP_VarSelect);
        }
      }
      break;
    }
    case TK_VARIABLE: {
      notValidCheckConstraint(pParse, pNC, "parameters");
      notValidPartIdxWhere(pParse, pNC, "parameters");
      break;
    }
  }
  return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl 0x4(%rsi), %eax
pushq $0x1
popq %rbp
testb $0x4, %al
jne 0x48d2a
movq %rsi, %r14
movq %rdi, %r12
movq 0x20(%rdi), %r13
movq (%r13), %r15
movl %eax, %ecx
orl $0x4, %ecx
movl %ecx, 0x4(%rsi)
movzbl (%rsi), %ecx
cmpl $0x14, %ecx
je 0x4897a
cmpl $0x98, %ecx
je 0x48a18
cmpl $0x49, %ecx
je 0x4897a
cmpl $0x75, %ecx
je 0x4897a
cmpl $0x77, %ecx
je 0x48a08
cmpl $0x86, %ecx
je 0x489c2
cmpl $0x1b, %ecx
jne 0x489e5
movq 0x8(%r14), %rcx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x48a4c
btl $0xb, %eax
jae 0x489e5
movl 0x28(%r13), %ebx
movq %r13, %rbp
leaq 0x1c600(%rip), %r13     # 0x64f8e
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x49c41
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x49c2c
movq 0x20(%r14), %rsi
movq %r12, %rdi
callq 0x46e97
cmpl 0x28(%rbp), %ebx
je 0x489e5
orb $0x20, 0x4(%r14)
jmp 0x489e5
leaq 0x1c5d0(%rip), %r14     # 0x64f99
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x49c41
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x49c2c
cmpl $0x0, 0x50(%r15)
je 0x489f4
pushq $0x2
popq %rbp
jmp 0x48d2a
movq (%r15), %rax
xorl %ebp, %ebp
cmpb $0x0, 0x50(%rax)
setne %bpl
addl %ebp, %ebp
jmp 0x48d2a
movq 0x18(%r14), %rax
cmpb $0x1b, (%rax)
jne 0x48a2e
xorl %esi, %esi
movq %r14, %rdx
jmp 0x48a3d
movq 0x20(%r14), %rax
testq %rax, %rax
movq %rax, 0x28(%rsp)
je 0x48a65
movl (%rax), %eax
movl %eax, 0x14(%rsp)
jmp 0x48a6d
movq 0x10(%r14), %rcx
movq 0x8(%rcx), %rsi
movq %rax, %rdx
movq 0x18(%rax), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rdx), %rax
movq 0x8(%rax), %rdx
movq %r15, %rdi
movq %r13, %r8
movq %r14, %r9
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x49383
movl $0x0, 0x14(%rsp)
movq (%r15), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movb 0x71(%rax), %al
movb %al, 0x10(%rsp)
leaq 0x1c42c(%rip), %rdx     # 0x64eb2
movq %r15, %rdi
movq %r13, 0x18(%rsp)
movq %r13, %rsi
callq 0x49c2c
movq 0x8(%r14), %rbx
movq %rbx, %rdi
callq 0x90a2
movl %eax, %r13d
movq (%r15), %rdi
movzbl 0x10(%rsp), %r8d
movq %rbx, %rsi
movl %eax, %edx
movl 0x14(%rsp), %ecx
movl %r8d, 0x10(%rsp)
xorl %r9d, %r9d
callq 0x14804
testq %rax, %rax
movl %r13d, 0xc(%rsp)
movq %rax, 0x20(%rsp)
je 0x48b7b
cmpq $0x0, 0x18(%rax)
sete %cl
movl %ecx, 0x8(%rsp)
testb $0x4, 0x3(%rax)
je 0x48bce
orl $0x41000, 0x4(%r14)     # imm = 0x41000
cmpl $0x2, 0x14(%rsp)
jne 0x48bc6
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
movq %rcx, 0x40(%rsp)
cmpb $-0x7d, (%rax)
jne 0x48b56
movq 0x8(%rax), %r13
movq %r13, %rdi
callq 0x90a2
leaq 0x40(%rsp), %rsi
pushq $0x1
popq %rcx
movq %r13, %rdi
movq %rsi, %r13
movl %eax, %edx
callq 0x2230e
movsd (%r13), %xmm0
ucomisd 0x1a4c0(%rip), %xmm0    # 0x63010
jbe 0x48d3b
orl $-0x1, 0x2c(%r14)
leaq 0x1c35a(%rip), %rsi     # 0x64ebc
movq %r15, %rdi
xorl %eax, %eax
callq 0x10b53
movq 0x18(%rsp), %rax
incl 0x2c(%rax)
movq 0x20(%rsp), %r13
jmp 0x48bd1
movq (%r15), %rdi
pushq $-0x2
popq %rcx
movl $0x0, 0x8(%rsp)
movq %rbx, %rsi
movl %r13d, %edx
movl 0x10(%rsp), %r8d
xorl %r9d, %r9d
callq 0x14804
testq %rax, %rax
jne 0x48bce
movq (%r15), %rax
cmpb $0x0, 0x99(%rax)
movq 0x18(%rsp), %r13
jne 0x48d0e
leaq 0x1c38d(%rip), %rsi     # 0x64f4a
movl 0xc(%rsp), %edx
jmp 0x48c4b
movl $0x3e, 0x2c(%r14)
movq %rax, %r13
movq 0x30(%r13), %rcx
pushq $0x1f
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x4810e
testl %eax, %eax
je 0x48c14
cmpl $0x1, %eax
jne 0x48c0b
movq 0x30(%r13), %rdx
leaq 0x1c30a(%rip), %rsi     # 0x64f03
movq %r15, %rdi
xorl %eax, %eax
callq 0x10b53
movq 0x18(%rsp), %rax
incl 0x2c(%rax)
movb $0x63, (%r14)
jmp 0x48d2a
testb $0x8, 0x3(%r13)
jne 0x48c20
movq %rbx, %rcx
jmp 0x48c28
movq %rbx, %rcx
orb $0x8, 0x6(%r14)
cmpb $0x0, 0x8(%rsp)
movq 0x18(%rsp), %r13
movl 0xc(%rsp), %edx
je 0x48c61
movb $0x1, %bl
testb $0x1, 0x30(%r13)
jne 0x48c63
leaq 0x1c2de(%rip), %rsi     # 0x64f26
movq %rcx, %rbx
movq %r15, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10b53
incl 0x2c(%r13)
jmp 0x48d0e
xorl %ebx, %ebx
cmpq $0x0, 0x20(%rsp)
jne 0x48c80
leaq 0x1c2ef(%rip), %rsi     # 0x64f61
movq %r15, %rdi
xorl %eax, %eax
callq 0x10b53
incl 0x2c(%r13)
testb %bl, %bl
je 0x48d0e
andb $-0x2, 0x30(%r13)
movq %r12, %rdi
movq 0x28(%rsp), %rsi
callq 0x46fbb
movb $-0x66, (%r14)
movb $0x0, 0x36(%r14)
leaq 0x48(%rsp), %r12
movq %r13, %rbx
leaq 0x30(%rsp), %r13
leaq 0x40(%rsp), %r15
testq %rbx, %rbx
je 0x48d21
movq 0x8(%rbx), %rax
andq $0x0, 0x10(%r12)
xorpd %xmm0, %xmm0
movupd %xmm0, (%r12)
leaq 0x12ea(%rip), %rcx      # 0x49fbf
movq %rcx, 0x40(%rsp)
movq %r13, 0x60(%rsp)
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movq 0x20(%r14), %rsi
movq %r15, %rdi
callq 0x46fbb
cmpl $0x0, 0x38(%rsp)
jg 0x48d1d
cmpl $0x0, 0x3c(%rsp)
je 0x48d1d
incb 0x36(%r14)
movq 0x20(%rbx), %rbx
jmp 0x48cb5
movq %r12, %rdi
movq 0x28(%rsp), %rsi
callq 0x46fbb
jmp 0x48d2a
orb $0x2, 0x30(%rbx)
movq 0x18(%rsp), %rax
orb $0x1, 0x30(%rax)
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
mulsd 0x1a2d5(%rip), %xmm0    # 0x63018
cvttsd2si %xmm0, %eax
movl %eax, 0x2c(%r14)
testl %eax, %eax
jns 0x48b74
jmp 0x48b5b