// File: /workspace/github_c_makefile_star2_O2/jkbenaim[P]psfrag/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->pExpr->x.pList;
    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );
    assert( !IsWindowFunc(pF->pExpr) );
    if( ExprHasProperty(pF->pExpr, EP_WinFunc) ){
      Expr *pFilter = pF->pExpr->y.pWin->pFilter;
      if( pAggInfo->nAccumulator 
       && (pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) 
      ){
        if( regHit==0 ) regHit = ++pParse->nMem;
        /* If this is the first row of the group (regAcc==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==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->pExpr, pC->iMem);
  }

  pAggInfo->directMode = 0;
  if( addrHitTest ){
    sqlite3VdbeJumpHere(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)
movl $0x0, 0x14(%rsp)
xorl %eax, %eax
movq %rbx, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
cmpl 0x38(%r13), %eax
jge 0x5f1dc
movl %eax, 0x24(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rax), %r14
xorl %ebp, %ebp
testb $0x1, 0x7(%rax)
jne 0x5f022
xorl %r13d, %r13d
jmp 0x5f081
movq 0x40(%rax), %rax
movq 0x48(%rax), %r12
cmpl $0x0, 0x2c(%r13)
je 0x5f065
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
testb $0x20, 0x4(%rax)
je 0x5f065
movl 0x14(%rsp), %ecx
testl %ecx, %ecx
jne 0x5f052
movl 0x38(%r15), %ecx
incl %ecx
movl %ecx, 0x38(%r15)
movq %rbx, %rdi
pushq $0x4e
popq %rsi
movl 0x20(%rsp), %edx
movl %ecx, 0x14(%rsp)
callq 0x393ea
movl 0x44(%r15), %r13d
decl %r13d
movl %r13d, 0x44(%r15)
movq %r15, %rdi
movq %r12, %rsi
movl %r13d, %edx
pushq $0x10
popq %rcx
callq 0x51efb
movl $0x0, %r12d
testq %r14, %r14
je 0x5f0af
movl (%r14), %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x51206
movl %eax, %r12d
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
xorl %ecx, %ecx
pushq $0x1
popq %r8
callq 0x5122e
movq 0x18(%rsp), %rax
movl 0x14(%rax), %esi
testl %esi, %esi
js 0x5f0dc
testl %r13d, %r13d
jne 0x5f0cb
movl 0x44(%r15), %r13d
decl %r13d
movl %r13d, 0x44(%r15)
movq %r15, %rdi
movl %r13d, %edx
pushq $0x1
popq %rcx
movl %r12d, %r8d
callq 0x67c05
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
testb $0x20, 0x4(%rax)
je 0x5f15f
addq $0x8, %r14
xorl %eax, %eax
xorl %ebx, %ebx
testq %rax, %rax
jne 0x5f10f
cmpl %ebp, %ebx
jge 0x5f10f
movq (%r14), %rsi
movq %r15, %rdi
callq 0x3a441
incl %ebx
addq $0x20, %r14
jmp 0x5f0f3
testq %rax, %rax
jne 0x5f11b
movq (%r15), %rax
movq 0x10(%rax), %rax
movl 0x14(%rsp), %edx
testl %edx, %edx
movq 0x28(%rsp), %rbx
jne 0x5f141
movq 0x30(%rsp), %rcx
cmpl $0x0, 0x2c(%rcx)
je 0x5f13f
movl 0x38(%r15), %edx
incl %edx
movl %edx, 0x38(%r15)
jmp 0x5f141
xorl %edx, %edx
movl $0xfffffffe, (%rsp)     # imm = 0xFFFFFFFE
movq %rbx, %rdi
pushq $0x52
popq %rsi
movl %edx, 0x14(%rsp)
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x4f693
movq 0x18(%rsp), %r14
movl 0x10(%r14), %r8d
movq %rbx, %rdi
movl $0x9a, %esi
xorl %edx, %edx
movl %r12d, %ecx
callq 0x393ef
movq 0x8(%r14), %rsi
movq %rbx, %rdi
pushq $-0x8
popq %rdx
callq 0x4f9f9
movslq 0x90(%rbx), %rax
testq %rax, %rax
jle 0x5f1a9
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 0x51378
testl %r13d, %r13d
je 0x5f1c6
movq %rbx, %rdi
movl %r13d, %esi
callq 0x511d4
movl 0x24(%rsp), %eax
incl %eax
addq $0x18, 0x18(%rsp)
movq 0x30(%rsp), %r13
jmp 0x5effb
movl 0x14(%rsp), %edx
testl %edx, %edx
movl 0x20(%rsp), %eax
jne 0x5f1f7
xorl %ebp, %ebp
testl %eax, %eax
je 0x5f204
cmpl $0x0, 0x2c(%r13)
movl %eax, %edx
je 0x5f204
pushq $0x12
popq %rsi
movq %rbx, %rdi
callq 0x50c39
movl %eax, %ebp
movq 0x20(%r13), %rbx
addq $0x18, %rbx
xorl %r14d, %r14d
cmpl 0x2c(%r13), %r14d
jge 0x5f22c
movq (%rbx), %rsi
movl -0x4(%rbx), %edx
movq %r15, %rdi
callq 0x4f6c9
incl %r14d
addq $0x20, %rbx
jmp 0x5f20f
movb $0x0, (%r13)
testl %ebp, %ebp
je 0x5f24f
movq 0x28(%rsp), %rdi
movl %ebp, %esi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f682
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq