// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x46bb00
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x47fec7
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x47fece
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x47fece
movl -0x44(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x47feee
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, -0x48(%rbp)
jmp 0x47fef5
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x47fef5
movl -0x48(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x47ff49
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x5c(%rax)
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %r8d
addl -0x24(%rbp), %r8d
subl $0x1, %r8d
movl $0x49, %esi
xorl %edx, %edx
callq 0x4537c0
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x480138
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x480059
movq -0x18(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x57, %eax
je 0x480059
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x47fc00
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x34(%rax)
movq -0x18(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0x38(%rax)
cmpq $0x0, -0x40(%rbp)
je 0x48000e
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x38(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x69, %eax
jne 0x48000e
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movb $0x1, (%rax)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x54(%rax), %edx
movl $0x71, %esi
movl $0x2, %ecx
callq 0x453790
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0xfffffff7, %edx       # imm = 0xFFFFFFF7
callq 0x46c440
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x58(%rax), %ecx
addl $0x1, %ecx
movl $0x46, %esi
xorl %edx, %edx
callq 0x453790
jmp 0x480125
movq -0x30(%rbp), %rax
leaq 0xfdc4c(%rip), %rcx     # 0x57dcb0
cmpq %rcx, 0x38(%rax)
je 0x48007b
movq -0x30(%rbp), %rax
leaq 0xfdc45(%rip), %rcx     # 0x57dcba
cmpq %rcx, 0x38(%rax)
jne 0x4800cd
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x34(%rax)
movq -0x18(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x38(%rax)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x54(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
movl $0x6f, %esi
callq 0x453790
jmp 0x480123
movq -0x30(%rbp), %rax
leaq 0xfdbee(%rip), %rcx     # 0x57dcc6
cmpq %rcx, 0x38(%rax)
je 0x4800ef
movq -0x30(%rbp), %rax
leaq 0xfdbe2(%rip), %rcx     # 0x57dccb
cmpq %rcx, 0x38(%rax)
jne 0x480121
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x34(%rax)
movq -0x18(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x54(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
movl $0x6f, %esi
callq 0x453790
jmp 0x480123
jmp 0x480125
jmp 0x480127
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x47ff51
addq $0x50, %rsp
popq %rbp
retq
nop