// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/sqlite3.c
// Function: windowCodeCacheStep
static void windowCodeCacheStep(
  Parse *pParse, 
  Select *p,
  WhereInfo *pWInfo,
  int regGosub, 
  int addrGosub
){
  Window *pMWin = p->pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  int k;
  int addr;
  ExprList *pPart = pMWin->pPartition;
  ExprList *pOrderBy = pMWin->pOrderBy;
  int nPeer = pOrderBy ? pOrderBy->nExpr : 0;
  int regNewPeer;

  int addrGoto;                   /* Address of Goto used to jump flush_par.. */
  int addrNext;                   /* Jump here for next iteration of loop */
  int regFlushPart;
  int lblFlushPart;
  int csrLead;
  int regCtr;
  int regArg;                     /* Register array to martial function args */
  int regSize;
  int lblEmpty;
  int bReverse = pMWin->pOrderBy && pMWin->eStart==TK_CURRENT 
          && pMWin->eEnd==TK_UNBOUNDED;

  assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT) 
       || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED) 
       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT) 
       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED) 
  );

  lblEmpty = sqlite3VdbeMakeLabel(v);
  regNewPeer = pParse->nMem+1;
  pParse->nMem += nPeer;

  /* Allocate register and label for the "flush_partition" sub-routine. */
  regFlushPart = ++pParse->nMem;
  lblFlushPart = sqlite3VdbeMakeLabel(v);

  csrLead = pParse->nTab++;
  regCtr = ++pParse->nMem;

  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);

  /* Start of "flush_partition" */
  sqlite3VdbeResolveLabel(v, lblFlushPart);
  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
  VdbeCoverage(v);
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);

  /* Initialize the accumulator register for each window function to NULL */
  regArg = windowInitAccum(pParse, pMWin);

  sqlite3VdbeAddOp2(v, OP_Integer, 0, regCtr);
  sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
  VdbeCoverage(v);
  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblEmpty);
  VdbeCoverageNeverTaken(v);

  if( bReverse ){
    int addr2 = sqlite3VdbeCurrentAddr(v);
    windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
    sqlite3VdbeAddOp2(v, OP_Next, csrLead, addr2);
    VdbeCoverage(v);
    sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
    VdbeCoverageNeverTaken(v);
  }
  addrNext = sqlite3VdbeCurrentAddr(v);

  if( pOrderBy && (pMWin->eEnd==TK_CURRENT || pMWin->eStart==TK_CURRENT) ){
    int bCurrent = (pMWin->eStart==TK_CURRENT);
    int addrJump = 0;             /* Address of OP_Jump below */
    if( pMWin->eType==TK_RANGE ){
      int iOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
      int regPeer = pMWin->regPart + (pPart ? pPart->nExpr : 0);
      KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
      for(k=0; k<nPeer; k++){
        sqlite3VdbeAddOp3(v, OP_Column, csrLead, iOff+k, regNewPeer+k);
      }
      addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
      sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
      addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
      VdbeCoverage(v);
      sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, nPeer-1);
    }

    windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 
        (bCurrent ? regArg : 0), (bCurrent ? regSize : 0)
    );
    if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
  }

  if( bReverse==0 ){
    windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
  }
  sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);
  sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrNext);
  VdbeCoverage(v);

  windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 0, 0);

  sqlite3VdbeResolveLabel(v, lblEmpty);
  sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
  sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);

  /* Jump to here to skip over flush_partition */
  sqlite3VdbeJumpHere(v, addrGoto);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x46bb00
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x494824
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
jmp 0x49482e
xorl %eax, %eax
movl %eax, -0x9c(%rbp)
jmp 0x49482e
movl -0x9c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x10(%rcx)
movb %al, -0x9d(%rbp)
je 0x494873
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %ecx
xorl %eax, %eax
cmpl $0x52, %ecx
movb %al, -0x9d(%rbp)
jne 0x494873
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x57, %eax
sete %al
movb %al, -0x9d(%rbp)
movb -0x9d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x78(%rbp)
movq -0x30(%rbp), %rdi
callq 0x46e490
movl %eax, -0x74(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x46e490
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rcx
movl 0x34(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x34(%rcx)
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x5c(%rbp), %ecx
movl -0x60(%rbp), %r8d
leaq -0x70(%rbp), %r9
callq 0x495260
movq -0x30(%rbp), %rdi
movl $0xb, %esi
callq 0x46bb70
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x46e530
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xa8(%rbp), %rdi
movl %eax, %ecx
addl $0x2, %ecx
movl $0x11, %esi
xorl %edx, %edx
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x48(%rax), %ecx
movl $0x6f, %esi
callq 0x453790
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x495570
movl %eax, -0x6c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %ecx
movl $0x46, %esi
xorl %edx, %edx
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x74(%rbp), %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %edx
movl -0x74(%rbp), %ecx
movl $0x24, %esi
callq 0x453790
cmpl $0x0, -0x78(%rbp)
je 0x494a05
movq -0x30(%rbp), %rdi
callq 0x473080
movl %eax, -0x7c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x64(%rbp), %edx
movl -0x6c(%rbp), %r8d
movl -0x70(%rbp), %r9d
xorl %ecx, %ecx
callq 0x4956d0
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x7c(%rbp), %ecx
movl $0x5, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x74(%rbp), %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
callq 0x473080
movl %eax, -0x58(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x494c78
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x52, %eax
je 0x494a3a
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x52, %eax
jne 0x494c78
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x52, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movq -0x28(%rbp), %rax
movzbl 0x18(%rax), %eax
cmpl $0x56, %eax
jne 0x494bb5
movq -0x28(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0xac(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x494a8d
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
jmp 0x494a97
xorl %eax, %eax
movl %eax, -0xb0(%rbp)
jmp 0x494a97
movl -0xac(%rbp), %eax
movl -0xb0(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0xb4(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x494acd
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xb8(%rbp)
jmp 0x494ad7
xorl %eax, %eax
movl %eax, -0xb8(%rbp)
jmp 0x494ad7
movl -0xb4(%rbp), %eax
movl -0xb8(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x8c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x47fc00
movq %rax, -0x98(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x494b3f
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x88(%rbp), %ecx
addl -0x34(%rbp), %ecx
movl -0x50(%rbp), %r8d
addl -0x34(%rbp), %r8d
movl $0x5a, %esi
callq 0x4537c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x494b0a
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x8c(%rbp), %ecx
movl -0x4c(%rbp), %r8d
movl $0x57, %esi
callq 0x4537c0
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %rsi
movl $0xfffffff7, %edx       # imm = 0xFFFFFFF7
callq 0x46c440
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %edx
addl $0x2, %edx
movl -0x38(%rbp), %r8d
addl $0x2, %r8d
movl $0x10, %esi
xorl %ecx, %ecx
callq 0x4537c0
movl %eax, -0x84(%rbp)
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x8c(%rbp), %ecx
movl -0x4c(%rbp), %r8d
subl $0x1, %r8d
movl $0x4e, %esi
callq 0x4537c0
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xc0(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xbc(%rbp)
cmpl $0x0, -0x80(%rbp)
je 0x494bf7
movl -0x6c(%rbp), %eax
movl %eax, -0xdc(%rbp)
jmp 0x494c01
xorl %eax, %eax
movl %eax, -0xdc(%rbp)
jmp 0x494c01
movl -0xdc(%rbp), %eax
movl %eax, -0xe0(%rbp)
cmpl $0x0, -0x80(%rbp)
je 0x494c1e
movl -0x70(%rbp), %eax
movl %eax, -0xe4(%rbp)
jmp 0x494c28
xorl %eax, %eax
movl %eax, -0xe4(%rbp)
jmp 0x494c28
movl -0xe0(%rbp), %r9d
movl -0xbc(%rbp), %r8d
movl -0xc0(%rbp), %ecx
movl -0xc4(%rbp), %edx
movq -0xd0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
movl -0xe4(%rbp), %eax
movl %eax, (%rsp)
callq 0x496040
cmpl $0x0, -0x84(%rbp)
je 0x494c76
movq -0x30(%rbp), %rdi
movl -0x84(%rbp), %esi
callq 0x46bba0
jmp 0x494c78
cmpl $0x0, -0x78(%rbp)
jne 0x494c98
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x64(%rbp), %edx
movl -0x6c(%rbp), %r8d
movl -0x70(%rbp), %r9d
xorl %ecx, %ecx
callq 0x4956d0
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %edx
movl $0x53, %esi
movl $0x1, %ecx
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x58(%rbp), %ecx
movl $0x5, %esi
callq 0x453790
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x68(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
xorl %r9d, %r9d
movl $0x0, (%rsp)
callq 0x496040
movq -0x30(%rbp), %rdi
movl -0x74(%rbp), %esi
callq 0x46e530
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %edx
movl $0x8b, %esi
callq 0x46e2d0
movq -0x30(%rbp), %rdi
movl -0x5c(%rbp), %edx
movl $0x42, %esi
callq 0x46e2d0
movq -0x30(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x46bba0
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)