// File: /workspace/github_c_makefile_star2_O2/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, %r13
movl %esi, 0x20(%rsp)
movq %rdi, %r15
movq 0x10(%rdi), %rbx
movb $0x1, (%rdx)
movq 0x30(%rdx), %rax
movq %rax, 0x18(%rsp)
xorl %edx, %edx
xorl %eax, %eax
movq %rbx, 0x28(%rsp)
movq %r13, 0x30(%rsp)
cmpl 0x38(%r13), %eax
jge 0x275498
movl %eax, 0x24(%rsp)
movl %edx, 0x14(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rax), %r12
xorl %ebp, %ebp
testb $0x1, 0x7(%rax)
jne 0x2752ca
xorl %r13d, %r13d
jmp 0x27532f
movq 0x40(%rax), %rax
movq 0x48(%rax), %r14
cmpl $0x0, 0x2c(%r13)
je 0x275313
movl 0x20(%rsp), %edx
testl %edx, %edx
je 0x275313
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
andl $0x20, %eax
je 0x275313
movl 0x14(%rsp), %ecx
testl %ecx, %ecx
jne 0x275304
movl 0x38(%r15), %ecx
incl %ecx
movl %ecx, 0x38(%r15)
movq %rbx, %rdi
pushq $0x4d
popq %rsi
movl %ecx, 0x14(%rsp)
callq 0x24d51a
movl 0x44(%r15), %r13d
decl %r13d
movl %r13d, 0x44(%r15)
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
pushq $0x10
popq %rcx
callq 0x26726e
movl $0x0, %r14d
testq %r12, %r12
je 0x27535e
movl (%r12), %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x266492
movl %eax, %r14d
movq %r15, %rdi
movq %r12, %rsi
movl %eax, %edx
xorl %ecx, %ecx
pushq $0x1
popq %r8
callq 0x2664ba
movq 0x18(%rsp), %rax
movl 0x14(%rax), %esi
testl %esi, %esi
js 0x27538b
testl %r13d, %r13d
jne 0x27537a
movl 0x44(%r15), %r13d
decl %r13d
movl %r13d, 0x44(%r15)
movq %r15, %rdi
movl %r13d, %edx
pushq $0x1
popq %rcx
movl %r14d, %r8d
callq 0x27e010
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
testb $0x20, 0x4(%rax)
jne 0x27539f
movl %r14d, %r12d
jmp 0x275417
addq $0x8, %r12
xorl %eax, %eax
xorl %ebx, %ebx
testq %rax, %rax
jne 0x2753c4
cmpl %ebp, %ebx
jge 0x2753c4
movq (%r12), %rsi
movq %r15, %rdi
callq 0x24e541
incl %ebx
addq $0x18, %r12
jmp 0x2753a7
testq %rax, %rax
jne 0x2753d0
movq (%r15), %rax
movq 0x10(%rax), %rax
movl 0x14(%rsp), %edx
testl %edx, %edx
movq 0x28(%rsp), %rbx
jne 0x2753f6
movq 0x30(%rsp), %rcx
cmpl $0x0, 0x2c(%rcx)
je 0x2753f4
movl 0x38(%r15), %edx
incl %edx
movl %edx, 0x38(%r15)
jmp 0x2753f6
xorl %edx, %edx
movl %r14d, %r12d
movl $0xfffffffe, (%rsp)     # imm = 0xFFFFFFFE
movq %rbx, %rdi
pushq $0x51
popq %rsi
movl %edx, 0x14(%rsp)
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x264609
movq 0x18(%rsp), %r14
movl 0x10(%r14), %r8d
movq %rbx, %rdi
movl $0x9a, %esi
xorl %edx, %edx
movl %r12d, %ecx
callq 0x24d51f
movq 0x8(%r14), %rsi
movq %rbx, %rdi
pushq $-0x8
popq %rdx
callq 0x26495f
movslq 0x90(%rbx), %rax
testq %rax, %rax
jle 0x275461
movzbl %bpl, %ecx
movq 0x88(%rbx), %rdx
imulq $0x18, %rax, %rax
movw %cx, -0x16(%rdx,%rax)
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x2666df
testl %r13d, %r13d
je 0x27547e
movq %rbx, %rdi
movl %r13d, %esi
callq 0x266fe1
movl 0x24(%rsp), %eax
incl %eax
addq $0x18, 0x18(%rsp)
movq 0x30(%rsp), %r13
movl 0x14(%rsp), %edx
jmp 0x27529f
testl %edx, %edx
jne 0x2754af
xorl %ebp, %ebp
movl 0x20(%rsp), %eax
testl %eax, %eax
je 0x2754bc
cmpl $0x0, 0x2c(%r13)
movl %eax, %edx
je 0x2754bc
pushq $0x12
popq %rsi
movq %rbx, %rdi
callq 0x265d5c
movl %eax, %ebp
movq 0x20(%r13), %rbx
addq $0x14, %rbx
xorl %r14d, %r14d
cmpl 0x2c(%r13), %r14d
jge 0x2754e4
movq -0xc(%rbx), %rsi
movl (%rbx), %edx
movq %r15, %rdi
callq 0x26463f
incl %r14d
addq $0x20, %rbx
jmp 0x2754c7
movb $0x0, (%r13)
testl %ebp, %ebp
je 0x275507
movq 0x28(%rsp), %rdi
movl %ebp, %esi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x27e90d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq