// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x438f4a
movl $0x0, -0x4(%rbp)
jmp 0x4391d5
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x438f61
movl $0x0, -0x4(%rbp)
jmp 0x4391d5
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x61(%rbp)
je 0x438fa1
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
movb $0x1, %al
cmpl $0x85, %ecx
movb %al, -0x62(%rbp)
je 0x438f9b
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x88, %eax
sete %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x438faa
jmp 0x438fba
jmp 0x438fac
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x438f69
cmpq $0x0, -0x30(%rbp)
jne 0x438fcd
movl $0x0, -0x4(%rbp)
jmp 0x4391d5
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpw $0x0, 0x14(%rax)
je 0x438ff4
movl $0x0, -0x4(%rbp)
jmp 0x4391d5
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x439038
movq -0x40(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x43902b
jmp 0x439038
jmp 0x43902d
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x439004
cmpl $0x0, -0x1c(%rbp)
jge 0x43904a
movl $0x0, -0x4(%rbp)
jmp 0x4391d5
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl $0x80, %esi
callq 0x3c9520
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x439085
movl $0x2, -0x4(%rbp)
jmp 0x4391d5
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x19360
movq -0x50(%rbp), %rdi
movq -0x28(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
leaq -0x60(%rbp), %r8
movq %rcx, %rsi
movq %rcx, %rdx
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x41d020
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x4390d8
movl $0x2, -0x4(%rbp)
jmp 0x4391d5
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x80, %edx
callq 0x19610
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rdi
movl $0xb1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x41d620
movq -0x70(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x41d3c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movb $-0x78, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x78(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x10000, %ecx          # imm = 0x10000
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x58(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x60(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)