// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x8(%rbp), %rdi
callq 0x6f480
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x6f7de
movl $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x6f639
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x67c30
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x44(%rbp), %edx
movl $0x1, %ecx
callq 0x69d90
jmp 0x6f647
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jl 0x6f679
movq -0x18(%rbp), %rdi
callq 0x67890
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x14(%rax), %esi
movl -0x40(%rbp), %edx
movl -0x44(%rbp), %r8d
movl $0x1, %ecx
callq 0x7bb80
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movzbl 0x3(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6f750
movq $0x0, -0x58(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x58(%rbp)
movb %al, -0x65(%rbp)
jne 0x6f6c4
movl -0x64(%rbp), %eax
cmpl -0x3c(%rbp), %eax
setl %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
testb $0x1, %al
jne 0x6f6cd
jmp 0x6f6f8
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
callq 0x659b0
movq %rax, -0x58(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x60(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x60(%rbp)
jmp 0x6f6ac
cmpq $0x0, -0x58(%rbp)
jne 0x6f70e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x6f72e
movq -0x10(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x6f72e
movq -0x8(%rbp), %rcx
movl 0x58(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x58(%rcx)
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movq -0x58(%rbp), %r9
movl $0x1f, %esi
xorl %r8d, %r8d
movl %r8d, %ecx
movl $0xfffffffc, (%rsp)     # imm = 0xFFFFFFFC
callq 0x5e1b0
movq -0x18(%rbp), %rdi
movl -0x44(%rbp), %ecx
movq -0x30(%rbp), %rax
movl 0x10(%rax), %r8d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r9
movl $0x8, %esi
xorl %edx, %edx
movl $0xfffffffb, (%rsp)     # imm = 0xFFFFFFFB
callq 0x5e1b0
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %eax
movzbl %al, %esi
callq 0x5e540
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x69c40
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x67e90
cmpl $0x0, -0x40(%rbp)
je 0x6f7c2
movq -0x18(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x677f0
movq -0x8(%rbp), %rdi
callq 0x6f480
jmp 0x6f7c4
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
jmp 0x6f5dd
cmpl $0x0, -0x20(%rbp)
je 0x6f7f8
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movl $0x27, %esi
callq 0x5ecf0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6f480
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x6f84f
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x38(%rbp), %rax
movl 0x14(%rax), %edx
callq 0x69c70
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x38(%rbp)
jmp 0x6f814
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rdi
callq 0x6f480
cmpl $0x0, -0x24(%rbp)
je 0x6f871
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x5e090
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)