// File: /workspace/github_c_makefile_star2_O1/ukontainer[P]sqlite-bench/sqlite3.c
// Function: sqlite3WindowAlloc
SQLITE_PRIVATE Window *sqlite3WindowAlloc(
  Parse *pParse,    /* Parsing context */
  int eType,        /* Frame type. TK_RANGE or TK_ROWS */
  int eStart,       /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */
  Expr *pStart,     /* Start window size if TK_PRECEDING or FOLLOWING */
  int eEnd,         /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */
  Expr *pEnd        /* End window size if TK_FOLLOWING or PRECEDING */
){
  Window *pWin = 0;

  /* Parser assures the following: */
  assert( eType==TK_RANGE || eType==TK_ROWS );
  assert( eStart==TK_CURRENT || eStart==TK_PRECEDING
           || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );
  assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING
           || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );
  assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );
  assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );


  /* If a frame is declared "RANGE" (not "ROWS"), then it may not use
  ** either "<expr> PRECEDING" or "<expr> FOLLOWING".
  */
  if( eType==TK_RANGE && (pStart!=0 || pEnd!=0) ){
    sqlite3ErrorMsg(pParse, "RANGE must use only UNBOUNDED or CURRENT ROW");
    goto windowAllocErr;
  }

  /* Additionally, the
  ** starting boundary type may not occur earlier in the following list than
  ** the ending boundary type:
  **
  **   UNBOUNDED PRECEDING
  **   <expr> PRECEDING
  **   CURRENT ROW
  **   <expr> FOLLOWING
  **   UNBOUNDED FOLLOWING
  **
  ** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending
  ** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting
  ** frame boundary.
  */
  if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
   || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
  ){
    sqlite3ErrorMsg(pParse, "unsupported frame delimiter for ROWS");
    goto windowAllocErr;
  }

  pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( pWin==0 ) goto windowAllocErr;
  pWin->eType = eType;
  pWin->eStart = eStart;
  pWin->eEnd = eEnd;
  pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
  pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
  return pWin;

windowAllocErr:
  sqlite3ExprDelete(pParse->db, pEnd);
  sqlite3ExprDelete(pParse->db, pStart);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %r15
movl %r8d, %ebp
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, %r14
cmpl $0x56, %esi
movq %rcx, (%rsp)
jne 0x44e803
movq %rcx, %rax
orq %r15, %rax
je 0x44e803
leaq 0x105edc(%rip), %rsi    # 0x5546dd
jmp 0x44e819
movl %r12d, %eax
xorl $0x52, %eax
movl %ebp, %ecx
xorl $0x55, %ecx
leaq 0x105ef5(%rip), %rsi    # 0x55470a
orl %eax, %ecx
jne 0x44e858
movq %r14, %rdi
xorl %eax, %eax
callq 0x40e237
testq %r15, %r15
je 0x44e833
movq (%r14), %rdi
movq %r15, %rsi
callq 0x439685
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x44e844
movq (%r14), %rdi
callq 0x439685
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x53, %r12d
jne 0x44e868
cmpl $0x52, %ebp
je 0x44e819
cmpl $0x55, %ebp
je 0x44e819
movq (%r14), %rdi
movl $0x70, %esi
callq 0x40c57c
testq %rax, %rax
je 0x44e823
movq %rax, %rbx
movb %r13b, 0x18(%rax)
movb %r12b, 0x19(%rax)
movb %bpl, 0x1a(%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x476b9d
movq %rax, 0x28(%rbx)
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x476b9d
movq %rax, 0x20(%rbx)
jmp 0x44e846