// File: /workspace/github_c_makefile_star2_O1/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)
je 0x2dc181
xorl %ebp, %ebp
cmpb $-0x5c, (%r14)
jne 0x2dc2b1
movq 0x8(%r15), %rcx
movl (%rcx), %eax
xorl %ebp, %ebp
movl $0x0, %edx
testl %eax, %eax
jle 0x2dc179
movl 0x2c(%r14), %esi
addq $0x48, %rcx
xorl %edx, %edx
cmpl (%rcx), %esi
je 0x2dc179
incq %rdx
addq $0x70, %rcx
cmpq %rdx, %rax
jne 0x2dc167
movl %eax, %edx
cmpl %eax, %edx
je 0x2dc2b1
movzbl (%r14), %eax
xorl %ebp, %ebp
leal -0xa4(%rax), %ecx
cmpl $0x2, %ecx
jae 0x2dc2a1
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpq $0x0, 0x10(%r15)
je 0x2dc1e5
movq 0x10(%r15), %rax
cmpl $0x0, (%rax)
jle 0x2dc1e5
movl $0x8, %r13d
xorl %r12d, %r12d
movq (%rax,%r13), %rsi
xorl %edi, %edi
movq %r14, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x2ca527
testl %eax, %eax
je 0x2dc1e5
incq %r12
movq 0x10(%r15), %rax
movslq (%rax), %rcx
addq $0x18, %r13
cmpq %rcx, %r12
jl 0x2dc1b5
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %r12d, %r12d
jns 0x2dc219
movq (%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2cbf97
testq %rax, %rax
je 0x2dc206
cmpb $-0x5b, (%rax)
jne 0x2dc206
movb $-0x57, (%rax)
movq 0x10(%r15), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x2bb1a3
movq %rax, 0x10(%r15)
cmpq $0x0, 0x10(%r15)
je 0x2dc28e
movl 0x4(%r14), %eax
movl %eax, %r13d
andl $0x100, %r13d           # imm = 0x100
orl $0x8000000, %eax        # imm = 0x8000000
movl %eax, 0x4(%r14)
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2afd54
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movq $0x0, 0x40(%r14)
movb $-0x5c, (%r14)
testl %r12d, %r12d
jns 0x2dc273
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 %r13d, 0x4(%r14)
movq (%rbx), %rax
cmpb $0x0, 0x61(%rax)
movl $0x2, %eax
cmovnel %eax, %ebp
jne 0x2dc2b1
jmp 0x2dc2af
cmpl $0xa9, %eax
jne 0x2dc2af
testb $0x1, 0x7(%r14)
jne 0x2dc2c2
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rcx
xorl %ebp, %ebp
testq %rcx, %rcx
sete %al
je 0x2dc2eb
movq 0x40(%r14), %rdx
cmpq %rcx, %rdx
je 0x2dc2e6
movq 0x40(%rcx), %rcx
testq %rcx, %rcx
sete %al
jne 0x2dc2d3
jmp 0x2dc2eb
movl $0x1, %ebp
testb %al, %al
jne 0x2dc196
jmp 0x2dc2b1