// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3WindowAlloc
SQLITE_PRIVATE Window *sqlite3WindowAlloc(
  Parse *pParse,    /* Parsing context */
  int eType,        /* Frame type. TK_RANGE, TK_ROWS, TK_GROUPS, or 0 */
  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 */
  u8 eExclude       /* EXCLUDE clause */
){
  Window *pWin = 0;
  int bImplicitFrame = 0;

  /* Parser assures the following: */
  assert( eType==0 || eType==TK_RANGE || eType==TK_ROWS || eType==TK_GROUPS );
  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( eType==0 ){
    bImplicitFrame = 1;
    eType = TK_RANGE;
  }

  /* 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 specification");
    goto windowAllocErr;
  }

  pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( pWin==0 ) goto windowAllocErr;
  pWin->eFrmType = eType;
  pWin->eStart = eStart;
  pWin->eEnd = eEnd;
  if( eExclude==0 && OptimizationDisabled(pParse->db, SQLITE_WindowFunc) ){
    eExclude = TK_NO;
  }
  pWin->eExclude = eExclude;
  pWin->bImplicitFrame = bImplicitFrame;
  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
subq $0x18, %rsp
movq %r9, %r15
movq %rcx, 0x10(%rsp)
movl %edx, %r13d
movq %rdi, %r14
testl %esi, %esi
sete %dl
movl %r13d, %eax
xorl $0x55, %eax
movl %r8d, %ecx
xorl $0x58, %ecx
orl %eax, %ecx
jne 0x2bc58e
leaq 0x11d9cf(%rip), %rsi    # 0x3d9f29
movq %r14, %rdi
xorl %eax, %eax
callq 0x27b48d
testq %r15, %r15
je 0x2bc574
movq (%r14), %rdi
movq %r15, %rsi
callq 0x2a6164
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x2bc586
movq (%r14), %rdi
callq 0x2a6164
xorl %r12d, %r12d
jmp 0x2bc61e
movl %r8d, %ebp
movl %esi, %ebx
cmpl $0x56, %r13d
jne 0x2bc5a3
cmpl $0x58, %ebp
je 0x2bc553
cmpl $0x55, %ebp
je 0x2bc553
movb %dl, 0xf(%rsp)
movq (%r14), %rdi
movl $0x90, %esi
callq 0x279b27
testq %rax, %rax
je 0x2bc564
movq %rax, %r12
movb 0x50(%rsp), %al
testl %ebx, %ebx
movzbl %bl, %ecx
movl $0x59, %edx
cmovnel %ecx, %edx
movb %dl, 0x20(%r12)
movb %r13b, 0x21(%r12)
movb %bpl, 0x22(%r12)
testb %al, %al
jne 0x2bc5ee
movq (%r14), %rax
movb 0x5c(%rax), %al
shlb $0x6, %al
sarb $0x7, %al
andb $0x42, %al
movb %al, 0x24(%r12)
movb 0xf(%rsp), %al
movb %al, 0x23(%r12)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2ea07e
movq %rax, 0x30(%r12)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0x2ea07e
movq %rax, 0x28(%r12)
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq