// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: updateAccumulator
static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){
  Vdbe *v = pParse->pVdbe;
  int i;
  int regHit = 0;
  int addrHitTest = 0;
  struct AggInfo_func *pF;
  struct AggInfo_col *pC;

  pAggInfo->directMode = 1;
  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){
    int nArg;
    int addrNext = 0;
    int regAgg;
    ExprList *pList = pF->pFExpr->x.pList;
    assert( !ExprHasProperty(pF->pFExpr, EP_xIsSelect) );
    assert( !IsWindowFunc(pF->pFExpr) );
    if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){
      Expr *pFilter = pF->pFExpr->y.pWin->pFilter;
      if( pAggInfo->nAccumulator
       && (pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
       && regAcc
      ){
        /* If regAcc==0, there there exists some min() or max() function
        ** without a FILTER clause that will ensure the magnet registers
        ** are populated. */
        if( regHit==0 ) regHit = ++pParse->nMem;
        /* If this is the first row of the group (regAcc contains 0), clear the
        ** "magnet" register regHit so that the accumulator registers
        ** are populated if the FILTER clause jumps over the the
        ** invocation of min() or max() altogether. Or, if this is not
        ** the first row (regAcc contains 1), set the magnet register so that
        ** the accumulators are not populated unless the min()/max() is invoked
        ** and indicates that they should be.  */
        sqlite3VdbeAddOp2(v, OP_Copy, regAcc, regHit);
      }
      addrNext = sqlite3VdbeMakeLabel(pParse);
      sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL);
    }
    if( pList ){
      nArg = pList->nExpr;
      regAgg = sqlite3GetTempRange(pParse, nArg);
      sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);
    }else{
      nArg = 0;
      regAgg = 0;
    }
    if( pF->iDistinct>=0 ){
      if( addrNext==0 ){
        addrNext = sqlite3VdbeMakeLabel(pParse);
      }
      testcase( nArg==0 );  /* Error condition */
      testcase( nArg>1 );   /* Also an error */
      codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
    }
    if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
      CollSeq *pColl = 0;
      struct ExprList_item *pItem;
      int j;
      assert( pList!=0 );  /* pList!=0 if pF->pFunc has NEEDCOLL */
      for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){
        pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
      }
      if( !pColl ){
        pColl = pParse->db->pDfltColl;
      }
      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);
    }
    sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, pF->iMem);
    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
    sqlite3VdbeChangeP5(v, (u8)nArg);
    sqlite3ReleaseTempRange(pParse, regAgg, nArg);
    if( addrNext ){
      sqlite3VdbeResolveLabel(v, addrNext);
    }
  }
  if( regHit==0 && pAggInfo->nAccumulator ){
    regHit = regAcc;
  }
  if( regHit ){
    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);
  }
  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
    sqlite3ExprCode(pParse, pC->pCExpr, pC->iMem);
  }

  pAggInfo->directMode = 0;
  if( addrHitTest ){
    sqlite3VdbeJumpHereOrPopInst(v, addrHitTest);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movl %esi, 0x10(%rsp)
movq %rdi, %r15
movq 0x10(%rdi), %r13
movb $0x1, (%rdx)
cmpl $0x0, 0x38(%rdx)
jle 0x2d1e1a
movq 0x30(%r12), %rbp
leaq 0x2c(%r15), %rax
movq %rax, 0x28(%rsp)
leaq 0xd4(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
movq %r13, 0x30(%rsp)
movq %r12, 0x18(%rsp)
movq (%rbp), %rax
movq 0x20(%rax), %r14
testb $0x1, 0x7(%rax)
movl %ebx, 0x14(%rsp)
jne 0x2d1bc5
movl $0x0, 0x8(%rsp)
jmp 0x2d1c34
movq 0x40(%rax), %rax
movq 0x48(%rax), %rbx
cmpl $0x0, 0x2c(%r12)
je 0x2d1c12
cmpl $0x0, 0x10(%rsp)
je 0x2d1c12
movq 0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x20, %eax
je 0x2d1c12
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
jne 0x2d1bfa
movl 0x38(%r15), %ecx
incl %ecx
movl %ecx, 0x38(%r15)
movq %r13, %rdi
movl $0x4d, %esi
movl 0x10(%rsp), %edx
movl %ecx, 0x4(%rsp)
xorl %r8d, %r8d
callq 0x2a83e1
movl 0x44(%r15), %edx
decl %edx
movl %edx, 0x44(%r15)
movq %r15, %rdi
movq %rbx, %rsi
movl %edx, 0x8(%rsp)
movl $0x10, %ecx
callq 0x2bfceb
movl 0x14(%rsp), %ebx
testq %r14, %r14
je 0x2d1c62
movl (%r14), %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x2beb15
movq %r15, %rdi
movq %r14, %rsi
movl %eax, 0xc(%rsp)
movl %eax, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x2beb59
jmp 0x2d1c6d
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
movl 0x8(%rsp), %edx
movl 0x14(%rbp), %esi
testl %esi, %esi
js 0x2d1c9c
testl %edx, %edx
jne 0x2d1c86
movl 0x44(%r15), %edx
decl %edx
movl %edx, 0x44(%r15)
movq %r15, %rdi
movl %edx, 0x8(%rsp)
movl $0x1, %ecx
movl 0xc(%rsp), %r8d
callq 0x2dfd51
movq 0x8(%rbp), %rax
testb $0x20, 0x4(%rax)
jne 0x2d1cb0
movl 0xc(%rsp), %r14d
jmp 0x2d1d45
testl %r12d, %r12d
jle 0x2d1cec
addq $0x8, %r14
movl $0x1, %r13d
movq (%r14), %rsi
movq %r15, %rdi
callq 0x2a9678
movq %rax, %rbx
testq %rax, %rax
jne 0x2d1ce2
addq $0x18, %r14
leal 0x1(%r13), %eax
cmpl %r12d, %r13d
movl %eax, %r13d
jl 0x2d1cbf
testq %rbx, %rbx
movq 0x30(%rsp), %r13
jne 0x2d1cf3
movq (%r15), %rax
movq 0x10(%rax), %rbx
movl 0x4(%rsp), %edx
testl %edx, %edx
movl 0xc(%rsp), %r14d
jne 0x2d1d19
movq 0x18(%rsp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x2d1d17
movl 0x38(%r15), %edx
incl %edx
movl %edx, 0x38(%r15)
jmp 0x2d1d19
xorl %edx, %edx
movq %r13, %rdi
movl $0x51, %esi
movl %edx, 0x4(%rsp)
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
movq %r13, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x27b778
movl 0x14(%rsp), %ebx
movl 0x10(%rbp), %r8d
movq %r13, %rdi
movl $0x9a, %esi
xorl %edx, %edx
movl %r14d, %ecx
callq 0x2a83e1
movq 0x8(%rbp), %rsi
movq (%r13), %rdi
cmpb $0x0, 0x61(%rdi)
je 0x2d1d76
testb $0x10, 0x4(%rsi)
je 0x2d1d92
callq 0x282904
jmp 0x2d1d92
movq 0x88(%r13), %rax
movslq 0x90(%r13), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x8, -0x17(%rax,%rcx,8)
movq %rsi, -0x8(%rax,%rcx,8)
movslq 0x90(%r13), %rax
testq %rax, %rax
jle 0x2d1db2
movzbl %r12b, %ecx
movq 0x88(%r13), %rdx
leaq (%rax,%rax,2), %rax
movw %cx, -0x16(%rdx,%rax,8)
cmpl $0x1, %r12d
jne 0x2d1dda
testl %r14d, %r14d
je 0x2d1dec
movzbl 0x1f(%r15), %eax
cmpq $0x7, %rax
ja 0x2d1dec
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%r15)
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
jmp 0x2d1de9
cmpl %r12d, 0x28(%r15)
jge 0x2d1dec
movl %r12d, 0x28(%r15)
movq 0x28(%rsp), %rax
movl %r14d, (%rax)
movl 0x8(%rsp), %esi
testl %esi, %esi
je 0x2d1dfc
movq %r13, %rdi
callq 0x2bfa39
incl %ebx
addq $0x18, %rbp
movq 0x18(%rsp), %r12
cmpl 0x38(%r12), %ebx
jl 0x2d1ba9
movl 0x4(%rsp), %edx
testl %edx, %edx
jne 0x2d1e35
movl 0x2c(%r12), %eax
testl %eax, %eax
sete %cl
movl 0x10(%rsp), %esi
testl %esi, %esi
sete %dl
xorl %ebp, %ebp
orb %cl, %dl
movl %esi, %edx
jne 0x2d1e4e
movq %r13, %rdi
movl $0x12, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
movl %eax, %ebp
movl 0x2c(%r12), %eax
testl %eax, %eax
jle 0x2d1e7a
movq 0x20(%r12), %rbx
addq $0x14, %rbx
xorl %r14d, %r14d
movq -0xc(%rbx), %rsi
movl (%rbx), %edx
movq %r15, %rdi
callq 0x2bc7e9
incl %r14d
addq $0x20, %rbx
cmpl 0x2c(%r12), %r14d
jl 0x2d1e5e
movb $0x0, (%r12)
testl %ebp, %ebp
je 0x2d1ec7
movl 0x90(%r13), %eax
leal -0x1(%rax), %ecx
cmpl %ebp, %ecx
jne 0x2d1e9a
movl %ebp, 0x90(%r13)
jmp 0x2d1ec7
movq (%r13), %rdx
cmpb $0x0, 0x61(%rdx)
je 0x2d1ead
leaq 0x1ecfdd(%rip), %rcx    # 0x4bee88
jmp 0x2d1ec4
testl %ebp, %ebp
cmovnsl %ebp, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x88(%r13), %rcx
movl %eax, 0x8(%rcx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq