// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/sqlite3.c
// Function: windowCodeDefaultStep
static void windowCodeDefaultStep(
  Parse *pParse, 
  Select *p,
  WhereInfo *pWInfo,
  int regGosub, 
  int addrGosub
){
  Window *pMWin = p->pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  int k;
  int iSubCsr = p->pSrc->a[0].iCursor;
  int nSub = p->pSrc->a[0].pTab->nCol;
  int reg = pParse->nMem+1;
  int regRecord = reg+nSub;
  int regRowid = regRecord+1;
  int addr;
  ExprList *pPart = pMWin->pPartition;
  ExprList *pOrderBy = pMWin->pOrderBy;

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

  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 && !pOrderBy)
  );

  if( pMWin->eEnd==TK_UNBOUNDED ){
    pOrderBy = 0;
  }

  pParse->nMem += nSub + 2;

  /* Load the individual column values of the row returned by
  ** the sub-select into an array of registers. */
  for(k=0; k<nSub; k++){
    sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
  }

  /* Check if this is the start of a new partition or peer group. */
  if( pPart || pOrderBy ){
    int nPart = (pPart ? pPart->nExpr : 0);
    int addrGoto = 0;
    int addrJump = 0;
    int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);

    if( pPart ){
      int regNewPart = reg + pMWin->nBufferCol;
      KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
      addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
      sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
      addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
      VdbeCoverageEqNe(v);
      windowAggFinal(pParse, pMWin, 1);
      if( pOrderBy ){
        addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
      }
    }

    if( pOrderBy ){
      int regNewPeer = reg + pMWin->nBufferCol + nPart;
      int regPeer = pMWin->regPart + nPart;

      if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
      if( pMWin->eType==TK_RANGE ){
        KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
        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);
      }else{
        addrJump = 0;
      }
      windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);
      if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
    }

    sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
    VdbeCoverage(v);
    sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
    sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
    VdbeCoverage(v);

    sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
    sqlite3VdbeAddOp3(
        v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
    );

    if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
  }

  /* Invoke step function for window functions */
  windowAggStep(pParse, pMWin, -1, 0, reg, 0);

  /* Buffer the current row in the ephemeral table. */
  if( pMWin->nBufferCol>0 ){
    sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
  }else{
    sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
    sqlite3VdbeAppendP4(v, (void*)"", 0);
  }
  sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
  sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);

  /* End the database scan loop. */
  sqlite3WhereEnd(pWInfo);

  windowAggFinal(pParse, pMWin, 1);
  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
  VdbeCoverage(v);
  sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
  sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
  VdbeCoverage(v);
}

// 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 -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x48(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movswl 0x46(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movzbl 0x1a(%rax), %eax
cmpl $0x57, %eax
jne 0x494dd4
movq $0x0, -0x60(%rbp)
movl -0x3c(%rbp), %ecx
addl $0x2, %ecx
movq -0x8(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x494e1a
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %edx
movl -0x34(%rbp), %ecx
movl -0x40(%rbp), %r8d
addl -0x34(%rbp), %r8d
movl $0x5a, %esi
callq 0x4537c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x494deb
cmpq $0x0, -0x58(%rbp)
jne 0x494e2c
cmpq $0x0, -0x60(%rbp)
je 0x495110
cmpq $0x0, -0x58(%rbp)
je 0x494e41
movq -0x58(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
jmp 0x494e4b
xorl %eax, %eax
movl %eax, -0x94(%rbp)
jmp 0x494e4b
movl -0x94(%rbp), %eax
movl %eax, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x494e77
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x98(%rbp)
jmp 0x494e81
xorl %eax, %eax
movl %eax, -0x98(%rbp)
jmp 0x494e81
movl -0x98(%rbp), %eax
movl %eax, -0x70(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x494f35
movl -0x40(%rbp), %eax
movq -0x28(%rbp), %rcx
addl 0x68(%rcx), %eax
movl %eax, -0x74(%rbp)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x47fc00
movq %rax, -0x80(%rbp)
movq -0x30(%rbp), %rdi
movl -0x74(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x5c(%rax), %ecx
movl -0x64(%rbp), %r8d
movl $0x57, %esi
callq 0x4537c0
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl $0xfffffff7, %edx       # imm = 0xFFFFFFF7
callq 0x46c440
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %edx
addl $0x2, %edx
movl -0x4c(%rbp), %r8d
addl $0x2, %r8d
movl $0x10, %esi
xorl %ecx, %ecx
callq 0x4537c0
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0x495aa0
cmpq $0x0, -0x60(%rbp)
je 0x494f33
movq -0x30(%rbp), %rdi
movl $0xb, %esi
callq 0x46bb70
movl %eax, -0x68(%rbp)
jmp 0x494f35
cmpq $0x0, -0x60(%rbp)
je 0x49502e
movl -0x40(%rbp), %eax
movq -0x28(%rbp), %rcx
addl 0x68(%rcx), %eax
addl -0x64(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x28(%rbp), %rax
movl 0x5c(%rax), %eax
addl -0x64(%rbp), %eax
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x6c(%rbp)
je 0x494f75
movq -0x30(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x46bba0
movq -0x28(%rbp), %rax
movzbl 0x18(%rax), %eax
cmpl $0x56, %eax
jne 0x494ff3
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x47fc00
movq %rax, -0x90(%rbp)
movq -0x30(%rbp), %rdi
movl -0x84(%rbp), %edx
movl -0x88(%rbp), %ecx
movl -0x70(%rbp), %r8d
movl $0x57, %esi
callq 0x4537c0
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movq -0x90(%rbp), %rsi
movl $0xfffffff7, %edx       # imm = 0xFFFFFFF7
callq 0x46c440
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %edx
addl $0x2, %edx
movl -0x4c(%rbp), %r8d
addl $0x2, %r8d
movl $0x10, %esi
xorl %ecx, %ecx
callq 0x4537c0
movl %eax, -0x6c(%rbp)
jmp 0x494ffa
movl $0x0, -0x6c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x28(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x52, %eax
sete %al
andb $0x1, %al
movzbl %al, %edx
callq 0x495aa0
cmpl $0x0, -0x68(%rbp)
je 0x49502c
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %esi
callq 0x46bba0
jmp 0x49502e
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 $0x3, %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0xc, %esi
callq 0x453790
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xa8(%rbp), %rdi
movl -0x9c(%rbp), %edx
movl %eax, %ecx
subl $0x1, %ecx
movl $0x5, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %edx
movl $0x8b, %esi
callq 0x46e2d0
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %edx
movq -0x28(%rbp), %rax
addl 0x68(%rax), %edx
movq -0x28(%rbp), %rax
movl 0x5c(%rax), %ecx
movl -0x64(%rbp), %r8d
addl -0x70(%rbp), %r8d
subl $0x1, %r8d
movl $0x4e, %esi
callq 0x4537c0
cmpl $0x0, -0x6c(%rbp)
je 0x49510e
movq -0x30(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x46bba0
jmp 0x495110
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x40(%rbp), %r8d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
movl %r9d, %ecx
callq 0x4956d0
movq -0x28(%rbp), %rax
cmpl $0x0, 0x68(%rax)
jle 0x495154
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x68(%rax), %ecx
movl -0x44(%rbp), %r8d
movl $0x66, %esi
callq 0x4537c0
jmp 0x495179
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %ecx
movl $0x4b, %esi
xorl %edx, %edx
callq 0x453790
movq -0x30(%rbp), %rdi
leaq 0x10ad9b(%rip), %rsi    # 0x59ff0d
xorl %edx, %edx
callq 0x46c440
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %edx
movl -0x48(%rbp), %ecx
movl $0x79, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %edx
movl -0x44(%rbp), %ecx
movl -0x48(%rbp), %r8d
movl $0x7a, %esi
callq 0x4537c0
movq -0x18(%rbp), %rdi
callq 0x481df0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0x495aa0
movq -0x30(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0xcc(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xd8(%rbp), %rdi
movl -0xcc(%rbp), %edx
movl %eax, %ecx
addl $0x3, %ecx
movl $0x24, %esi
callq 0x453790
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0xc, %esi
callq 0x453790
movq -0x30(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0xbc(%rbp)
movq -0x30(%rbp), %rdi
callq 0x473080
movq -0xc8(%rbp), %rdi
movl -0xbc(%rbp), %edx
movl %eax, %ecx
subl $0x1, %ecx
movl $0x5, %esi
callq 0x453790
addq $0xe0, %rsp
popq %rbp
retq
nop