// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3WindowUpdate
SQLITE_PRIVATE void sqlite3WindowUpdate(
  Parse *pParse,
  Window *pList,                  /* List of named windows for this SELECT */
  Window *pWin,                   /* Window frame to update */
  FuncDef *pFunc                  /* Window function definition */
){
  if( pWin->zName && pWin->eFrmType==0 ){
    Window *p = windowFind(pParse, pList, pWin->zName);
    if( p==0 ) return;
    pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
    pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
    pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
    pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
    pWin->eStart = p->eStart;
    pWin->eEnd = p->eEnd;
    pWin->eFrmType = p->eFrmType;
    pWin->eExclude = p->eExclude;
  }else{
    sqlite3WindowChain(pParse, pWin, pList);
  }
  if( (pWin->eFrmType==TK_RANGE)
   && (pWin->pStart || pWin->pEnd)
   && (pWin->pOrderBy==0 || pWin->pOrderBy->nExpr!=1)
  ){
    sqlite3ErrorMsg(pParse,
      "RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression"
    );
  }else
  if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
    sqlite3 *db = pParse->db;
    if( pWin->pFilter ){
      sqlite3ErrorMsg(pParse,
          "FILTER clause may only be used with aggregate window functions"
      );
    }else{
      struct WindowUpdate {
        const char *zFunc;
        int eFrmType;
        int eStart;
        int eEnd;
      } aUp[] = {
        { row_numberName,   TK_ROWS,   TK_UNBOUNDED, TK_CURRENT },
        { dense_rankName,   TK_RANGE,  TK_UNBOUNDED, TK_CURRENT },
        { rankName,         TK_RANGE,  TK_UNBOUNDED, TK_CURRENT },
        { percent_rankName, TK_GROUPS, TK_CURRENT,   TK_UNBOUNDED },
        { cume_distName,    TK_GROUPS, TK_FOLLOWING, TK_UNBOUNDED },
        { ntileName,        TK_ROWS,   TK_CURRENT,   TK_UNBOUNDED },
        { leadName,         TK_ROWS,   TK_UNBOUNDED, TK_UNBOUNDED },
        { lagName,          TK_ROWS,   TK_UNBOUNDED, TK_CURRENT },
      };
      int i;
      for(i=0; i<ArraySize(aUp); i++){
        if( pFunc->zName==aUp[i].zFunc ){
          sqlite3ExprDelete(db, pWin->pStart);
          sqlite3ExprDelete(db, pWin->pEnd);
          pWin->pEnd = pWin->pStart = 0;
          pWin->eFrmType = aUp[i].eFrmType;
          pWin->eStart = aUp[i].eStart;
          pWin->eEnd = aUp[i].eEnd;
          pWin->eExclude = 0;
          if( pWin->eStart==TK_FOLLOWING ){
            pWin->pStart = sqlite3Expr(db, TK_INTEGER, "1");
          }
          break;
        }
      }
    }
  }
  pWin->pFunc = pFunc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x43799c
movq -0x18(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x0, %eax
jne 0x43799c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
callq 0x438550
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4378de
jmp 0x437b92
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %edx, %edx
callq 0x432810
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rsi
xorl %edx, %edx
callq 0x432810
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rsi
xorl %edx, %edx
callq 0x42dee0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rsi
xorl %edx, %edx
callq 0x42dee0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
movb 0x21(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x21(%rax)
movq -0x28(%rbp), %rax
movb 0x22(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x22(%rax)
movq -0x28(%rbp), %rax
movb 0x20(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x20(%rax)
movq -0x28(%rbp), %rax
movb 0x24(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x24(%rax)
jmp 0x4379ad
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x4295e0
movq -0x18(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x59, %eax
jne 0x4379ff
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x4379d0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x4379ff
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x4379e8
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x1, (%rax)
je 0x4379ff
movq -0x8(%rbp), %rdi
leaq 0x175685(%rip), %rsi    # 0x5ad078
movb $0x0, %al
callq 0x3cb660
jmp 0x437b86
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x437b84
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x437a41
movq -0x8(%rbp), %rdi
leaq 0x17568a(%rip), %rsi    # 0x5ad0bf
movb $0x0, %al
callq 0x3cb660
jmp 0x437b82
leaq -0xf0(%rbp), %rdi
leaq 0x203311(%rip), %rsi    # 0x63ad60
movl $0xc0, %edx
callq 0x19610
movl $0x0, -0xf4(%rbp)
cmpl $0x8, -0xf4(%rbp)
jge 0x437b80
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0xf4(%rbp), %rdx
leaq -0xf0(%rbp), %rcx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jne 0x437b6a
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x40c670
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x40c670
movq -0x18(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movslq -0xf4(%rbp), %rcx
leaq -0xf0(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x20(%rax)
movslq -0xf4(%rbp), %rcx
leaq -0xf0(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x21(%rax)
movslq -0xf4(%rbp), %rcx
leaq -0xf0(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x22(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x24(%rax)
movq -0x18(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x56, %eax
jne 0x437b68
movq -0x30(%rbp), %rdi
movl $0x98, %esi
leaq 0x108bb2(%rip), %rdx    # 0x54070a
callq 0x41d620
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x437b80
jmp 0x437b6c
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x437a63
jmp 0x437b82
jmp 0x437b84
jmp 0x437b86
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax,%rax)