// File: /workspace/github_c_makefile_star2_O1/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: resolveCompoundOrderBy
static int resolveCompoundOrderBy(
  Parse *pParse,        /* Parsing context.  Leave error messages here */
  Select *pSelect       /* The SELECT statement containing the ORDER BY */
){
  int i;
  ExprList *pOrderBy;
  ExprList *pEList;
  sqlite3 *db;
  int moreToDo = 1;

  pOrderBy = pSelect->pOrderBy;
  if( pOrderBy==0 ) return 0;
  db = pParse->db;
#if SQLITE_MAX_COLUMN
  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
    sqlite3ErrorMsg(pParse, "too many terms in ORDER BY clause");
    return 1;
  }
#endif
  for(i=0; i<pOrderBy->nExpr; i++){
    pOrderBy->a[i].done = 0;
  }
  pSelect->pNext = 0;
  while( pSelect->pPrior ){
    pSelect->pPrior->pNext = pSelect;
    pSelect = pSelect->pPrior;
  }
  while( pSelect && moreToDo ){
    struct ExprList_item *pItem;
    moreToDo = 0;
    pEList = pSelect->pEList;
    assert( pEList!=0 );
    for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
      int iCol = -1;
      Expr *pE, *pDup;
      if( pItem->done ) continue;
      pE = sqlite3ExprSkipCollate(pItem->pExpr);
      if( sqlite3ExprIsInteger(pE, &iCol) ){
        if( iCol<=0 || iCol>pEList->nExpr ){
          resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
          return 1;
        }
      }else{
        iCol = resolveAsName(pParse, pEList, pE);
        if( iCol==0 ){
          pDup = sqlite3ExprDup(db, pE, 0);
          if( !db->mallocFailed ){
            assert(pDup);
            iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);
          }
          sqlite3ExprDelete(db, pDup);
        }
      }
      if( iCol>0 ){
        /* Convert the ORDER BY term into an integer column number iCol,
        ** taking care to preserve the COLLATE clause if it exists */
        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
        if( pNew==0 ) return 1;
        pNew->flags |= EP_IntValue;
        pNew->u.iValue = iCol;
        if( pItem->pExpr==pE ){
          pItem->pExpr = pNew;
        }else{
          Expr *pParent = pItem->pExpr;
          assert( pParent->op==TK_COLLATE );
          while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
          assert( pParent->pLeft==pE );
          pParent->pLeft = pNew;
        }
        sqlite3ExprDelete(db, pE);
        pItem->u.x.iOrderByCol = (u16)iCol;
        pItem->done = 1;
      }else{
        moreToDo = 1;
      }
    }
    pSelect = pSelect->pNext;
  }
  for(i=0; i<pOrderBy->nExpr; i++){
    if( pOrderBy->a[i].done==0 ){
      sqlite3ErrorMsg(pParse, "%r ORDER BY term does not match any "
            "column in the result set", i+1);
      return 1;
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq 0x48(%rsi), %r15
testq %r15, %r15
je 0x58c44
movq (%rdi), %rcx
movl (%r15), %eax
movq %rcx, -0x40(%rbp)
cmpl 0x70(%rcx), %eax
jle 0x588e7
leaq 0x269ed(%rip), %rsi     # 0x7f2c8
xorl %eax, %eax
callq 0x14804
jmp 0x58c5a
movq %rdi, -0x58(%rbp)
cmpl $0x0, (%r15)
jle 0x5890f
movl $0x19, %eax
xorl %ecx, %ecx
movq 0x8(%r15), %rdx
andb $-0x2, (%rdx,%rax)
incq %rcx
movslq (%r15), %rdx
addq $0x20, %rax
cmpq %rdx, %rcx
jl 0x588f8
movq $0x0, 0x58(%rsi)
movq 0x50(%rsi), %rax
testq %rax, %rax
je 0x58935
movq %rax, %rcx
movq %rsi, 0x58(%rax)
movq 0x50(%rax), %rax
movq %rcx, %rsi
testq %rax, %rax
jne 0x58920
jmp 0x58938
movq %rsi, %rcx
movl $0x1, %eax
movq %r15, -0x60(%rbp)
testq %rcx, %rcx
je 0x58c1b
testl %eax, %eax
je 0x58c1b
cmpl $0x0, (%r15)
movq %rcx, -0x50(%rbp)
jle 0x58bf7
movq (%rcx), %rax
movq %rax, -0x68(%rbp)
movq 0x8(%r15), %r13
xorl %r14d, %r14d
movl $0x0, -0x30(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
testb $0x1, 0x19(%r13)
jne 0x589b2
movq (%r13), %r12
testq %r12, %r12
je 0x589be
movl 0x4(%r12), %eax
btl $0xc, %eax
jae 0x589be
btl $0x12, %eax
jb 0x589a3
addq $0x10, %r12
jmp 0x589ac
movq 0x20(%r12), %rax
movq 0x8(%rax), %r12
movq (%r12), %r12
jmp 0x58987
movl $0xb, %eax
xorl %ebx, %ebx
jmp 0x58b77
movq %r12, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x55469
testl %eax, %eax
je 0x58a11
movl -0x2c(%rbp), %eax
testl %eax, %eax
jle 0x589e1
movq -0x68(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x58adc
leal 0x1(%r14), %edx
movq -0x68(%rbp), %rax
movl (%rax), %r8d
xorl %ebx, %ebx
movq -0x58(%rbp), %rdi
leaq 0x267d7(%rip), %rsi     # 0x7f1d0
leaq 0x26568(%rip), %rcx     # 0x7ef68
xorl %eax, %eax
callq 0x14804
movl $0x1, %eax
jmp 0x58b77
movq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0x5ad0d
movl %eax, -0x2c(%rbp)
testl %eax, %eax
jne 0x58adc
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x54a6f
movq %rax, %rsi
cmpb $0x0, 0x51(%rbx)
jne 0x58ad4
movq -0x50(%rbp), %rax
movq (%rax), %rdx
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x58(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0xa8(%rbp)
movq %rdx, -0x48(%rbp)
movq %rdx, -0xa0(%rbp)
movw $0x1, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movq (%rcx), %rbx
movb 0x54(%rbx), %r15b
movb $0x1, 0x54(%rbx)
leaq -0xb0(%rbp), %rdi
movq %rsi, -0x38(%rbp)
callq 0x56cd9
movb %r15b, 0x54(%rbx)
xorl %ebx, %ebx
testl %eax, %eax
je 0x58b96
movq -0x38(%rbp), %rsi
movl %ebx, -0x2c(%rbp)
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x3d8f7
movl -0x2c(%rbp), %r15d
movb $0x1, %bl
testl %r15d, %r15d
jle 0x58b61
movq $0x0, -0xb0(%rbp)
movl $0x0, -0xa8(%rbp)
movq -0x40(%rbp), %rdi
movl $0x84, %esi
leaq -0xb0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x56afe
testq %rax, %rax
je 0x58b6c
orb $0x4, 0x5(%rax)
movl %r15d, 0x8(%rax)
movq (%r13), %rdx
movq %r13, %rcx
cmpq %r12, %rdx
movq -0x60(%rbp), %r15
je 0x58b40
movq %rdx, %rcx
movq 0x10(%rdx), %rdx
cmpb $0x5f, (%rdx)
je 0x58b30
addq $0x10, %rcx
movq %rax, (%rcx)
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x3d8f7
movzwl -0x2c(%rbp), %eax
movw %ax, 0x1c(%r13)
orb $0x1, 0x19(%r13)
xorl %eax, %eax
jmp 0x58b77
xorl %eax, %eax
movl $0x1, -0x30(%rbp)
jmp 0x58b73
movl $0x1, %eax
xorl %ebx, %ebx
movq -0x60(%rbp), %r15
cmpl $0xb, %eax
je 0x58b84
testl %eax, %eax
jne 0x58c0a
incl %r14d
addq $0x20, %r13
cmpl (%r15), %r14d
jl 0x58975
jmp 0x58bfe
movq -0x48(%rbp), %rcx
movslq (%rcx), %rax
testq %rax, %rax
jle 0x58ac9
movq 0x8(%rcx), %rcx
movq %rcx, -0x48(%rbp)
shlq $0x5, %rax
movl $0x1, %ebx
xorl %r15d, %r15d
movq -0x38(%rbp), %rsi
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq (%rax,%r15), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x544b5
cmpl $0x2, %eax
jb 0x58ac9
incl %ebx
addq $0x20, %r15
movq -0x70(%rbp), %rax
cmpq %r15, %rax
movq -0x38(%rbp), %rsi
jne 0x58bc2
xorl %ebx, %ebx
jmp 0x58acd
movl $0x0, -0x30(%rbp)
movq -0x50(%rbp), %rcx
movq 0x58(%rcx), %rcx
movb $0x1, %bl
jmp 0x58c0e
movq -0x50(%rbp), %rcx
testb %bl, %bl
movl -0x30(%rbp), %eax
jne 0x58941
jmp 0x58c5a
movslq (%r15), %rax
testq %rax, %rax
jle 0x58c44
movq 0x8(%r15), %rcx
shlq $0x5, %rax
movl $0x1, %edx
xorl %esi, %esi
testb $0x1, 0x19(%rcx,%rsi)
je 0x58c48
incl %edx
addq $0x20, %rsi
cmpq %rsi, %rax
jne 0x58c32
xorl %eax, %eax
jmp 0x58c5f
leaq 0x2669b(%rip), %rsi     # 0x7f2ea
movq -0x58(%rbp), %rdi
xorl %eax, %eax
callq 0x14804
movl $0x1, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq