// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4299d0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x457d59
movq -0x20(%rbp), %rax
cmpl $0x0, 0x84(%rax)
jne 0x457c88
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movl 0x4(%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x457c88
movq -0x30(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x5a, %eax
je 0x457c88
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x60(%rax), %ecx
movl $0x48, %esi
xorl %edx, %edx
callq 0x410100
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x64(%rax), %edx
movl $0x21, %esi
callq 0x42ba70
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x64(%rax), %edx
movq -0x30(%rbp), %rax
movl 0x60(%rax), %r8d
movl $0x59, %esi
xorl %ecx, %ecx
callq 0x410130
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x430ae0
movq -0x40(%rbp), %rdi
movl %eax, %esi
subl $0x2, %esi
callq 0x429a70
jmp 0x457d46
movq -0x30(%rbp), %rax
cmpl $0x0, 0x68(%rax)
je 0x457c97
jmp 0x457d44
movq -0x30(%rbp), %rdi
callq 0x458950
movl %eax, -0x34(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x457d0c
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x5c(%rax), %edx
movl -0x34(%rbp), %ecx
movl $0x9d, %esi
callq 0x410100
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
callq 0x42a320
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x5c(%rax), %edx
movq -0x30(%rbp), %rax
movl 0x60(%rax), %ecx
movl $0x4d, %esi
callq 0x410100
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x5c(%rax), %ecx
movl $0x48, %esi
xorl %edx, %edx
callq 0x410100
jmp 0x457d42
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x5c(%rax), %edx
movl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
movl 0x60(%rax), %r8d
movl $0x9c, %esi
callq 0x410130
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
callq 0x42a320
jmp 0x457d44
jmp 0x457d46
jmp 0x457d48
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x457bdb
addq $0x40, %rsp
popq %rbp
retq
nop