// File: /workspace/github_c_makefile_star2_O2/ukontainer[P]sqlite-bench/sqlite3.c
// Function: windowPartitionCache
static void windowPartitionCache(
  Parse *pParse,
  Select *p,                      /* The rewritten SELECT statement */
  WhereInfo *pWInfo,              /* WhereInfo to call WhereEnd() on */
  int regFlushPart,               /* Register to use with Gosub lblFlushPart */
  int lblFlushPart,               /* Subroutine to Gosub to */
  int *pRegSize                   /* OUT: Register containing partition size */
){
  Window *pMWin = p->pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  int iSubCsr = p->pSrc->a[0].iCursor;
  int nSub = p->pSrc->a[0].pTab->nCol;
  int k;

  int reg = pParse->nMem+1;
  int regRecord = reg+nSub;
  int regRowid = regRecord+1;

  *pRegSize = regRowid;
  pParse->nMem += nSub + 2;

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

  /* Check if this is the start of a new partition. If so, call the
  ** flush_partition sub-routine.  */
  if( pMWin->pPartition ){
    int addr;
    ExprList *pPart = pMWin->pPartition;
    int nPart = pPart->nExpr;
    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);
    sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
    VdbeCoverageEqNe(v);
    sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
    sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
    VdbeComment((v, "call flush_partition"));
  }

  /* Buffer the current row in the ephemeral table. */
  sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
  sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);

  /* End of the input loop */
  sqlite3WhereEnd(pWInfo);

  /* Invoke "flush_partition" to deal with the final (or only) partition */
  sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
  VdbeComment((v, "call flush_partition"));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movl %r8d, 0x1c(%rsp)
movl %ecx, 0x8(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, %r14
movq %rdi, %r13
movq 0x70(%rsi), %rax
movq %rax, 0x10(%rsp)
callq 0x44856b
movq %rax, %r15
movq 0x28(%r14), %rax
movl 0x48(%rax), %r12d
movq 0x28(%rax), %rax
movswl 0x46(%rax), %ecx
movl 0x38(%r13), %r14d
leal 0x1(%r14,%rcx), %eax
movl %eax, 0xc(%rsp)
leal (%r14,%rcx), %eax
addl $0x2, %eax
incl %r14d
movl %eax, 0x18(%rsp)
movl %eax, (%rbx)
movl 0x38(%r13), %eax
addl %ecx, %eax
addl $0x2, %eax
movq %r13, 0x20(%rsp)
movl %eax, 0x38(%r13)
xorl %r13d, %r13d
testl %ecx, %ecx
movl $0x0, %ebp
movq %rcx, 0x28(%rsp)
cmovgl %ecx, %ebp
pushq $0x5a
popq %rbx
cmpl %r13d, %ebp
je 0x45e6c1
leal (%r14,%r13), %r8d
movq %r15, %rdi
movl %ebx, %esi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x432a44
incl %r13d
jmp 0x45e6a3
pushq $0x66
popq %rsi
movq %r15, %rdi
movl %r14d, %edx
movq 0x28(%rsp), %rcx
movl 0xc(%rsp), %r8d
callq 0x432a44
movq 0x10(%rsp), %rbx
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
movl 0x1c(%rsp), %r12d
movl 0x8(%rsp), %r13d
je 0x45e787
movl (%rsi), %ebp
addl 0x68(%rbx), %r14d
movq 0x20(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x452dfc
movq %rax, %rbx
movq 0x10(%rsp), %rax
movl 0x5c(%rax), %ecx
pushq $0x57
popq %rsi
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %r8d
callq 0x432a44
movl %r12d, %r13d
movl %eax, %r12d
pushq $-0x9
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rbx
callq 0x448919
leal 0x2(%r12), %edx
addl $0x4, %r12d
pushq $0x10
popq %rsi
movq %r15, %rdi
movl %r12d, %ecx
movl %r13d, %r12d
movl 0x8(%rsp), %r13d
movl %edx, %r8d
callq 0x432a44
movl 0x5c(%rbx), %ecx
decl %ebp
pushq $0x4e
popq %rsi
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %r8d
callq 0x432a44
pushq $0xc
popq %rsi
movq %r15, %rdi
movl %r13d, %edx
movl %r12d, %ecx
callq 0x432a3f
movl 0x48(%rbx), %edx
pushq $0x79
popq %rsi
movq %r15, %rdi
movl 0x18(%rsp), %ebp
movl %ebp, %ecx
callq 0x432a3f
movl 0x48(%rbx), %edx
pushq $0x7a
popq %rsi
movq %r15, %rdi
movl 0xc(%rsp), %ecx
movl %ebp, %r8d
callq 0x432a44
movq 0x30(%rsp), %rdi
callq 0x456c15
pushq $0xc
popq %rsi
movq %r15, %rdi
movl %r13d, %edx
movl %r12d, %ecx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x432a3f