// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: generateOutputSubroutine
static int generateOutputSubroutine(
  Parse *pParse,          /* Parsing context */
  Select *p,              /* The SELECT statement */
  SelectDest *pIn,        /* Coroutine supplying data */
  SelectDest *pDest,      /* Where to send the data */
  int regReturn,          /* The return address register */
  int regPrev,            /* Previous result register.  No uniqueness if 0 */
  KeyInfo *pKeyInfo,      /* For comparing with previous entry */
  int iBreak              /* Jump here if we hit the LIMIT */
){
  Vdbe *v = pParse->pVdbe;
  int iContinue;
  int addr;

  addr = sqlite3VdbeCurrentAddr(v);
  iContinue = sqlite3VdbeMakeLabel(v);

  /* Suppress duplicates for UNION, EXCEPT, and INTERSECT 
  */
  if( regPrev ){
    int addr1, addr2;
    addr1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); VdbeCoverage(v);
    addr2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,
                              (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);
    sqlite3VdbeAddOp3(v, OP_Jump, addr2+2, iContinue, addr2+2); VdbeCoverage(v);
    sqlite3VdbeJumpHere(v, addr1);
    sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);
    sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);
  }
  if( pParse->db->mallocFailed ) return 0;

  /* Suppress the first OFFSET entries if there is an OFFSET clause
  */
  codeOffset(v, p->iOffset, iContinue);

  assert( pDest->eDest!=SRT_Exists );
  assert( pDest->eDest!=SRT_Table );
  switch( pDest->eDest ){
    /* Store the result as data using a unique key.
    */
    case SRT_EphemTab: {
      int r1 = sqlite3GetTempReg(pParse);
      int r2 = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);
      sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);
      sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);
      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
      sqlite3ReleaseTempReg(pParse, r2);
      sqlite3ReleaseTempReg(pParse, r1);
      break;
    }

#ifndef SQLITE_OMIT_SUBQUERY
    /* If we are creating a set for an "expr IN (SELECT ...)" construct,
    ** then there should be a single item on the stack.  Write this
    ** item into the set table with bogus data.
    */
    case SRT_Set: {
      int r1;
      assert( pIn->nSdst==1 || pParse->nErr>0 );
      pDest->affSdst = 
         sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
      r1 = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
      sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
      sqlite3ReleaseTempReg(pParse, r1);
      break;
    }

    /* If this is a scalar select that is part of an expression, then
    ** store the results in the appropriate memory cell and break out
    ** of the scan loop.
    */
    case SRT_Mem: {
      assert( pIn->nSdst==1 || pParse->nErr>0 );  testcase( pIn->nSdst!=1 );
      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
      /* The LIMIT clause will jump out of the loop for us */
      break;
    }
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */

    /* The results are stored in a sequence of registers
    ** starting at pDest->iSdst.  Then the co-routine yields.
    */
    case SRT_Coroutine: {
      if( pDest->iSdst==0 ){
        pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);
        pDest->nSdst = pIn->nSdst;
      }
      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst);
      sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
      break;
    }

    /* If none of the above, then the result destination must be
    ** SRT_Output.  This routine is never called with any other
    ** destination other than the ones handled above or SRT_Output.
    **
    ** For SRT_Output, results are stored in a sequence of registers.  
    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to
    ** return the next row of result.
    */
    default: {
      assert( pDest->eDest==SRT_Output );
      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);
      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
      break;
    }
  }

  /* Jump to the end of the loop if the LIMIT is reached.
  */
  if( p->iLimit ){
    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
  }

  /* Generate the subroutine return
  */
  sqlite3VdbeResolveLabel(v, iContinue);
  sqlite3VdbeAddOp1(v, OP_Return, regReturn);

  return addr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x6c2b0
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x6e5a0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x82927
movq -0x38(%rbp), %rdi
movl -0x30(%rbp), %edx
movl $0x2f, %esi
callq 0x6e570
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x58(%rbp)
movq 0x10(%rbp), %rdi
callq 0x7b560
movq -0x68(%rbp), %rdi
movl -0x60(%rbp), %edx
movl -0x5c(%rbp), %ecx
movl -0x58(%rbp), %r8d
movq %rax, %r9
movl $0x2b, %esi
movl $0xfffffffa, (%rsp)     # imm = 0xFFFFFFFA
callq 0x6be70
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movl -0x48(%rbp), %edx
addl $0x2, %edx
movl -0x3c(%rbp), %ecx
movl -0x48(%rbp), %r8d
addl $0x2, %r8d
movl $0x2c, %esi
callq 0x56c10
movq -0x38(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x6be30
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
movl 0xc(%rax), %r8d
subl $0x1, %r8d
movl $0x1f, %esi
callq 0x56c10
movq -0x38(%rbp), %rdi
movl -0x30(%rbp), %ecx
movl $0x17, %esi
movl $0x1, %edx
callq 0x6c310
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpb $0x0, 0x51(%rax)
je 0x82940
movl $0x0, -0x4(%rbp)
jmp 0x82bb1
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %esi
movl -0x3c(%rbp), %edx
callq 0x827c0
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
addl $-0xa, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x3, %eax
ja 0x82b39
movq -0x70(%rbp), %rax
leaq 0x1ff1d(%rip), %rcx     # 0xa2894
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0x6f960
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6f960
movl %eax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
movl -0x4c(%rbp), %r8d
movl $0x32, %esi
callq 0x56c10
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x50(%rbp), %ecx
movl $0x54, %esi
callq 0x6c310
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x4c(%rbp), %ecx
movl -0x50(%rbp), %r8d
movl $0x5f, %esi
callq 0x56c10
movq -0x38(%rbp), %rdi
movl $0x8, %esi
callq 0x17b70
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x6f9b0
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x6f9b0
jmp 0x82b6c
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x72390
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x10(%rbp), %rdi
callq 0x6f960
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
movl -0x54(%rbp), %r8d
movq -0x28(%rbp), %r9
addq $0x1, %r9
movl $0x32, %esi
movl $0x1, %ecx
movl $0x1, (%rsp)
callq 0x6be70
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x1, %edx
callq 0x6e330
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %edx
movl -0x54(%rbp), %ecx
movl $0x70, %esi
callq 0x6c310
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x6f9b0
jmp 0x82b6c
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %edx
movl $0x1, %ecx
callq 0x80040
jmp 0x82b6c
movq -0x28(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x82b04
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x6ea60
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
callq 0x80040
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %edx
movl $0x14, %esi
callq 0x6e570
jmp 0x82b6c
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
movl $0x22, %esi
callq 0x6c310
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x20(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x6e330
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x82b8e
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0xc(%rax), %edx
movl 0x18(%rbp), %ecx
movl $0x8e, %esi
callq 0x6c310
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x6e780
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl $0x10, %esi
callq 0x6e570
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)