// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: windowAggFinal
static void windowAggFinal(WindowCodeArg *p, int bFin){
  Parse *pParse = p->pParse;
  Window *pMWin = p->pMWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;

  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    if( pMWin->regStartRowid==0
     && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
     && (pWin->eStart!=TK_UNBOUNDED)
    ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
      sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
      VdbeCoverage(v);
      sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);
      sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
    }else if( pWin->regApp ){
      assert( pMWin->regStartRowid==0 );
    }else{
      int nArg = windowArgCount(pWin);
      if( bFin ){
        sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg);
        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
        sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
        sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
      }else{
        sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
      }
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
callq 0x2bc630
testq %r14, %r14
je 0x2de726
movq %rax, %r15
leaq 0x1e0906(%rip), %r12    # 0x4bee88
movq %r14, %r13
cmpl $0x0, 0x84(%r14)
jne 0x2de5a4
movq 0x50(%r13), %rax
testb $0x10, 0x5(%rax)
je 0x2de5a4
cmpb $0x5a, 0x21(%r13)
jne 0x2de635
cmpl $0x0, 0x68(%r13)
jne 0x2de6f9
movq 0x70(%r13), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x2de5c0
movl (%rax), %ecx
jmp 0x2de5c2
xorl %ecx, %ecx
movl 0x5c(%r13), %edx
testl %ebx, %ebx
je 0x2de5ff
movq %r15, %rdi
movl $0x9d, %esi
xorl %r8d, %r8d
callq 0x2a83e1
movq 0x50(%r13), %rsi
movq (%r15), %rdi
cmpb $0x0, 0x61(%rdi)
je 0x2de6af
testb $0x10, 0x4(%rsi)
je 0x2de6cb
callq 0x282904
jmp 0x2de6cb
movl 0x60(%r13), %r8d
movq %r15, %rdi
movl $0x9c, %esi
callq 0x2a83e1
movq 0x50(%r13), %rsi
movq (%r15), %rdi
cmpb $0x0, 0x61(%rdi)
je 0x2de708
testb $0x10, 0x4(%rsi)
je 0x2de6f9
callq 0x282904
jmp 0x2de6f9
movl 0x60(%r13), %ecx
movq %r15, %rdi
movl $0x48, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x2a83e1
movl 0x64(%r13), %edx
movq %r15, %rdi
movl $0x21, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
movl 0x60(%r13), %r8d
movl 0x64(%r13), %edx
movq %r15, %rdi
movl $0x59, %esi
xorl %ecx, %ecx
callq 0x2a83e1
movl 0x90(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
movq %r12, %rcx
jne 0x2de6aa
xorl %ecx, %ecx
cmpl $0x2, %eax
setl %cl
orl $-0x2, %ecx
addl %eax, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x88(%r15), %rcx
movl %eax, 0x8(%rcx)
jmp 0x2de6f9
movq 0x88(%r15), %rax
movslq 0x90(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x8, -0x17(%rax,%rcx,8)
movq %rsi, -0x8(%rax,%rcx,8)
movl 0x5c(%r13), %edx
movl 0x60(%r13), %ecx
movq %r15, %rdi
movl $0x4d, %esi
xorl %r8d, %r8d
callq 0x2a83e1
movl 0x5c(%r13), %ecx
movq %r15, %rdi
movl $0x48, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x2a83e1
movq 0x40(%r13), %r13
testq %r13, %r13
jne 0x2de585
jmp 0x2de726
movq 0x88(%r15), %rax
movslq 0x90(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x8, -0x17(%rax,%rcx,8)
movq %rsi, -0x8(%rax,%rcx,8)
jmp 0x2de6f9
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq