// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/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;
  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_ALL, 0));
  p->op = TK_SELECT;
  p->pWhere = 0;
  pNew->pGroupBy = 0;
  pNew->pHaving = 0;
  pNew->pOrderBy = 0;
  p->pPrior = 0;
  pNew->pLimit = 0;
  pNew->pOffset = 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 0x62eda
movl $0x0, -0x4(%rbp)
jmp 0x63105
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x62ef1
movl $0x0, -0x4(%rbp)
jmp 0x63105
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x61(%rbp)
je 0x62f2e
movq -0x30(%rbp), %rax
movzbl 0x8(%rax), %ecx
movb $0x1, %al
cmpl $0x71, %ecx
movb %al, -0x62(%rbp)
je 0x62f28
movq -0x30(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x74, %eax
sete %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x62f37
jmp 0x62f47
jmp 0x62f39
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x62ef9
cmpq $0x0, -0x30(%rbp)
jne 0x62f5a
movl $0x0, -0x4(%rbp)
jmp 0x63105
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x62faf
movq -0x40(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movzwl 0x2(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x62fa2
jmp 0x62faf
jmp 0x62fa4
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x62f7a
cmpl $0x0, -0x1c(%rbp)
jge 0x62fc1
movl $0x0, -0x4(%rbp)
jmp 0x63105
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl $0x78, %esi
callq 0x11ca0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x62ffd
movl $0x2, -0x4(%rbp)
jmp 0x63105
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x8200
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 0x54980
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x63050
movl $0x2, -0x4(%rbp)
jmp 0x63105
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x78, %edx
callq 0x82f0
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 $0x71, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x548b0
movq -0x70(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x54650
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movb $0x74, 0x8(%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 -0x28(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x70(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)