// File: /workspace/github_c_makefile_star2_O0/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
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x771f9
movl $0x0, -0x4(%rbp)
jmp 0x77532
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movq -0x38(%rbp), %rcx
cmpl 0x70(%rcx), %eax
jle 0x77231
movq -0x10(%rbp), %rdi
leaq 0x309f8(%rip), %rsi     # 0xa7c16
movb $0x0, %al
callq 0x17840
movl $0x1, -0x4(%rbp)
jmp 0x77532
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x7726d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movb 0x19(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x19(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x77238
movq -0x18(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x772a2
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x58(%rax)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x77279
jmp 0x772a4
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x71(%rbp)
je 0x772ba
cmpl $0x0, -0x3c(%rbp)
setne %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x772c6
jmp 0x774cb
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x774ba
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rax
movb 0x19(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x77317
jmp 0x774a0
movq -0x48(%rbp), %rax
movq (%rax), %rdi
callq 0x70830
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x72570
cmpl $0x0, %eax
je 0x77374
cmpl $0x0, -0x4c(%rbp)
jle 0x7734a
movl -0x4c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x77372
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %edx
addl $0x1, %edx
movq -0x30(%rbp), %rax
movl (%rax), %ecx
leaq 0x30555(%rip), %rsi     # 0xa78b6
callq 0x7a5a0
movl $0x1, -0x4(%rbp)
jmp 0x77532
jmp 0x773ce
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x7a500
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x773cc
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rsi
xorl %edx, %edx
callq 0x713e0
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, 0x51(%rax)
jne 0x773bf
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x7a770
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x536c0
jmp 0x773ce
cmpl $0x0, -0x4c(%rbp)
jle 0x77497
movq -0x38(%rbp), %rdi
movl $0x84, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x61600
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x77401
movl $0x1, -0x4(%rbp)
jmp 0x77532
movq -0x68(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x4(%rax)
movl -0x4c(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq (%rax), %rax
cmpq -0x58(%rbp), %rax
jne 0x77435
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
jmp 0x7746a
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x7745e
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x77440
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x536c0
movl -0x4c(%rbp), %eax
movw %ax, %cx
movq -0x48(%rbp), %rax
movw %cx, 0x1c(%rax)
movq -0x48(%rbp), %rax
movb 0x19(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x19(%rax)
jmp 0x7749e
movl $0x1, -0x3c(%rbp)
jmp 0x774a0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x48(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x48(%rbp)
jmp 0x772eb
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x772a4
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x7752b
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movb 0x19(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x7751e
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %edx
addl $0x1, %edx
leaq 0x3072a(%rip), %rsi     # 0xa7c38
movb $0x0, %al
callq 0x17840
movl $0x1, -0x4(%rbp)
jmp 0x77532
jmp 0x77520
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x774d2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nop