// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: pushOntoSorter
static void pushOntoSorter(
  Parse *pParse,         /* Parser context */
  SortCtx *pSort,        /* Information about the ORDER BY clause */
  Select *pSelect,       /* The whole SELECT statement */
  int regData,           /* First register holding data to be sorted */
  int regOrigData,       /* First register holding data before packing */
  int nData,             /* Number of elements in the data array */
  int nPrefixReg         /* No. of reg prior to regData available for use */
){
  Vdbe *v = pParse->pVdbe;                         /* Stmt under construction */
  int bSeq = ((pSort->sortFlags & SORTFLAG_UseSorter)==0);
  int nExpr = pSort->pOrderBy->nExpr;              /* No. of ORDER BY terms */
  int nBase = nExpr + bSeq + nData;                /* Fields in sorter record */
  int regBase;                                     /* Regs for sorter record */
  int regRecord = ++pParse->nMem;                  /* Assembled sorter record */
  int nOBSat = pSort->nOBSat;                      /* ORDER BY terms to skip */
  int op;                            /* Opcode to add sorter record to sorter */
  int iLimit;                        /* LIMIT counter */

  assert( bSeq==0 || bSeq==1 );
  assert( nData==1 || regData==regOrigData );
  if( nPrefixReg ){
    assert( nPrefixReg==nExpr+bSeq );
    regBase = regData - nExpr - bSeq;
  }else{
    regBase = pParse->nMem + 1;
    pParse->nMem += nBase;
  }
  assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );
  iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;
  pSort->labelDone = sqlite3VdbeMakeLabel(v);
  sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,
                          SQLITE_ECEL_DUP|SQLITE_ECEL_REF);
  if( bSeq ){
    sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr);
  }
  if( nPrefixReg==0 ){
    sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData);
  }
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord);
  if( nOBSat>0 ){
    int regPrevKey;   /* The first nOBSat columns of the previous row */
    int addrFirst;    /* Address of the OP_IfNot opcode */
    int addrJmp;      /* Address of the OP_Jump opcode */
    VdbeOp *pOp;      /* Opcode that opens the sorter */
    int nKey;         /* Number of sorting key columns, including OP_Sequence */
    KeyInfo *pKI;     /* Original KeyInfo on the sorter table */

    regPrevKey = pParse->nMem+1;
    pParse->nMem += pSort->nOBSat;
    nKey = nExpr - pSort->nOBSat + bSeq;
    if( bSeq ){
      addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); 
    }else{
      addrFirst = sqlite3VdbeAddOp1(v, OP_SequenceTest, pSort->iECursor);
    }
    VdbeCoverage(v);
    sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);
    pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
    if( pParse->db->mallocFailed ) return;
    pOp->p2 = nKey + nData;
    pKI = pOp->p4.pKeyInfo;
    memset(pKI->aSortOrder, 0, pKI->nField); /* Makes OP_Jump below testable */
    sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
    testcase( pKI->nXField>2 );
    pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,
                                           pKI->nXField-1);
    addrJmp = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
    pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
    pSort->regReturn = ++pParse->nMem;
    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
    sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);
    if( iLimit ){
      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, pSort->labelDone);
      VdbeCoverage(v);
    }
    sqlite3VdbeJumpHere(v, addrFirst);
    sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat);
    sqlite3VdbeJumpHere(v, addrJmp);
  }
  if( pSort->sortFlags & SORTFLAG_UseSorter ){
    op = OP_SorterInsert;
  }else{
    op = OP_IdxInsert;
  }
  sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
  if( iLimit ){
    int addr;
    addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v);
    sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
    sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
    sqlite3VdbeJumpHere(v, addr);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
addl -0x34(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rcx
movl 0x54(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x54(%rcx)
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x8ef20
movl -0x1c(%rbp), %eax
subl -0x38(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x8ef3a
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x54(%rax), %ecx
movl %ecx, 0x54(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x8ef53
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x8ef5d
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
callq 0x6e5a0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl -0x40(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0x5, %r8d
callq 0x6ead0
cmpl $0x0, -0x34(%rbp)
je 0x8efb2
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl -0x40(%rbp), %ecx
addl -0x38(%rbp), %ecx
movl $0x4b, %esi
callq 0x6c310
cmpl $0x0, 0x10(%rbp)
jne 0x8efd0
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x40(%rbp), %edx
addl -0x38(%rbp), %edx
addl -0x34(%rbp), %edx
movl -0x24(%rbp), %ecx
callq 0x80040
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %edx
addl -0x48(%rbp), %edx
movl -0x3c(%rbp), %ecx
subl -0x48(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl $0x32, %esi
callq 0x56c10
cmpl $0x0, -0x48(%rbp)
jle 0x8f1de
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
addl 0x54(%rax), %ecx
movl %ecx, 0x54(%rax)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
subl 0x8(%rcx), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x8f045
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %edx
addl -0x38(%rbp), %edx
movl $0x2f, %esi
callq 0x6e570
movl %eax, -0x58(%rbp)
jmp 0x8f05d
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl $0x3c, %esi
callq 0x6e570
movl %eax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movl -0x54(%rbp), %edx
movl -0x40(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r8d
movl $0x2b, %esi
callq 0x56c10
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x56e10
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpb $0x0, 0x51(%rax)
je 0x8f09f
jmp 0x8f26c
movl -0x6c(%rbp), %ecx
addl -0x24(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x78(%rbp), %rax
movzwl 0x6(%rax), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0xb2b0
movq -0x30(%rbp), %rdi
movq -0x78(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffa, %ecx       # imm = 0xFFFFFFFA
callq 0x17dd0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl -0x48(%rbp), %edx
movq -0x78(%rbp), %rax
movzwl 0x8(%rax), %ecx
subl $0x1, %ecx
callq 0x7dd10
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
callq 0x6c2b0
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x5c(%rbp), %edx
addl $0x1, %edx
movl -0x5c(%rbp), %r8d
addl $0x1, %r8d
movl $0x2c, %esi
xorl %ecx, %ecx
callq 0x56c10
movq -0x30(%rbp), %rdi
callq 0x6e5a0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
movl 0x54(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x54(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movl $0xf, %esi
callq 0x6c310
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl $0x79, %esi
callq 0x6e570
cmpl $0x0, -0x50(%rbp)
je 0x8f1b0
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movl $0x2f, %esi
callq 0x6c310
movq -0x30(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x6be30
movq -0x8(%rbp), %rdi
movl -0x40(%rbp), %esi
movl -0x54(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
callq 0x80040
movq -0x30(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x6be30
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8f1f7
movl $0x6f, -0x4c(%rbp)
jmp 0x8f1fe
movl $0x70, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl -0x44(%rbp), %ecx
callq 0x6c310
cmpl $0x0, -0x50(%rbp)
je 0x8f26c
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl $0x8d, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x56c10
movl %eax, -0x7c(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl $0x6b, %esi
callq 0x6e570
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
movl $0x63, %esi
callq 0x6e570
movq -0x30(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x6be30
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)