// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %ebp
testb $0x4, %al
jne 0x4db43
movq %rsi, %r14
movq %rdi, %r12
movq 0x20(%rdi), %r15
movq (%r15), %rbx
movl %eax, %ecx
orl $0x4, %ecx
movl %ecx, 0x4(%rsi)
movzbl (%rsi), %ecx
cmpl $0x74, %ecx
jle 0x4da49
cmpl $0x85, %ecx
jg 0x4dac5
cmpl $0x75, %ecx
je 0x4da60
cmpl $0x77, %ecx
jne 0x4db29
movq 0x18(%r14), %rax
cmpb $0x1b, (%rax)
jne 0x4db61
xorl %esi, %esi
movq %r14, %rdx
jmp 0x4db70
cmpl $0x14, %ecx
je 0x4da60
cmpl $0x1b, %ecx
je 0x4db54
cmpl $0x49, %ecx
jne 0x4db29
btl $0xb, %eax
jae 0x4db29
movl 0x28(%r15), %ebp
testb $0x4, 0x30(%r15)
je 0x4da8d
leaq 0x245df(%rip), %rsi     # 0x7205b
leaq 0x244eb(%rip), %rdx     # 0x71f6e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11c1f
testb $0x10, 0x30(%r15)
je 0x4daac
leaq 0x24593(%rip), %rsi     # 0x7202e
leaq 0x244cc(%rip), %rdx     # 0x71f6e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11c1f
movq 0x20(%r14), %rsi
movq %r12, %rdi
callq 0x4b6b0
cmpl 0x28(%r15), %ebp
je 0x4db29
orb $0x20, 0x4(%r14)
jmp 0x4db29
cmpl $0x86, %ecx
je 0x4daeb
cmpl $0x98, %ecx
jne 0x4db29
movq 0x20(%r14), %r13
testq %r13, %r13
je 0x4db98
movl (%r13), %ecx
jmp 0x4db9a
testb $0x4, 0x30(%r15)
je 0x4db0a
leaq 0x24562(%rip), %rsi     # 0x7205b
leaq 0x24479(%rip), %rdx     # 0x71f79
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11c1f
testb $0x10, 0x30(%r15)
je 0x4db29
leaq 0x24516(%rip), %rsi     # 0x7202e
leaq 0x2445a(%rip), %rdx     # 0x71f79
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11c1f
movl $0x2, %ebp
cmpl $0x0, 0x50(%rbx)
jne 0x4db43
movq (%rbx), %rax
xorl %ebp, %ebp
cmpb $0x0, 0x50(%rax)
setne %bpl
addl %ebp, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %rcx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x4db7f
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 %rbx, %rdi
movq %r15, %r8
movq %r14, %r9
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4e20e
xorl %ecx, %ecx
movq (%rbx), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movb 0x71(%rax), %dl
testb $0x10, 0x30(%r15)
movl %ecx, 0x8(%rsp)
je 0x4dbd7
leaq 0x24474(%rip), %rsi     # 0x7202e
movb %dl, 0x4(%rsp)
leaq 0x242cd(%rip), %rdx     # 0x71e92
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11c1f
movb 0x4(%rsp), %dl
movl 0x8(%rsp), %ecx
movq %rbx, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movq 0x8(%r14), %rbx
testq %rbx, %rbx
je 0x4dc08
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %rbx, %rax
incl %r13d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x4dbf3
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
jmp 0x4dc0b
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movzbl %dl, %r8d
movq %rbx, %rsi
movl %r13d, %edx
movl %r8d, 0x1c(%rsp)
xorl %r9d, %r9d
callq 0x162c0
testq %rax, %rax
movq %rbx, 0x28(%rsp)
je 0x4dc53
movq %rax, %rcx
cmpq $0x0, 0x18(%rax)
sete %al
movl %eax, 0x4(%rsp)
movb $0x1, %al
testb $0x4, 0x3(%rcx)
jne 0x4dce0
movb $0x1, %dl
jmp 0x4dc87
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl $0x0, 0x4(%rsp)
movq %rbx, %rsi
movl %r13d, %edx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
movl 0x1c(%rsp), %r8d
xorl %r9d, %r9d
callq 0x162c0
movq %rax, %rcx
testq %rax, %rax
sete %dl
setne %al
movq 0x10(%rsp), %rdi
testq %rcx, %rcx
je 0x4dd45
movb %dl, 0x1c(%rsp)
movb %al, 0x8(%rsp)
movq %rcx, %rbx
movq 0x30(%rcx), %rcx
movl $0x1f, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x4cb27
testl %eax, %eax
je 0x4dd2d
cmpl $0x1, %eax
jne 0x4dcd7
movq 0x30(%rbx), %rdx
leaq 0x2421c(%rip), %rsi     # 0x71ee3
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x11c1f
incl 0x2c(%r15)
movb $0x63, (%r14)
jmp 0x4db43
orl $0x41000, 0x4(%r14)     # imm = 0x41000
cmpl $0x2, 0x8(%rsp)
movq 0x10(%rsp), %rdi
jne 0x4de57
movq %rdi, %rbx
movq %rcx, 0x8(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rdi
callq 0x4ed14
movl %eax, 0x2c(%r14)
testl %eax, %eax
js 0x4de74
movb $0x1, %dl
movq 0x8(%rsp), %rcx
movq %rbx, %rdi
jmp 0x4de93
testb $0x8, 0x3(%rbx)
movq 0x10(%rsp), %rdi
movb 0x8(%rsp), %al
movb 0x1c(%rsp), %dl
je 0x4dd45
orb $0x8, 0x6(%r14)
cmpb $0x0, 0x4(%rsp)
je 0x4dd72
testb $0x1, 0x30(%r15)
jne 0x4dd72
leaq 0x241ac(%rip), %rsi     # 0x71f06
movl %r13d, %edx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
callq 0x11c1f
incl 0x2c(%r15)
jmp 0x4de45
testb %al, %al
je 0x4dd83
testb %dl, %dl
jne 0x4ddb9
leaq 0x241c0(%rip), %rsi     # 0x71f41
jmp 0x4dda6
movq (%rdi), %rax
cmpb $0x0, 0x99(%rax)
setne %al
leaq 0x241aa(%rip), %rcx     # 0x71f41
leaq 0x2418c(%rip), %rsi     # 0x71f2a
cmovneq %rcx, %rsi
testb %dl, %al
jne 0x4ddb9
movl %r13d, %edx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
callq 0x11c1f
incl 0x2c(%r15)
cmpb $0x0, 0x4(%rsp)
je 0x4de45
andb $-0x2, 0x30(%r15)
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0x4b7da
movb $-0x66, (%r14)
movb $0x0, 0x36(%r14)
leaq 0x30(%rsp), %r13
leaq 0x40(%rsp), %r12
movq %r15, %rbx
movq 0x8(%rbx), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x50(%rsp)
leaq 0x1425(%rip), %rcx      # 0x4f229
movq %rcx, 0x40(%rsp)
movq %r13, 0x60(%rsp)
movq %rax, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movq 0x20(%r14), %rsi
movq %r12, %rdi
callq 0x4b7da
cmpl $0x0, 0x38(%rsp)
jg 0x4de66
cmpl $0x0, 0x3c(%rsp)
je 0x4de66
incb 0x36(%r14)
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
jne 0x4ddec
jmp 0x4de6a
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0x4b7da
jmp 0x4db43
movl $0x3e, 0x2c(%r14)
movb $0x1, %dl
jmp 0x4dc8c
orb $0x2, 0x30(%rbx)
orb $0x1, 0x30(%r15)
jmp 0x4db43
leaq 0x24021(%rip), %rsi     # 0x71e9c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11c1f
movq %rbx, %rdi
incl 0x2c(%r15)
movb $0x1, %dl
movq 0x8(%rsp), %rcx
movb $0x1, %al
jmp 0x4dc8c