// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/sqlite3.c
// Function: windowCodeRowExprStep
static void windowCodeRowExprStep(
  Parse *pParse, 
  Select *p,
  WhereInfo *pWInfo,
  int regGosub, 
  int addrGosub
){
  Window *pMWin = p->pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  int regFlushPart;               /* Register for "Gosub flush_partition" */
  int lblFlushPart;               /* Label for "Gosub flush_partition" */
  int lblFlushDone;               /* Label for "Gosub flush_partition_done" */

  int regArg;
  int addr;
  int csrStart = pParse->nTab++;
  int csrEnd = pParse->nTab++;
  int regStart;                    /* Value of <expr> PRECEDING */
  int regEnd;                      /* Value of <expr> FOLLOWING */
  int addrGoto;
  int addrTop;
  int addrIfPos1 = 0;
  int addrIfPos2 = 0;
  int regSize = 0;

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

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

  regStart = ++pParse->nMem;
  regEnd = ++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)+3);
  VdbeCoverage(v);
  VdbeComment((v, "Flush_partition subroutine"));
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);

  /* If either regStart or regEnd are not non-negative integers, throw 
  ** an exception.  */
  if( pMWin->pStart ){
    sqlite3ExprCode(pParse, pMWin->pStart, regStart);
    windowCheckIntValue(pParse, regStart, 0);
  }
  if( pMWin->pEnd ){
    sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
    windowCheckIntValue(pParse, regEnd, 1);
  }

  /* If this is "ROWS <expr1> FOLLOWING AND ROWS <expr2> FOLLOWING", do:
  **
  **   if( regEnd<regStart ){
  **     // The frame always consists of 0 rows
  **     regStart = regSize;
  **   }
  **   regEnd = regEnd - regStart;
  */
  if( pMWin->pEnd && pMWin->eStart==TK_FOLLOWING ){
    assert( pMWin->pStart!=0 );
    assert( pMWin->eEnd==TK_FOLLOWING );
    sqlite3VdbeAddOp3(v, OP_Ge, regStart, sqlite3VdbeCurrentAddr(v)+2, regEnd);
    VdbeCoverageNeverNull(v);
    sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
    sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
  }

  if( pMWin->pStart && pMWin->eEnd==TK_PRECEDING ){
    assert( pMWin->pEnd!=0 );
    assert( pMWin->eStart==TK_PRECEDING );
    sqlite3VdbeAddOp3(v, OP_Le, regStart, sqlite3VdbeCurrentAddr(v)+3, regEnd);
    VdbeCoverageNeverNull(v);
    sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
    sqlite3VdbeAddOp2(v, OP_Copy, regSize, regEnd);
  }

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

  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
  VdbeCoverage(v);
  sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
  VdbeCoverageNeverTaken(v);
  sqlite3VdbeChangeP5(v, 1);
  sqlite3VdbeAddOp2(v, OP_Rewind, csrEnd, lblFlushDone);
  VdbeCoverageNeverTaken(v);
  sqlite3VdbeChangeP5(v, 1);

  /* Invoke AggStep function for each window function using the row that
  ** csrEnd currently points to. Or, if csrEnd is already at EOF,
  ** do nothing.  */
  addrTop = sqlite3VdbeCurrentAddr(v);
  if( pMWin->eEnd==TK_PRECEDING ){
    addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
    VdbeCoverage(v);
  }
  sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
  VdbeCoverage(v);
  addr = sqlite3VdbeAddOp0(v, OP_Goto);
  windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);
  if( pMWin->eEnd==TK_UNBOUNDED ){
    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
    sqlite3VdbeJumpHere(v, addr);
    addrTop = sqlite3VdbeCurrentAddr(v);
  }else{
    sqlite3VdbeJumpHere(v, addr);
    if( pMWin->eEnd==TK_PRECEDING ){
      sqlite3VdbeJumpHere(v, addrIfPos1);
    }
  }

  if( pMWin->eEnd==TK_FOLLOWING ){
    addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
    VdbeCoverage(v);
  }
  if( pMWin->eStart==TK_FOLLOWING ){
    addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
    VdbeCoverage(v);
  }
  windowAggFinal(pParse, pMWin, 0);
  windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
  sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
  VdbeCoverage(v);
  sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
  if( pMWin->eStart==TK_FOLLOWING ){
    sqlite3VdbeJumpHere(v, addrIfPos2);
  }

  if( pMWin->eStart==TK_CURRENT 
   || pMWin->eStart==TK_PRECEDING 
   || pMWin->eStart==TK_FOLLOWING 
  ){
    int lblSkipInverse = sqlite3VdbeMakeLabel(v);;
    if( pMWin->eStart==TK_PRECEDING ){
      sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
      VdbeCoverage(v);
    }
    if( pMWin->eStart==TK_FOLLOWING ){
      sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);
      VdbeCoverage(v);
      sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);
    }else{
      sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
      VdbeCoverageAlwaysTaken(v);
    }
    windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
    sqlite3VdbeResolveLabel(v, lblSkipInverse);
  }
  if( pMWin->eEnd==TK_FOLLOWING ){
    sqlite3VdbeJumpHere(v, addrIfPos1);
  }
  sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);

  /* flush_partition_done: */
  sqlite3VdbeResolveLabel(v, lblFlushDone);
  sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
  sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
  VdbeComment((v, "end flush_partition subroutine"));

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %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 -0x8(%rbp), %rcx
movl 0x34(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x34(%rcx)
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rcx
movl 0x34(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x34(%rcx)
movl %eax, -0x4c(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
callq 0x46e490
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x46e490
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x34(%rbp), %ecx
movl -0x38(%rbp), %r8d
leaq -0x68(%rbp), %r9
callq 0x495260
movq -0x30(%rbp), %rdi
movl $0xb, %esi
callq 0x46bb70
movl %eax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x46e530
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0x78(%rbp), %rdi
movl %eax, %ecx
addl $0x3, %ecx
movl $0x11, %esi
xorl %edx, %edx
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x48(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x48(%rax), %ecx
movl $0x6f, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x48(%rax), %ecx
movl $0x6f, %esi
callq 0x453790
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4942c4
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rsi
movl -0x50(%rbp), %edx
callq 0x46be40
movq -0x8(%rbp), %rdi
movl -0x50(%rbp), %esi
xorl %edx, %edx
callq 0x495470
movq -0x28(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x4942f4
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rsi
movl -0x54(%rbp), %edx
callq 0x46be40
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
movl $0x1, %edx
callq 0x495470
movq -0x28(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x49436f
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x53, %eax
jne 0x49436f
movq -0x30(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0x88(%rbp), %rdi
movl -0x7c(%rbp), %edx
movl %eax, %ecx
addl $0x2, %ecx
movl -0x54(%rbp), %r8d
movl $0x39, %esi
callq 0x4537c0
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %edx
movl -0x50(%rbp), %ecx
movl $0x4e, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x54(%rbp), %ecx
movl -0x54(%rbp), %r8d
movl $0x61, %esi
callq 0x4537c0
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4943ec
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x55, %eax
jne 0x4943ec
movq -0x30(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0x98(%rbp), %rdi
movl -0x8c(%rbp), %edx
movl %eax, %ecx
addl $0x3, %ecx
movl -0x54(%rbp), %r8d
movl $0x37, %esi
callq 0x4537c0
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %edx
movl -0x50(%rbp), %ecx
movl $0x4e, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %edx
movl -0x54(%rbp), %ecx
movl $0x4e, %esi
callq 0x453790
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x495570
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %edx
movl -0x3c(%rbp), %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x48(%rbp), %edx
movl -0x3c(%rbp), %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x411430
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %edx
movl -0x3c(%rbp), %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x411430
movq -0x30(%rbp), %rdi
callq 0x473080
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x55, %eax
jne 0x49448d
movq -0x30(%rbp), %rdi
movl -0x54(%rbp), %edx
movl $0x2f, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x4537c0
movl %eax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xa8(%rbp), %rdi
movl -0x9c(%rbp), %edx
movl %eax, %ecx
addl $0x2, %ecx
movl $0x5, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl $0xb, %esi
callq 0x46bb70
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl -0x40(%rbp), %r8d
movl -0x68(%rbp), %r9d
xorl %ecx, %ecx
callq 0x4956d0
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x57, %eax
jne 0x49452b
movq -0x30(%rbp), %rdi
movl -0x5c(%rbp), %ecx
movl $0xb, %esi
xorl %edx, %edx
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x46bba0
movq -0x30(%rbp), %rdi
callq 0x473080
movl %eax, -0x5c(%rbp)
jmp 0x494552
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x46bba0
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x55, %eax
jne 0x494550
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x46bba0
jmp 0x494552
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x53, %eax
jne 0x49457b
movq -0x30(%rbp), %rdi
movl -0x54(%rbp), %edx
movl $0x2f, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x4537c0
movl %eax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x53, %eax
jne 0x4945a4
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl $0x2f, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x4537c0
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x495aa0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0x495c80
movq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0xac(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %edx
movl %eax, %ecx
addl $0x2, %ecx
movl $0x5, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %ecx
movl $0xb, %esi
xorl %edx, %edx
callq 0x453790
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x53, %eax
jne 0x49462f
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x46bba0
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x52, %eax
je 0x49465a
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x55, %eax
je 0x49465a
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x53, %eax
jne 0x49474a
movq -0x30(%rbp), %rdi
callq 0x46e490
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x55, %eax
jne 0x49468d
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x6c(%rbp), %ecx
movl $0x2f, %esi
movl $0x1, %r8d
callq 0x4537c0
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x53, %eax
jne 0x4946e8
movq -0x30(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xc8(%rbp), %rdi
movl -0xbc(%rbp), %edx
movl %eax, %ecx
addl $0x2, %ecx
movl $0x5, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x6c(%rbp), %ecx
movl $0xb, %esi
xorl %edx, %edx
callq 0x453790
jmp 0x494721
movq -0x30(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0xcc(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xd8(%rbp), %rdi
movl -0xcc(%rbp), %edx
movl %eax, %ecx
addl $0x1, %ecx
movl $0x5, %esi
callq 0x453790
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x48(%rbp), %edx
movl -0x40(%rbp), %r8d
movl -0x68(%rbp), %r9d
movl $0x1, %ecx
callq 0x4956d0
movq -0x30(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x46e530
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x53, %eax
jne 0x494763
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x46bba0
movq -0x30(%rbp), %rdi
movl -0x5c(%rbp), %ecx
movl $0xb, %esi
xorl %edx, %edx
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x3c(%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 -0x34(%rbp), %edx
movl $0x42, %esi
callq 0x46e2d0
movq -0x30(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x46bba0
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax)