// File: /workspace/github_c_makefile_star2_O1/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 %esi, %ebx
movq (%rdi), %rax
movq 0x8(%rdi), %r15
movq %rax, %rdi
callq 0x2c5ddf
testq %r15, %r15
je 0x2e79df
movq %rax, %r14
leaq 0x1e264d(%rip), %r12    # 0x4c9e88
movq %r15, %r13
cmpl $0x0, 0x84(%r15)
jne 0x2e785d
movq 0x50(%r13), %rax
testb $0x10, 0x5(%rax)
je 0x2e785d
cmpb $0x5a, 0x21(%r13)
jne 0x2e78ee
cmpl $0x0, 0x68(%r13)
jne 0x2e79b2
movq 0x70(%r13), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x2e7879
movl (%rax), %ecx
jmp 0x2e787b
xorl %ecx, %ecx
movl 0x5c(%r13), %edx
testl %ebx, %ebx
je 0x2e78b8
movq %r14, %rdi
movl $0x9d, %esi
xorl %r8d, %r8d
callq 0x2b200c
movq 0x50(%r13), %rsi
movq (%r14), %rdi
cmpb $0x0, 0x61(%rdi)
je 0x2e7968
testb $0x10, 0x4(%rsi)
je 0x2e7984
callq 0x28c3e7
jmp 0x2e7984
movl 0x60(%r13), %r8d
movq %r14, %rdi
movl $0x9c, %esi
callq 0x2b200c
movq 0x50(%r13), %rsi
movq (%r14), %rdi
cmpb $0x0, 0x61(%rdi)
je 0x2e79c1
testb $0x10, 0x4(%rsi)
je 0x2e79b2
callq 0x28c3e7
jmp 0x2e79b2
movl 0x60(%r13), %ecx
movq %r14, %rdi
movl $0x48, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x2b200c
movl 0x64(%r13), %edx
movq %r14, %rdi
movl $0x21, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b200c
movl 0x60(%r13), %r8d
movl 0x64(%r13), %edx
movq %r14, %rdi
movl $0x59, %esi
xorl %ecx, %ecx
callq 0x2b200c
movl 0x90(%r14), %eax
movq (%r14), %rcx
cmpb $0x0, 0x61(%rcx)
movq %r12, %rcx
jne 0x2e7963
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(%r14), %rcx
movl %eax, 0x8(%rcx)
jmp 0x2e79b2
movq 0x88(%r14), %rax
movslq 0x90(%r14), %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 %r14, %rdi
movl $0x4d, %esi
xorl %r8d, %r8d
callq 0x2b200c
movl 0x5c(%r13), %ecx
movq %r14, %rdi
movl $0x48, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x2b200c
movq 0x40(%r13), %r13
testq %r13, %r13
jne 0x2e783e
jmp 0x2e79df
movq 0x88(%r14), %rax
movslq 0x90(%r14), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x8, -0x17(%rax,%rcx,8)
movq %rsi, -0x8(%rax,%rcx,8)
jmp 0x2e79b2
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq