// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/sqlite3.c
// Function: windowAggStep
static void windowAggStep(
  Parse *pParse, 
  Window *pMWin,                  /* Linked list of window functions */
  int csr,                        /* Read arguments from this cursor */
  int bInverse,                   /* True to invoke xInverse instead of xStep */
  int reg,                        /* Array of registers */
  int regPartSize                 /* Register containing size of partition */
){
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    int flags = pWin->pFunc->funcFlags;
    int regArg;
    int nArg = windowArgCount(pWin);

    if( csr>=0 ){
      int i;
      for(i=0; i<nArg; i++){
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
      }
      regArg = reg;
      if( flags & SQLITE_FUNC_WINDOW_SIZE ){
        if( nArg==0 ){
          regArg = regPartSize;
        }else{
          sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);
        }
        nArg++;
      }
    }else{
      assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );
      regArg = reg + pWin->iArgCol;
    }

    if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX) 
      && pWin->eStart!=TK_UNBOUNDED 
    ){
      int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);
      VdbeCoverage(v);
      if( bInverse==0 ){
        sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
        sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp);
        sqlite3VdbeAddOp3(v, OP_MakeRecord, pWin->regApp, 2, pWin->regApp+2);
        sqlite3VdbeAddOp2(v, OP_IdxInsert, pWin->csrApp, pWin->regApp+2);
      }else{
        sqlite3VdbeAddOp4Int(v, OP_SeekGE, pWin->csrApp, 0, regArg, 1);
        VdbeCoverageNeverTaken(v);
        sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);
        sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
      }
      sqlite3VdbeJumpHere(v, addrIsNull);
    }else if( pWin->regApp ){
      assert( pWin->pFunc->zName==nth_valueName
           || pWin->pFunc->zName==first_valueName
      );
      assert( bInverse==0 || bInverse==1 );
      sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
    }else if( pWin->pFunc->zName==leadName
           || pWin->pFunc->zName==lagName
    ){
      /* no-op */
    }else{
      int addrIf = 0;
      if( pWin->pFilter ){
        int regTmp;
        assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
        assert( nArg || pWin->pOwner->x.pList==0 );
        if( csr>0 ){
          regTmp = sqlite3GetTempReg(pParse);
          sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
        }else{
          regTmp = regArg + nArg;
        }
        addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
        VdbeCoverage(v);
        if( csr>0 ){
          sqlite3ReleaseTempReg(pParse, regTmp);
        }
      }
      if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
        CollSeq *pColl;
        assert( nArg>0 );
        pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
        sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
      }
      sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep, 
                        bInverse, regArg, pWin->regAccum);
      sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
      sqlite3VdbeChangeP5(v, (u8)nArg);
      if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x46bb00
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x495a90
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
callq 0x496000
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x4957b2
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x49576f
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x6c(%rax), %ecx
addl -0x40(%rbp), %ecx
movl -0x1c(%rbp), %r8d
addl -0x40(%rbp), %r8d
movl $0x5a, %esi
callq 0x4537c0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x495739
movl -0x1c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
andl $0x20000, %eax          # imm = 0x20000
cmpl $0x0, %eax
je 0x4957b0
cmpl $0x0, -0x3c(%rbp)
jne 0x495790
movl -0x20(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x4957a7
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %edx
movl -0x1c(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movl $0x4f, %esi
callq 0x453790
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4957bf
movl -0x1c(%rbp), %eax
movq -0x30(%rbp), %rcx
addl 0x6c(%rcx), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x4(%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x4958e5
movq -0x30(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x57, %eax
je 0x4958e5
movq -0x28(%rbp), %rdi
movl -0x38(%rbp), %edx
movl $0x32, %esi
callq 0x46e2d0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x49587f
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x58(%rax), %edx
addl $0x1, %edx
movl $0x53, %esi
movl $0x1, %ecx
callq 0x453790
movq -0x28(%rbp), %rdi
movl -0x38(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x58(%rax), %ecx
movl $0x4f, %esi
callq 0x453790
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x58(%rax), %edx
movq -0x30(%rbp), %rax
movl 0x58(%rax), %r8d
addl $0x2, %r8d
movl $0x66, %esi
movl $0x2, %ecx
callq 0x4537c0
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x54(%rax), %edx
movq -0x30(%rbp), %rax
movl 0x58(%rax), %ecx
addl $0x2, %ecx
movl $0x85, %esi
callq 0x453790
jmp 0x4958d4
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x54(%rax), %edx
movl -0x38(%rbp), %r8d
movl $0x18, %esi
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x4113b0
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x54(%rax), %edx
movl $0x7c, %esi
callq 0x46e2d0
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rdi
callq 0x473080
movq -0x60(%rbp), %rdi
movl %eax, %esi
subl $0x2, %esi
callq 0x46bba0
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x46bba0
jmp 0x495a7d
movq -0x30(%rbp), %rax
cmpl $0x0, 0x58(%rax)
je 0x495914
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x58(%rax), %edx
addl $0x1, %edx
subl -0x18(%rbp), %edx
movl $0x53, %esi
movl $0x1, %ecx
callq 0x453790
jmp 0x495a7b
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
leaq 0xe83a3(%rip), %rcx     # 0x57dcc6
cmpq %rcx, 0x38(%rax)
je 0x49593e
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
leaq 0xe8393(%rip), %rcx     # 0x57dccb
cmpq %rcx, 0x38(%rax)
jne 0x495943
jmp 0x495a79
movl $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x4959c1
cmpl $0x0, -0x14(%rbp)
jle 0x495988
movq -0x8(%rbp), %rdi
callq 0x470ad0
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x6c(%rax), %ecx
addl -0x3c(%rbp), %ecx
movl -0x4c(%rbp), %r8d
movl $0x5a, %esi
callq 0x4537c0
jmp 0x495991
movl -0x38(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rdi
movl -0x4c(%rbp), %edx
movl $0x14, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x4537c0
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x4959bf
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x470060
jmp 0x4959c1
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x4(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x495a13
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x485c70
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %r9
movl $0x52, %esi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
movl $0xfffffffe, (%rsp)     # imm = 0xFFFFFFFE
callq 0x46bbd0
movq -0x28(%rbp), %rdi
movl -0x18(%rbp), %ecx
movl $0x9b, %esi
movl $0x9a, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movl -0x18(%rbp), %edx
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movl 0x4c(%rax), %r8d
callq 0x4537c0
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
movl $0xfffffff8, %edx       # imm = 0xFFFFFFF8
callq 0x46c440
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %eax
movzbl %al, %eax
movzwl %ax, %esi
callq 0x411430
cmpl $0x0, -0x48(%rbp)
je 0x495a77
movq -0x28(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x46bba0
jmp 0x495a79
jmp 0x495a7b
jmp 0x495a7d
jmp 0x495a7f
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x495703
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)