// File: /workspace/github_c_makefile_star2_O3/ukontainer[P]sqlite-bench/sqlite3.c
// Function: sqlite3WindowCodeInit
SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){
  Window *pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  int nPart = (pMWin->pPartition ? pMWin->pPartition->nExpr : 0);
  nPart += (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
  if( nPart ){
    pMWin->regPart = pParse->nMem+1;
    pParse->nMem += nPart;
    sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nPart-1);
  }

  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    FuncDef *p = pWin->pFunc;
    if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
      /* The inline versions of min() and max() require a single ephemeral
      ** table and 3 registers. The registers are used as follows:
      **
      **   regApp+0: slot to copy min()/max() argument to for MakeRecord
      **   regApp+1: integer value used to ensure keys are unique
      **   regApp+2: output of MakeRecord
      */
      ExprList *pList = pWin->pOwner->x.pList;
      KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
      pWin->csrApp = pParse->nTab++;
      pWin->regApp = pParse->nMem+1;
      pParse->nMem += 3;
      if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
        assert( pKeyInfo->aSortOrder[0]==0 );
        pKeyInfo->aSortOrder[0] = 1;
      }
      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
      sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
      sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
    }
    else if( p->zName==nth_valueName || p->zName==first_valueName ){
      /* Allocate two registers at pWin->regApp. These will be used to
      ** store the start and end index of the current frame.  */
      assert( pMWin->iEphCsr );
      pWin->regApp = pParse->nMem+1;
      pWin->csrApp = pParse->nTab++;
      pParse->nMem += 2;
      sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
    }
    else if( p->zName==leadName || p->zName==lagName ){
      assert( pMWin->iEphCsr );
      pWin->csrApp = pParse->nTab++;
      sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
movq %rdi, %r14
callq 0x44dbe5
movq %rax, %r15
movq 0x8(%r13), %rcx
xorl %r8d, %r8d
movl $0x0, %eax
testq %rcx, %rcx
je 0x45cd7d
movl (%rcx), %eax
movq 0x10(%r13), %rcx
testq %rcx, %rcx
je 0x45cd89
movl (%rcx), %r8d
addl %eax, %r8d
je 0x45cdaf
movl 0x38(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x5c(%r13)
addl %eax, %r8d
movl %r8d, 0x38(%r14)
movq %r15, %rdi
movl $0x49, %esi
xorl %edx, %edx
callq 0x43a65f
leaq 0xf316c(%rip), %r12     # 0x54ff22
leaq 0xf316f(%rip), %rbp     # 0x54ff2c
movq %r13, %rbx
movq %r13, (%rsp)
movq 0x40(%rbx), %rax
testb $0x10, 0x5(%rax)
je 0x45cdd4
cmpb $0x57, 0x19(%rbx)
jne 0x45ce52
movq 0x38(%rax), %rax
cmpq %r12, %rax
setne %cl
cmpq %rbp, %rax
setne %dl
testb %dl, %cl
jne 0x45ce09
movl 0x38(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x58(%rbx)
movl 0x34(%r14), %edx
leal 0x1(%rdx), %ecx
movl %ecx, 0x34(%r14)
movl %edx, 0x54(%rbx)
addl $0x2, %eax
movl %eax, 0x38(%r14)
jmp 0x45ce39
leaq 0xf3128(%rip), %rcx     # 0x54ff38
cmpq %rcx, %rax
setne %cl
leaq 0xf3120(%rip), %rdx     # 0x54ff3d
cmpq %rdx, %rax
setne %al
testb %al, %cl
jne 0x45cf13
movl 0x34(%r14), %edx
leal 0x1(%rdx), %eax
movl %eax, 0x34(%r14)
movl %edx, 0x54(%rbx)
movl 0x48(%r13), %ecx
movq %r15, %rdi
movl $0x6f, %esi
xorl %r8d, %r8d
callq 0x43a65f
jmp 0x45cf13
movq %rbp, %r13
movq %r12, %rbp
movq 0x60(%rbx), %rax
movq 0x20(%rax), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x45cb70
movq %rax, %r12
movl 0x34(%r14), %edx
leal 0x1(%rdx), %eax
movl %eax, 0x34(%r14)
movl %edx, 0x54(%rbx)
movl 0x38(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x58(%rbx)
addl $0x3, %eax
movl %eax, 0x38(%r14)
testq %r12, %r12
je 0x45ceac
movq 0x40(%rbx), %rax
movq 0x38(%rax), %rax
cmpb $0x69, 0x1(%rax)
jne 0x45ceac
movq 0x18(%r12), %rax
movb $0x1, (%rax)
movl 0x54(%rbx), %edx
movq %r15, %rdi
movl $0x71, %esi
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movq (%r15), %rdi
cmpb $0x0, 0x61(%rdi)
je 0x45ced9
movl $0xfffffff7, %esi       # imm = 0xFFFFFFF7
movq %r12, %rdx
callq 0x4233b8
jmp 0x45cef2
movq 0x68(%r15), %rax
movslq 0xb8(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x9, -0x17(%rax,%rcx,8)
movq %r12, -0x8(%rax,%rcx,8)
movl 0x58(%rbx), %ecx
incl %ecx
movq %r15, %rdi
movl $0x46, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x43a65f
movq %rbp, %r12
movq %r13, %rbp
movq (%rsp), %r13
movq 0x30(%rbx), %rbx
testq %rbx, %rbx
jne 0x45cdc4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq