// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
xorl %ebp, %ebp
cmpq $0x0, 0x50(%rsi)
je 0x26d6a4
movq %rsi, %rbx
movq 0x48(%rsi), %rax
testq %rax, %rax
je 0x26d6a4
leaq 0x50(%rbx), %r13
movq %rbx, %rcx
testq %rcx, %rcx
je 0x26d6a4
movzbl (%rcx), %edx
cmpl $0x88, %edx
je 0x26d697
cmpl $0x85, %edx
jne 0x26d69d
movq 0x50(%rcx), %rcx
jmp 0x26d67f
cmpw $0x0, 0x1c(%rax)
je 0x26d6b5
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rax), %edx
leal 0x1(%rdx), %ecx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
addq $-0x10, %rax
decl %ecx
testl %ecx, %ecx
jle 0x26d6a4
movq (%rax), %rdx
addq $-0x18, %rax
testb $0x1, 0x5(%rdx)
je 0x26d6c5
movq (%rdi), %r15
movq (%r15), %r12
movl $0x80, %esi
movq %r12, %rdi
callq 0x2258ed
pushq $0x2
popq %rbp
testq %rax, %rax
je 0x26d6a4
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 0x25ba2e
testq %rax, %rax
je 0x26d6a4
pushq $0x10
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, 0x28(%rbx)
movq %r12, %rdi
movl $0xb1, %esi
xorl %edx, %edx
callq 0x25bd93
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x25bc95
movq %rax, 0x20(%rbx)
movb $-0x78, (%rbx)
andq $0x0, 0x30(%rbx)
andq $0x0, 0x48(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r14)
andq $0x0, 0x68(%rbx)
andq $0x0, 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)
andq $0x0, 0x60(%r14)
xorl %ebp, %ebp
jmp 0x26d6a4