// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq (%rdi), %r14
movq 0x28(%rdi), %r15
cmpq $0x0, 0x20(%r15)
movzbl (%rsi), %ecx
je 0x2d2998
cmpl $0xa4, %ecx
jne 0x2d2aac
movq 0x8(%r15), %rsi
movslq (%rsi), %rdx
xorl %eax, %eax
movl $0x0, %edi
testq %rdx, %rdx
jle 0x2d2990
movl 0x2c(%rbx), %r8d
addq $0x48, %rsi
xorl %edi, %edi
cmpl (%rsi), %r8d
je 0x2d2990
incq %rdi
addq $0x70, %rsi
cmpq %rdi, %rdx
jne 0x2d297a
jmp 0x2d2aac
cmpl %edx, %edi
je 0x2d2aae
leal -0xa4(%rcx), %eax
cmpl $0x2, %eax
jae 0x2d2a9e
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x2d29ee
cmpl $0x0, (%rax)
jle 0x2d29ee
movl $0x8, %r13d
xorl %r12d, %r12d
movq (%rax,%r13), %rsi
xorl %edi, %edi
movq %rbx, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x2c0d98
movl %eax, %ecx
movq 0x10(%r15), %rax
testl %ecx, %ecx
je 0x2d2ae0
incq %r12
movslq (%rax), %rcx
addq $0x18, %r13
cmpq %rcx, %r12
jl 0x2d29be
movq (%r14), %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2c2864
testq %rax, %rax
je 0x2d2a0a
cmpb $-0x5b, (%rax)
jne 0x2d2a0a
movb $-0x57, (%rax)
movq 0x10(%r15), %rsi
movq (%r14), %rdi
movq %rax, %rdx
callq 0x2b1a3f
movq %rax, 0x10(%r15)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movb $0x1, %r13b
testq %rax, %rax
je 0x2d2a8e
movl 0x4(%rbx), %eax
movl %eax, %ebp
andl $0x100, %ebp            # imm = 0x100
orl $0x8000000, %eax        # imm = 0x8000000
movl %eax, 0x4(%rbx)
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x2a6164
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movq $0x0, 0x40(%rbx)
movb $-0x5c, (%rbx)
testb %r13b, %r13b
je 0x2d2a75
movq 0x10(%r15), %rax
movl (%rax), %r12d
decl %r12d
movw %r12w, 0x30(%rbx)
movq (%r15), %rax
movl 0x58(%rax), %eax
movl %eax, 0x2c(%rbx)
movq 0x18(%r15), %rax
movq %rax, 0x40(%rbx)
movl %ebp, 0x4(%rbx)
movq (%r14), %rcx
movl $0x2, %eax
cmpb $0x0, 0x61(%rcx)
jne 0x2d2aae
jmp 0x2d2aac
cmpl $0xa9, %ecx
jne 0x2d2aac
testb $0x1, 0x7(%rbx)
jne 0x2d2abd
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rax
testq %rax, %rax
je 0x2d29a7
movq 0x40(%rbx), %rcx
cmpq %rax, %rcx
je 0x2d2ae8
movq 0x40(%rax), %rax
testq %rax, %rax
jne 0x2d2acd
jmp 0x2d29a7
xorl %r13d, %r13d
jmp 0x2d2a26
movl $0x1, %eax
jmp 0x2d2aae