// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: convertCompoundSelectToSubquery
static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){
  int i;
  Select *pNew;
  Select *pX;
  sqlite3 *db;
  struct ExprList_item *a;
  SrcList *pNewSrc;
  Parse *pParse;
  Token dummy;

  if( p->pPrior==0 ) return WRC_Continue;
  if( p->pOrderBy==0 ) return WRC_Continue;
  for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){}
  if( pX==0 ) return WRC_Continue;
  a = p->pOrderBy->a;
#ifndef SQLITE_OMIT_WINDOWFUNC
  /* If iOrderByCol is already non-zero, then it has already been matched
  ** to a result column of the SELECT statement. This occurs when the
  ** SELECT is rewritten for window-functions processing and then passed
  ** to sqlite3SelectPrep() and similar a second time. The rewriting done
  ** by this function is not required in this case. */
  if( a[0].u.x.iOrderByCol ) return WRC_Continue;
#endif
  for(i=p->pOrderBy->nExpr-1; i>=0; i--){
    if( a[i].pExpr->flags & EP_Collate ) break;
  }
  if( i<0 ) return WRC_Continue;

  /* If we reach this point, that means the transformation is required. */

  pParse = pWalker->pParse;
  db = pParse->db;
  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
  if( pNew==0 ) return WRC_Abort;
  memset(&dummy, 0, sizeof(dummy));
  pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0);
  if( pNewSrc==0 ) return WRC_Abort;
  *pNew = *p;
  p->pSrc = pNewSrc;
  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0));
  p->op = TK_SELECT;
  p->pWhere = 0;
  pNew->pGroupBy = 0;
  pNew->pHaving = 0;
  pNew->pOrderBy = 0;
  p->pPrior = 0;
  p->pNext = 0;
  p->pWith = 0;
#ifndef SQLITE_OMIT_WINDOWFUNC
  p->pWinDefn = 0;
#endif
  p->selFlags &= ~SF_Compound;
  assert( (p->selFlags & SF_Converted)==0 );
  p->selFlags |= SF_Converted;
  assert( pNew->pPrior!=0 );
  pNew->pPrior->pNext = pNew;
  pNew->pLimit = 0;
  return WRC_Continue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
xorl %ebp, %ebp
cmpq $0x0, 0x50(%rsi)
je 0x2c761c
movq %rsi, %rbx
movq 0x48(%rsi), %rax
testq %rax, %rax
je 0x2c761c
leaq 0x50(%rbx), %r13
movq %rbx, %rcx
movzbl (%rcx), %edx
cmpl $0x88, %edx
je 0x2c760a
cmpl $0x85, %edx
jne 0x2c7615
movq 0x50(%rcx), %rcx
testq %rcx, %rcx
jne 0x2c75f7
jmp 0x2c761c
cmpw $0x0, 0x1c(%rax)
je 0x2c762d
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rax), %edx
leal 0x1(%rdx), %ecx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rax
addq $-0x10, %rax
decl %ecx
testl %ecx, %ecx
jle 0x2c761c
movq (%rax), %rdx
addq $-0x18, %rax
testb $0x1, 0x5(%rdx)
je 0x2c763e
movq (%rdi), %r15
movq (%r15), %r12
movl $0x80, %esi
movq %r12, %rdi
callq 0x279b27
movl $0x2, %ebp
testq %rax, %rax
je 0x2c761c
movq %rax, %r14
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r8
movaps %xmm0, (%r8)
movups %xmm0, (%rsp)
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rax, %r9
callq 0x2b1798
testq %rax, %rax
je 0x2c761c
movl $0x10, %ecx
movq %r14, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, 0x28(%rbx)
leaq 0x28(%rsp), %rdx
xorl %ebp, %ebp
movq %rbp, (%rdx)
movl $0x0, 0x8(%rdx)
movq %r12, %rdi
movl $0xb1, %esi
xorl %ecx, %ecx
callq 0x2b1c27
movq (%r15), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2b1a3f
movq %rax, 0x20(%rbx)
movb $-0x78, (%rbx)
movq %rbp, 0x30(%rbx)
movq %rbp, 0x48(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r14)
movq %rbp, 0x68(%rbx)
movq %rbp, 0x78(%rbx)
movups %xmm0, (%r13)
movl $0xfffefeff, %eax       # imm = 0xFFFEFEFF
andl 0x4(%rbx), %eax
orl $0x10000, %eax          # imm = 0x10000
movl %eax, 0x4(%rbx)
movq 0x50(%r14), %rax
movq %r14, 0x58(%rax)
movq %rbp, 0x60(%r14)
xorl %ebp, %ebp
jmp 0x2c761c