// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: selectWindowRewriteExprCb
static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
  struct WindowRewrite *p = pWalker->u.pRewrite;
  Parse *pParse = pWalker->pParse;
  assert( p!=0 );
  assert( p->pWin!=0 );

  /* If this function is being called from within a scalar sub-select
  ** that used by the SELECT statement being processed, only process
  ** TK_COLUMN expressions that refer to it (the outer SELECT). Do
  ** not process aggregates or window functions at all, as they belong
  ** to the scalar sub-select.  */
  if( p->pSubSelect ){
    if( pExpr->op!=TK_COLUMN ){
      return WRC_Continue;
    }else{
      int nSrc = p->pSrc->nSrc;
      int i;
      for(i=0; i<nSrc; i++){
        if( pExpr->iTable==p->pSrc->a[i].iCursor ) break;
      }
      if( i==nSrc ) return WRC_Continue;
    }
  }

  switch( pExpr->op ){

    case TK_FUNCTION:
      if( !ExprHasProperty(pExpr, EP_WinFunc) ){
        break;
      }else{
        Window *pWin;
        for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
          if( pExpr->y.pWin==pWin ){
            assert( pWin->pOwner==pExpr );
            return WRC_Prune;
          }
        }
      }
      /* no break */ deliberate_fall_through

    case TK_AGG_FUNCTION:
    case TK_COLUMN: {
      int iCol = -1;
      if( p->pSub ){
        int i;
        for(i=0; i<p->pSub->nExpr; i++){
          if( 0==sqlite3ExprCompare(0, p->pSub->a[i].pExpr, pExpr, -1) ){
            iCol = i;
            break;
          }
        }
      }
      if( iCol<0 ){
        Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
        if( pDup && pDup->op==TK_AGG_FUNCTION ) pDup->op = TK_FUNCTION;
        p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
      }
      if( p->pSub ){
        int f = pExpr->flags & EP_Collate;
        assert( ExprHasProperty(pExpr, EP_Static)==0 );
        ExprSetProperty(pExpr, EP_Static);
        sqlite3ExprDelete(pParse->db, pExpr);
        ExprClearProperty(pExpr, EP_Static);
        memset(pExpr, 0, sizeof(Expr));

        pExpr->op = TK_COLUMN;
        pExpr->iColumn = (iCol<0 ? p->pSub->nExpr-1: iCol);
        pExpr->iTable = p->pWin->iEphCsr;
        pExpr->y.pTab = p->pTab;
        pExpr->flags = f;
      }
      if( pParse->db->mallocFailed ) return WRC_Abort;
      break;
    }

    default: /* no-op */
      break;
  }

  return WRC_Continue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq (%rdi), %rbx
movq 0x28(%rdi), %r15
cmpq $0x0, 0x20(%r15)
movzbl (%rsi), %eax
je 0x2758b3
cmpl $0xa4, %eax
jne 0x2759e4
movq 0x8(%r15), %rdi
movl (%rdi), %ecx
xorl %esi, %esi
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
addq $0x48, %rdi
cmpq %rsi, %rdx
je 0x2758ab
movl 0x2c(%r14), %r8d
cmpl (%rdi), %r8d
je 0x2758a9
incq %rsi
addq $0x70, %rdi
jmp 0x275892
movl %esi, %edx
cmpl %ecx, %edx
je 0x2759e4
leal -0xa4(%rax), %ecx
cmpl $0x2, %ecx
jae 0x2758fc
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x27592f
pushq $0x8
popq %r13
xorl %r12d, %r12d
pushq $-0x1
popq %rbp
movslq (%rax), %rcx
cmpq %rcx, %r12
jge 0x27592f
movq (%rax,%r13), %rsi
xorl %edi, %edi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x26823c
movl %eax, %ecx
movq 0x10(%r15), %rax
testl %ecx, %ecx
je 0x275965
incq %r12
addq $0x18, %r13
jmp 0x2758d1
cmpl $0xa9, %eax
jne 0x2759e4
testb $0x1, 0x7(%r14)
je 0x2759e4
pushq $0x1
popq %rax
movq %r15, %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
je 0x2758be
leaq 0x40(%rdx), %rcx
cmpq %rdx, 0x40(%r14)
jne 0x275918
jmp 0x2759e6
movq (%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x267197
testq %rax, %rax
je 0x275949
cmpb $-0x5b, (%rax)
jne 0x275949
movb $-0x57, (%rax)
pushq $-0x1
popq %r12
movq 0x10(%r15), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x25bc95
movq %rax, 0x10(%r15)
movb $0x1, %r13b
jmp 0x275968
xorl %r13d, %r13d
testq %rax, %rax
je 0x2759d6
movl 0x4(%r14), %eax
movl %eax, %ebp
andl $0x100, %ebp            # imm = 0x100
orl $0x8000000, %eax        # imm = 0x8000000
movl %eax, 0x4(%r14)
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x24b649
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x30(%r14)
andq $0x0, 0x40(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movb $-0x5c, (%r14)
testb %r13b, %r13b
je 0x2759bb
movq 0x10(%r15), %rax
movl (%rax), %r12d
decl %r12d
movw %r12w, 0x30(%r14)
movq (%r15), %rax
movl 0x58(%rax), %eax
movl %eax, 0x2c(%r14)
movq 0x18(%r15), %rax
movq %rax, 0x40(%r14)
movl %ebp, 0x4(%r14)
movq (%rbx), %rax
cmpb $0x0, 0x61(%rax)
je 0x2759e4
pushq $0x2
popq %rax
jmp 0x2759e6
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq