// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: updateAccumulator
static void updateAccumulator(Parse *pParse, 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;
  sqlite3ExprCacheClear(pParse);
  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) );
    if( pList ){
      nArg = pList->nExpr;
      regAgg = sqlite3GetTempRange(pParse, nArg);
      sqlite3ExprCodeExprList(pParse, pList, regAgg, 1);
    }else{
      nArg = 0;
      regAgg = 0;
    }
    if( pF->iDistinct>=0 ){
      addrNext = sqlite3VdbeMakeLabel(v);
      assert( nArg==1 );
      codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
    }
    if( pF->pFunc->flags & 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);
    }
    sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
                      (void*)pF->pFunc, P4_FUNCDEF);
    sqlite3VdbeChangeP5(v, (u8)nArg);
    sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
    sqlite3ReleaseTempRange(pParse, regAgg, nArg);
    if( addrNext ){
      sqlite3VdbeResolveLabel(v, addrNext);
      sqlite3ExprCacheClear(pParse);
    }
  }

  /* Before populating the accumulator registers, clear the column cache.
  ** Otherwise, if any of the required column values are already present 
  ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value
  ** to pC->iMem. But by the time the value is used, the original register
  ** may have been used, invalidating the underlying buffer holding the
  ** text or blob value. See ticket [883034dcb5].
  **
  ** Another solution would be to change the OP_SCopy used to copy cached
  ** values to an OP_Copy.
  */
  if( regHit ){
    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit);
  }
  sqlite3ExprCacheClear(pParse);
  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
  }
  pAggInfo->directMode = 0;
  sqlite3ExprCacheClear(pParse);
  if( addrHitTest ){
    sqlite3VdbeJumpHere(v, addrHitTest);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rdi), %r13
movb $0x1, (%rsi)
callq 0x4da57
movq %rbx, -0x38(%rbp)
movq 0x28(%rbx), %rcx
xorl %ebx, %ebx
xorl %edx, %edx
movq %r13, -0x50(%rbp)
movl %ebx, -0x2c(%rbp)
movq -0x38(%rbp), %rax
cmpl 0x30(%rax), %edx
jge 0x4dcd4
movl %edx, -0x48(%rbp)
movq (%rcx), %rax
movq 0x20(%rax), %rbx
movl $0x0, -0x44(%rbp)
movl $0x0, %r12d
movl $0x0, %r15d
testq %rbx, %rbx
movq %rcx, -0x40(%rbp)
je 0x4db9a
movl (%rbx), %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x47c2c
movl %eax, %r15d
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %edx
pushq $0x1
popq %rcx
callq 0x49599
movq -0x40(%rbp), %rcx
cmpl $0x0, 0x14(%rcx)
js 0x4dbc6
movq %r13, %rdi
callq 0x47934
movl %eax, %edx
movq -0x40(%rbp), %rax
movl 0x14(%rax), %esi
movq %r14, %rdi
movl %edx, -0x44(%rbp)
pushq $0x1
popq %rcx
movl %r15d, %r8d
callq 0x527c8
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %r9
testb $0x8, 0x3(%r9)
jne 0x4dbd6
movl -0x2c(%rbp), %ebx
jmp 0x4dc50
movq 0x8(%rbx), %rbx
xorl %eax, %eax
xorl %r13d, %r13d
testq %rax, %rax
jne 0x4dbfd
cmpl %r12d, %r13d
jge 0x4dbfd
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x466ee
incl %r13d
addq $0x20, %rbx
jmp 0x4dbdf
testq %rax, %rax
jne 0x4dc09
movq (%r14), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ebx
testl %ebx, %ebx
movq -0x50(%rbp), %r13
jne 0x4dc2c
movq -0x38(%rbp), %rcx
cmpl $0x0, 0x24(%rcx)
je 0x4dc2a
movl 0x58(%r14), %ebx
incl %ebx
movl %ebx, 0x58(%r14)
jmp 0x4dc2c
xorl %ebx, %ebx
movl $0xfffffffc, (%rsp)     # imm = 0xFFFFFFFC
movq %r13, %rdi
pushq $0x1f
popq %rsi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x41fd2
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %r9
movl 0x10(%rcx), %r8d
movl $0xfffffffb, (%rsp)     # imm = 0xFFFFFFFB
movq %r13, %rdi
pushq $0x8
popq %rsi
xorl %edx, %edx
movl %r15d, %ecx
callq 0x41fd2
movq 0x8(%r13), %rax
testq %rax, %rax
je 0x4dc81
movslq 0x34(%r13), %rcx
imulq $0x18, %rcx, %rcx
movb %r12b, -0x15(%rax,%rcx)
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x49537
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x47d6c
movl -0x44(%rbp), %edx
testl %edx, %edx
je 0x4dcc2
jns 0x4dcba
movq 0x40(%r13), %rax
testq %rax, %rax
je 0x4dcba
notl %edx
movl 0x34(%r13), %ecx
movl %edx, %edx
movl %ecx, (%rax,%rdx,4)
movq %r14, %rdi
callq 0x4da57
movl -0x48(%rbp), %edx
incl %edx
movq -0x40(%rbp), %rcx
addq $0x18, %rcx
jmp 0x4db3f
xorl %r15d, %r15d
movl $0x0, %ebx
movl -0x2c(%rbp), %edx
testl %edx, %edx
je 0x4dcf0
pushq $0x27
popq %rsi
movq %r13, %rdi
callq 0x42436
movl %eax, %ebx
movq %r14, %rdi
callq 0x4da57
movq -0x38(%rbp), %rax
movq 0x18(%rax), %r12
addq $0x18, %r12
movq -0x38(%rbp), %rax
cmpl 0x24(%rax), %r15d
jge 0x4dd28
movq (%r12), %rsi
movl -0x4(%r12), %edx
movq %r14, %rdi
callq 0x494eb
incl %r15d
addq $0x20, %r12
jmp 0x4dd04
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x4da57
testl %ebx, %ebx
jle 0x4dd51
movl 0x34(%r13), %eax
cmpl %ebx, %eax
jbe 0x4dd51
movq 0x8(%r13), %rcx
movl %ebx, %edx
imulq $0x18, %rdx, %rdx
movl %eax, 0x8(%rcx,%rdx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq