// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %ebx
movl %r8d, %r13d
movq %rcx, -0x60(%rbp)
movq %rdx, -0x38(%rbp)
movq %rsi, %r15
movq %rdi, -0x50(%rbp)
movq 0x10(%rdi), %r14
movl 0x3c(%r14), %r12d
movq %r14, %rdi
callq 0x528c8
movl %eax, -0x44(%rbp)
testl %ebx, %ebx
movl %r13d, -0x30(%rbp)
movl %r12d, -0x2c(%rbp)
je 0x61edf
movq %r15, -0x40(%rbp)
movq 0x10(%rbp), %r12
movq %r14, %rdi
movl $0x2f, %esi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %eax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %edx
movl 0xc(%rax), %r8d
leal 0x1(%rbx), %r15d
testq %r12, %r12
je 0x61e2d
incl (%r12)
movq %r14, %rdi
movl $0x2b, %esi
movl %r15d, %ecx
callq 0x3fa9e
movl %eax, %r13d
movq %r14, %rdi
movl %eax, %esi
movq %r12, %rdx
movl $0xfffffffa, %ecx       # imm = 0xFFFFFFFA
callq 0x14ab9
addl $0x2, %r13d
movq %r14, %rdi
movl $0x2c, %esi
movl %r13d, %edx
movl -0x44(%rbp), %ecx
movl %r13d, %r8d
callq 0x3fa9e
movl 0x3c(%r14), %eax
leal -0x1(%rax), %ecx
movq 0x30(%r14), %rdx
movl %ecx, 0x68(%rdx)
movq (%r14), %rdx
cmpb $0x0, 0x51(%rdx)
je 0x61e8c
leaq 0x3365e(%rip), %rcx     # 0x954e8
jmp 0x61ea3
movl -0x58(%rbp), %edx
testl %edx, %edx
cmovnsl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%r14), %rcx
movl %eax, 0x8(%rcx)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %edx
movl 0xc(%rax), %r8d
decl %r8d
movq %r14, %rdi
movl $0x1f, %esi
movl %r15d, %ecx
callq 0x3fa9e
movq %r14, %rdi
movl $0x17, %esi
movl $0x1, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq -0x40(%rbp), %r15
movq -0x50(%rbp), %r12
movq (%r12), %rcx
xorl %eax, %eax
cmpb $0x0, 0x51(%rcx)
jne 0x622e9
movq %r14, %rbx
movq %r15, %r14
movq %r15, %r13
movl 0x10(%r14), %edx
testl %edx, %edx
jle 0x61f1e
movq %rbx, %rdi
movl $0x8b, %esi
movl -0x44(%rbp), %ecx
movl $0x1, %r8d
callq 0x3fa9e
movq -0x50(%rbp), %r12
movq -0x60(%rbp), %r15
movzbl (%r15), %eax
addl $-0xa, %eax
cmpl $0x3, %eax
ja 0x6203a
leaq 0x1834f(%rip), %rcx     # 0x7a288
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r13, -0x40(%rbp)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %r14d
movl 0x4(%r15), %ecx
movq 0x10(%r12), %rdi
movl $0x1e, %esi
movl %r14d, %edx
movl $0x1, %r8d
callq 0x3fa9e
movq %r12, %rdi
movl %r14d, %esi
movq -0x40(%rbp), %r13
movl $0x1, %edx
callq 0x5291f
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %r12d
movq %rbx, %r14
movl %eax, %ebx
jmp 0x6228f
movb 0x1f(%r12), %al
testb %al, %al
movq %rbx, %r14
je 0x62071
decb %al
movb %al, 0x1f(%r12)
movzbl %al, %eax
movl 0x24(%r12,%rax,4), %ebx
jmp 0x6207d
movq %r13, -0x40(%rbp)
cmpl $0x0, 0x8(%r15)
movq -0x38(%rbp), %rdi
movq %rbx, %r14
jne 0x6223f
movl 0xc(%rdi), %eax
movl 0x44(%r12), %edx
subl %eax, %edx
jge 0x62225
movl 0x54(%r12), %edx
leal 0x1(%rdx), %ecx
addl %eax, %edx
movl %edx, 0x54(%r12)
jmp 0x62237
movq %r13, -0x40(%rbp)
movq (%r13), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
leaq 0x1(%r15), %rax
movq %rax, -0x58(%rbp)
movsbl 0x1(%r15), %esi
callq 0x553ef
movq -0x50(%rbp), %r12
movb %al, 0x1(%r15)
movb 0x1f(%r12), %al
testb %al, %al
movq %rbx, %r14
je 0x6216f
decb %al
movb %al, 0x1f(%r12)
movzbl %al, %eax
movl 0x24(%r12,%rax,4), %r15d
jmp 0x6217c
movq -0x38(%rbp), %r13
movl 0x8(%r13), %edx
movl 0xc(%r13), %ecx
movq %rbx, %rdi
movl $0x22, %esi
xorl %r8d, %r8d
callq 0x3fa9e
movl 0x8(%r13), %esi
movl 0xc(%r13), %edx
movq %r14, %r13
movq %rbx, %r14
movq %r12, %rdi
callq 0x5291f
jmp 0x62288
movl 0x54(%r12), %ebx
incl %ebx
movl %ebx, 0x54(%r12)
movb 0x1f(%r12), %al
testb %al, %al
je 0x62097
decb %al
movb %al, 0x1f(%r12)
movzbl %al, %eax
movl 0x24(%r12,%rax,4), %r15d
jmp 0x620a4
movl 0x54(%r12), %r15d
incl %r15d
movl %r15d, 0x54(%r12)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %edx
movl 0xc(%rax), %ecx
movq %r14, %rdi
movl $0x32, %esi
movl %ebx, %r8d
callq 0x3fa9e
movq -0x60(%rbp), %r12
movl 0x4(%r12), %edx
movq %r14, %rdi
movl $0x54, %esi
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl 0x4(%r12), %edx
movq %r14, %rdi
movl $0x5f, %esi
movl %ebx, -0x38(%rbp)
movl %ebx, %ecx
movl %r15d, %r8d
callq 0x3fa9e
movq (%r14), %rax
cmpb $0x0, 0x51(%rax)
movl -0x30(%rbp), %ebx
je 0x62109
leaq 0x333e1(%rip), %rax     # 0x954e8
jmp 0x6211d
movslq 0x3c(%r14), %rax
movq 0x8(%r14), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x18, %rax
movl -0x2c(%rbp), %r12d
movb $0x8, 0x3(%rax)
testl %r15d, %r15d
movq -0x50(%rbp), %rdx
movl -0x38(%rbp), %esi
je 0x62300
movzbl 0x1f(%rdx), %eax
cmpq $0x7, %rax
ja 0x62300
xorl %ecx, %ecx
cmpl %r15d, 0x94(%rdx,%rcx)
je 0x622f8
addq $0x14, %rcx
cmpl $0xc8, %ecx
jne 0x62145
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rdx)
movl %r15d, 0x24(%rdx,%rax,4)
jmp 0x62300
movl 0x54(%r12), %r15d
incl %r15d
movl %r15d, 0x54(%r12)
movl -0x30(%rbp), %ebx
movq -0x38(%rbp), %r13
movl 0x8(%r13), %edx
movq %r14, %rdi
movl $0x32, %esi
movl $0x1, %ecx
movl %r15d, %r8d
callq 0x3fa9e
movq %r14, %rdi
movl %eax, %esi
movq -0x58(%rbp), %rdx
movl $0x1, %ecx
callq 0x14ab9
movl 0x8(%r13), %esi
movq %r12, %rdi
movl $0x1, %edx
callq 0x5291f
movq -0x60(%rbp), %rax
movl 0x4(%rax), %edx
movq %r14, %rdi
movl $0x70, %esi
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
testl %r15d, %r15d
movq -0x40(%rbp), %r13
movq %r12, %rdx
movl -0x2c(%rbp), %r12d
je 0x6228f
movzbl 0x1f(%rdx), %eax
cmpq $0x7, %rax
ja 0x6228f
xorl %ecx, %ecx
cmpl %r15d, 0x94(%rdx,%rcx)
je 0x62334
addq $0x14, %rcx
cmpl $0xc8, %ecx
jne 0x621fe
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rdx)
movl %r15d, 0x24(%rdx,%rax,4)
jmp 0x6228f
movl 0x48(%r12), %ecx
leal (%rcx,%rax), %esi
movl %esi, 0x48(%r12)
movl %edx, 0x44(%r12)
movl %ecx, 0x8(%r15)
movl %eax, 0xc(%r15)
movl 0x8(%r15), %ecx
movl 0x8(%rdi), %ebx
movq %r15, %r13
movl 0xc(%rdi), %r15d
movq 0x10(%r12), %rdi
movl $0x1e, %esi
movl %ebx, %edx
movl %r15d, %r8d
callq 0x3fa9e
movq %r12, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x5291f
movl 0x4(%r13), %edx
movq %r14, %rdi
movl $0x14, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq -0x40(%rbp), %r13
movl -0x30(%rbp), %ebx
movl -0x2c(%rbp), %r12d
movl 0xc(%r13), %edx
testl %edx, %edx
je 0x622aa
movl 0x18(%rbp), %ecx
movq %r14, %rdi
movl $0x8e, %esi
xorl %r8d, %r8d
callq 0x3fa9e
movq 0x30(%r14), %rax
movq 0x80(%rax), %rcx
testq %rcx, %rcx
je 0x622c9
movl -0x44(%rbp), %esi
notl %esi
movl 0x3c(%r14), %edx
movslq %esi, %rsi
movl %edx, (%rcx,%rsi,4)
movl 0x3c(%r14), %ecx
decl %ecx
movl %ecx, 0x68(%rax)
movq %r14, %rdi
movl $0x10, %esi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x8e(%rdx,%rcx)
testl %esi, %esi
je 0x6228f
movzbl 0x1f(%rdx), %eax
cmpq $0x7, %rax
ja 0x6228f
xorl %ecx, %ecx
cmpl %esi, 0x94(%rdx,%rcx)
je 0x62334
addq $0x14, %rcx
cmpl $0xc8, %ecx
jne 0x62310
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rdx)
movl %esi, 0x24(%rdx,%rax,4)
jmp 0x6228f
movb $0x1, 0x8e(%rdx,%rcx)
jmp 0x6228f