// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: generateWithRecursiveQuery
static void generateWithRecursiveQuery(
  Parse *pParse,        /* Parsing context */
  Select *p,            /* The recursive SELECT to be coded */
  SelectDest *pDest     /* What to do with query results */
){
  SrcList *pSrc = p->pSrc;      /* The FROM clause of the recursive query */
  int nCol = p->pEList->nExpr;  /* Number of columns in the recursive table */
  Vdbe *v = pParse->pVdbe;      /* The prepared statement under construction */
  Select *pSetup = p->pPrior;   /* The setup query */
  int addrTop;                  /* Top of the loop */
  int addrCont, addrBreak;      /* CONTINUE and BREAK addresses */
  int iCurrent = 0;             /* The Current table */
  int regCurrent;               /* Register holding Current table */
  int iQueue;                   /* The Queue table */
  int iDistinct = 0;            /* To ensure unique results if UNION */
  int eDest = SRT_Fifo;         /* How to write to Queue */
  SelectDest destQueue;         /* SelectDest targetting the Queue table */
  int i;                        /* Loop counter */
  int rc;                       /* Result code */
  ExprList *pOrderBy;           /* The ORDER BY clause */
  Expr *pLimit;                 /* Saved LIMIT and OFFSET */
  int regLimit, regOffset;      /* Registers used by LIMIT and OFFSET */

#ifndef SQLITE_OMIT_WINDOWFUNC
  if( p->pWin ){
    sqlite3ErrorMsg(pParse, "cannot use window functions in recursive queries");
    return;
  }
#endif

  /* Obtain authorization to do a recursive query */
  if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;

  /* Process the LIMIT and OFFSET clauses, if they exist */
  addrBreak = sqlite3VdbeMakeLabel(pParse);
  p->nSelectRow = 320;  /* 4 billion rows */
  computeLimitRegisters(pParse, p, addrBreak);
  pLimit = p->pLimit;
  regLimit = p->iLimit;
  regOffset = p->iOffset;
  p->pLimit = 0;
  p->iLimit = p->iOffset = 0;
  pOrderBy = p->pOrderBy;

  /* Locate the cursor number of the Current table */
  for(i=0; ALWAYS(i<pSrc->nSrc); i++){
    if( pSrc->a[i].fg.isRecursive ){
      iCurrent = pSrc->a[i].iCursor;
      break;
    }
  }

  /* Allocate cursors numbers for Queue and Distinct.  The cursor number for
  ** the Distinct table must be exactly one greater than Queue in order
  ** for the SRT_DistFifo and SRT_DistQueue destinations to work. */
  iQueue = pParse->nTab++;
  if( p->op==TK_UNION ){
    eDest = pOrderBy ? SRT_DistQueue : SRT_DistFifo;
    iDistinct = pParse->nTab++;
  }else{
    eDest = pOrderBy ? SRT_Queue : SRT_Fifo;
  }
  sqlite3SelectDestInit(&destQueue, eDest, iQueue);

  /* Allocate cursors for Current, Queue, and Distinct. */
  regCurrent = ++pParse->nMem;
  sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);
  if( pOrderBy ){
    KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);
    sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,
                      (char*)pKeyInfo, P4_KEYINFO);
    destQueue.pOrderBy = pOrderBy;
  }else{
    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);
  }
  VdbeComment((v, "Queue table"));
  if( iDistinct ){
    p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);
    p->selFlags |= SF_UsesEphemeral;
  }

  /* Detach the ORDER BY clause from the compound SELECT */
  p->pOrderBy = 0;

  /* Store the results of the setup-query in Queue. */
  pSetup->pNext = 0;
  ExplainQueryPlan((pParse, 1, "SETUP"));
  rc = sqlite3Select(pParse, pSetup, &destQueue);
  pSetup->pNext = p;
  if( rc ) goto end_of_recursive_query;

  /* Find the next row in the Queue and output that row */
  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak); VdbeCoverage(v);

  /* Transfer the next row in Queue over to Current */
  sqlite3VdbeAddOp1(v, OP_NullRow, iCurrent); /* To reset column cache */
  if( pOrderBy ){
    sqlite3VdbeAddOp3(v, OP_Column, iQueue, pOrderBy->nExpr+1, regCurrent);
  }else{
    sqlite3VdbeAddOp2(v, OP_RowData, iQueue, regCurrent);
  }
  sqlite3VdbeAddOp1(v, OP_Delete, iQueue);

  /* Output the single row in Current */
  addrCont = sqlite3VdbeMakeLabel(pParse);
  codeOffset(v, regOffset, addrCont);
  selectInnerLoop(pParse, p, iCurrent,
      0, 0, pDest, addrCont, addrBreak);
  if( regLimit ){
    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);
    VdbeCoverage(v);
  }
  sqlite3VdbeResolveLabel(v, addrCont);

  /* Execute the recursive SELECT taking the single row in Current as
  ** the value for the recursive-table. Store the results in the Queue.
  */
  if( p->selFlags & SF_Aggregate ){
    sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
  }else{
    p->pPrior = 0;
    ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
    sqlite3Select(pParse, p, &destQueue);
    assert( p->pPrior==0 );
    p->pPrior = pSetup;
  }

  /* Keep running the loop until the Queue is empty */
  sqlite3VdbeGoto(v, addrTop);
  sqlite3VdbeResolveLabel(v, addrBreak);

end_of_recursive_query:
  sqlite3ExprListDelete(pParse->db, p->pOrderBy);
  p->pOrderBy = pOrderBy;
  p->pLimit = pLimit;
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x5, -0x58(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x446baf
movq -0x8(%rbp), %rdi
leaq 0x167139(%rip), %rsi    # 0x5adcdc
movb $0x0, %al
callq 0x3cb660
jmp 0x446fff
movq -0x8(%rbp), %rdi
movl $0x21, %esi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rdx
movq %r8, %rcx
callq 0x4338b0
cmpl $0x0, %eax
je 0x446bd2
jmp 0x446fff
movq -0x8(%rbp), %rdi
callq 0x42d540
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movw $0x140, 0x2(%rax)       # imm = 0x140
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x441010
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x90(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x446cc1
movq -0x20(%rbp), %rax
addq $0x8, %rax
movslq -0x84(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movb 0x3d(%rax), %al
shrb $0x5, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x446cae
movq -0x20(%rbp), %rax
addq $0x8, %rax
movslq -0x84(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x40(%rax), %eax
movl %eax, -0x48(%rbp)
jmp 0x446cc1
jmp 0x446cb0
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x446c5c
movq -0x8(%rbp), %rcx
movl 0x34(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x34(%rcx)
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x84, %eax
jne 0x446d10
movq -0x90(%rbp), %rdx
movl $0x6, %eax
movl $0x8, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rcx
movl 0x34(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x34(%rcx)
movl %eax, -0x54(%rbp)
jmp 0x446d2b
movq -0x90(%rbp), %rdx
movl $0x5, %eax
movl $0x7, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %esi
movl -0x50(%rbp), %edx
leaq -0x80(%rbp), %rdi
callq 0x430c20
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x48(%rbp), %edx
movl -0x4c(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl $0x72, %esi
callq 0x410130
cmpq $0x0, -0x90(%rbp)
je 0x446dc0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x447ce0
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movq -0x90(%rbp), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movq -0xa8(%rbp), %r9
movl $0x64, %esi
xorl %r8d, %r8d
movl $0xfffffff7, (%rsp)     # imm = 0xFFFFFFF7
callq 0x429aa0
movq -0x90(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x446dd4
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x24(%rbp), %ecx
movl $0x64, %esi
callq 0x410100
cmpl $0x0, -0x54(%rbp)
je 0x446e03
movq -0x30(%rbp), %rdi
movl -0x54(%rbp), %edx
movl $0x64, %esi
xorl %ecx, %ecx
callq 0x410100
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
leaq 0x166ee2(%rip), %rdx    # 0x5add0d
movb $0x0, %al
callq 0x430b00
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x41aee0
movl %eax, -0x88(%rbp)
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x58(%rax)
cmpl $0x0, -0x88(%rbp)
je 0x446e63
jmp 0x446fcd
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x44(%rbp), %ecx
movl $0x25, %esi
callq 0x410100
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x48(%rbp), %edx
movl $0x80, %esi
callq 0x42ba70
cmpq $0x0, -0x90(%rbp)
je 0x446eb8
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movq -0x90(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl -0x4c(%rbp), %r8d
movl $0x59, %esi
callq 0x410130
jmp 0x446ecc
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %ecx
movl $0x7e, %esi
callq 0x410100
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
movl $0x7a, %esi
callq 0x42ba70
movq -0x8(%rbp), %rdi
callq 0x42d540
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movl -0xa0(%rbp), %esi
movl -0x40(%rbp), %edx
callq 0x447e40
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x48(%rbp), %edx
movq -0x18(%rbp), %r9
movl -0x40(%rbp), %r10d
movl -0x44(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %r8d
movq %r8, %rcx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x4435c0
cmpl $0x0, -0x9c(%rbp)
je 0x446f46
movq -0x30(%rbp), %rdi
movl -0x9c(%rbp), %edx
movl -0x44(%rbp), %ecx
movl $0x3b, %esi
callq 0x410100
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x42dc90
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x446f75
movq -0x8(%rbp), %rdi
leaq 0x166da7(%rip), %rsi    # 0x5add13
movb $0x0, %al
callq 0x3cb660
jmp 0x446fb5
movq -0x10(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
leaq 0x166dac(%rip), %rdx    # 0x5add3d
movb $0x0, %al
callq 0x430b00
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x41aee0
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x429db0
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x42dc90
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
callq 0x40c6a0
movq -0x90(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x98(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)