// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x445f66
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa4, %eax
je 0x445f00
movl $0x0, -0x4(%rbp)
jmp 0x44618a
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x445f4e
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq $0x8, %rcx
movslq -0x30(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x40(%rcx), %eax
jne 0x445f41
jmp 0x445f4e
jmp 0x445f43
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x445f14
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x445f62
movl $0x0, -0x4(%rbp)
jmp 0x44618a
jmp 0x445f64
jmp 0x445f66
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x50(%rbp)
addl $0xffffff5c, %eax       # imm = 0xFFFFFF5C
subl $0x2, %eax
jb 0x445fe2
jmp 0x445f7c
movl -0x50(%rbp), %eax
subl $0xa9, %eax
jne 0x446181
jmp 0x445f8c
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x0, %eax
jne 0x445fa2
jmp 0x446183
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x445fde
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
cmpq -0x38(%rbp), %rax
jne 0x445fce
movl $0x1, -0x4(%rbp)
jmp 0x44618a
jmp 0x445fd0
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x445fad
jmp 0x445fe0
jmp 0x445fe2
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x446055
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x446053
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x8, %rax
movslq -0x40(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl %eax, %edi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x42fc30
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x446046
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x446053
jmp 0x446048
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x445ffb
jmp 0x446055
cmpl $0x0, -0x3c(%rbp)
jge 0x4460ad
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x42dee0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x44608d
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa5, %eax
jne 0x44608d
movq -0x48(%rbp), %rax
movb $-0x57, (%rax)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x48(%rbp), %rdx
callq 0x41d3c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x446169
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x100, %eax            # imm = 0x100
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x8000000, %ecx        # imm = 0x8000000
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x40c670
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0xf7ffffff, %ecx       # imm = 0xF7FFFFFF
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x19360
movq -0x18(%rbp), %rax
movb $-0x5c, (%rax)
cmpl $0x0, -0x3c(%rbp)
jge 0x44612a
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x446130
movl -0x3c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x30(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl 0x58(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movl -0x4c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rax
cmpb $0x0, 0x61(%rax)
je 0x44617f
movl $0x2, -0x4(%rbp)
jmp 0x44618a
jmp 0x446183
jmp 0x446183
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)