// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x46bb00
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x48(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movswl 0x46(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x40(%rbp), %ecx
addl $0x2, %ecx
movq -0x8(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x495327
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x44(%rbp), %ecx
movl -0x48(%rbp), %r8d
addl -0x44(%rbp), %r8d
movl $0x5a, %esi
callq 0x4537c0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x4952f8
movq -0x38(%rbp), %rdi
movl -0x48(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x4c(%rbp), %r8d
movl $0x66, %esi
callq 0x4537c0
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x49540c
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x48(%rbp), %eax
movq -0x30(%rbp), %rcx
addl 0x68(%rcx), %eax
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x47fc00
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rdi
movl -0x68(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x5c(%rax), %ecx
movl -0x64(%rbp), %r8d
movl $0x57, %esi
callq 0x4537c0
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rdi
movq -0x70(%rbp), %rsi
movl $0xfffffff7, %edx       # imm = 0xFFFFFFF7
callq 0x46c440
movq -0x38(%rbp), %rdi
movl -0x54(%rbp), %edx
addl $0x2, %edx
movl -0x54(%rbp), %ecx
addl $0x4, %ecx
movl -0x54(%rbp), %r8d
addl $0x2, %r8d
movl $0x10, %esi
callq 0x4537c0
movq -0x38(%rbp), %rdi
movl -0x68(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x5c(%rax), %ecx
movl -0x64(%rbp), %r8d
subl $0x1, %r8d
movl $0x4e, %esi
callq 0x4537c0
movq -0x38(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0xc, %esi
callq 0x453790
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x48(%rax), %edx
movl -0x50(%rbp), %ecx
movl $0x79, %esi
callq 0x453790
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x48(%rax), %edx
movl -0x4c(%rbp), %ecx
movl -0x50(%rbp), %r8d
movl $0x7a, %esi
callq 0x4537c0
movq -0x18(%rbp), %rdi
callq 0x481df0
movq -0x38(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0xc, %esi
callq 0x453790
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)