// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pushOntoSorter
static void pushOntoSorter(
  Parse *pParse,         /* Parser context */
  ExprList *pOrderBy,    /* The ORDER BY clause */
  Select *pSelect,       /* The whole SELECT statement */
  int regData            /* Register holding data to be sorted */
){
  Vdbe *v = pParse->pVdbe;
  int nExpr = pOrderBy->nExpr;
  int regBase = sqlite3GetTempRange(pParse, nExpr+2);
  int regRecord = sqlite3GetTempReg(pParse);
  int op;
  sqlite3ExprCacheClear(pParse);
  sqlite3ExprCodeExprList(pParse, pOrderBy, regBase, 0);
  sqlite3VdbeAddOp2(v, OP_Sequence, pOrderBy->iECursor, regBase+nExpr);
  sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+1, 1);
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nExpr + 2, regRecord);
  if( pSelect->selFlags & SF_UseSorter ){
    op = OP_SorterInsert;
  }else{
    op = OP_IdxInsert;
  }
  sqlite3VdbeAddOp2(v, op, pOrderBy->iECursor, regRecord);
  sqlite3ReleaseTempReg(pParse, regRecord);
  sqlite3ReleaseTempRange(pParse, regBase, nExpr+2);
  if( pSelect->iLimit ){
    int addr1, addr2;
    int iLimit;
    if( pSelect->iOffset ){
      iLimit = pSelect->iOffset+1;
    }else{
      iLimit = pSelect->iLimit;
    }
    addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit);
    sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1);
    addr2 = sqlite3VdbeAddOp0(v, OP_Goto);
    sqlite3VdbeJumpHere(v, addr1);
    sqlite3VdbeAddOp1(v, OP_Last, pOrderBy->iECursor);
    sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy->iECursor);
    sqlite3VdbeJumpHere(v, addr2);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
addl $0x2, %esi
callq 0x67c30
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x66a70
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6f480
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x30(%rbp), %edx
xorl %ecx, %ecx
callq 0x69d90
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x30(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movl $0x40, %esi
callq 0x5e0c0
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x30(%rbp), %edx
addl -0x2c(%rbp), %edx
addl $0x1, %edx
movl $0x1, %ecx
callq 0x6f4f0
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movl -0x34(%rbp), %r8d
movl $0x2b, %esi
callq 0x5e0f0
movq -0x18(%rbp), %rax
movzwl 0xa(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x7bcde
movl $0x66, -0x38(%rbp)
jmp 0x7bce5
movl $0x67, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movl -0x38(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x34(%rbp), %ecx
callq 0x5e0c0
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x66ac0
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
movl -0x2c(%rbp), %edx
addl $0x2, %edx
callq 0x67e90
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x7bdc7
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x7bd40
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7bd4a
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %edx
movl $0x80, %esi
callq 0x5ecf0
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %edx
movl $0x20, %esi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x5e0c0
movq -0x28(%rbp), %rdi
movl $0xe, %esi
callq 0x5e060
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x5e090
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movl $0x62, %esi
callq 0x5ecf0
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movl $0x46, %esi
callq 0x5ecf0
movq -0x28(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x5e090
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)