// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: withExpand
static int withExpand(
  Walker *pWalker,
  struct SrcList_item *pFrom
){
  Parse *pParse = pWalker->pParse;
  sqlite3 *db = pParse->db;
  struct Cte *pCte;               /* Matched CTE (or NULL if no match) */
  With *pWith;                    /* WITH clause that pCte belongs to */

  assert( pFrom->pTab==0 );
  if( pParse->nErr ){
    return SQLITE_ERROR;
  }

  pCte = searchWith(pParse->pWith, pFrom, &pWith);
  if( pCte ){
    Table *pTab;
    ExprList *pEList;
    Select *pSel;
    Select *pLeft;                /* Left-most SELECT statement */
    int bMayRecursive;            /* True if compound joined by UNION [ALL] */
    With *pSavedWith;             /* Initial value of pParse->pWith */

    /* If pCte->zCteErr is non-NULL at this point, then this is an illegal
    ** recursive reference to CTE pCte. Leave an error in pParse and return
    ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.
    ** In this case, proceed.  */
    if( pCte->zCteErr ){
      sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName);
      return SQLITE_ERROR;
    }
    if( cannotBeFunction(pParse, pFrom) ) return SQLITE_ERROR;

    assert( pFrom->pTab==0 );
    pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
    if( pTab==0 ) return WRC_Abort;
    pTab->nTabRef = 1;
    pTab->zName = sqlite3DbStrDup(db, pCte->zName);
    pTab->iPKey = -1;
    pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
    pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;
    pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
    if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;
    assert( pFrom->pSelect );

    /* Check if this is a recursive CTE. */
    pSel = pFrom->pSelect;
    bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
    if( bMayRecursive ){
      int i;
      SrcList *pSrc = pFrom->pSelect->pSrc;
      for(i=0; i<pSrc->nSrc; i++){
        struct SrcList_item *pItem = &pSrc->a[i];
        if( pItem->zDatabase==0
         && pItem->zName!=0
         && 0==sqlite3StrICmp(pItem->zName, pCte->zName)
          ){
          pItem->pTab = pTab;
          pItem->fg.isRecursive = 1;
          pTab->nTabRef++;
          pSel->selFlags |= SF_Recursive;
        }
      }
    }

    /* Only one recursive reference is permitted. */
    if( pTab->nTabRef>2 ){
      sqlite3ErrorMsg(
          pParse, "multiple references to recursive table: %s", pCte->zName
      );
      return SQLITE_ERROR;
    }
    assert( pTab->nTabRef==1 ||
            ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 ));

    pCte->zCteErr = "circular reference: %s";
    pSavedWith = pParse->pWith;
    pParse->pWith = pWith;
    if( bMayRecursive ){
      Select *pPrior = pSel->pPrior;
      assert( pPrior->pWith==0 );
      pPrior->pWith = pSel->pWith;
      sqlite3WalkSelect(pWalker, pPrior);
      pPrior->pWith = 0;
    }else{
      sqlite3WalkSelect(pWalker, pSel);
    }
    pParse->pWith = pWith;

    for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
    pEList = pLeft->pEList;
    if( pCte->pCols ){
      if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){
        sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
            pCte->zName, pEList->nExpr, pCte->pCols->nExpr
        );
        pParse->pWith = pSavedWith;
        return SQLITE_ERROR;
      }
      pEList = pCte->pCols;
    }

    sqlite3ColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol);
    if( bMayRecursive ){
      if( pSel->selFlags & SF_Recursive ){
        pCte->zCteErr = "multiple recursive references: %s";
      }else{
        pCte->zCteErr = "recursive reference in a subquery: %s";
      }
      sqlite3WalkSelect(pWalker, pSel);
    }
    pCte->zCteErr = 0;
    pParse->pWith = pSavedWith;
  }

  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x439faf
movl $0x1, -0x4(%rbp)
jmp 0x43a3c4
movq -0x20(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x43aeb0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x43a3bd
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x43a007
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rax
movq (%rax), %rdx
movb $0x0, %al
callq 0x3cb660
movl $0x1, -0x4(%rbp)
jmp 0x43a3c4
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x43a580
cmpl $0x0, %eax
je 0x43a025
movl $0x1, -0x4(%rbp)
jmp 0x43a3c4
movq -0x28(%rbp), %rdi
movl $0x80, %esi
callq 0x3c9520
movq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpq $0x0, -0x40(%rbp)
jne 0x43a055
movl $0x2, -0x4(%rbp)
jmp 0x43a3c4
movq -0x40(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
callq 0x3c91a0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movw $0xffff, 0x44(%rax)     # imm = 0xFFFF
movq -0x40(%rbp), %rax
movw $0xc8, 0x4a(%rax)
movq -0x40(%rbp), %rax
movl 0x40(%rax), %ecx
orl $0x202, %ecx            # imm = 0x202
movl %ecx, 0x40(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %edx, %edx
callq 0x4325b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
cmpb $0x0, 0x61(%rax)
je 0x43a0d2
movl $0x7, -0x4(%rbp)
jmp 0x43a3c4
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movzbl (%rax), %ecx
movb $0x1, %al
cmpl $0x85, %ecx
movb %al, -0x89(%rbp)
je 0x43a10a
movq -0x50(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x84, %eax
sete %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x43a1dc
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x43a1da
movq -0x78(%rbp), %rax
addq $0x8, %rax
movslq -0x6c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x43a1ca
movq -0x80(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x43a1ca
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
callq 0x3c3e60
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x43a1ca
movq -0x40(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x80(%rbp), %rax
movb 0x3d(%rax), %cl
andb $-0x21, %cl
orb $0x20, %cl
movb %cl, 0x3d(%rax)
movq -0x40(%rbp), %rax
movl 0x3c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x3c(%rax)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x2000, %ecx           # imm = 0x2000
movl %ecx, 0x4(%rax)
jmp 0x43a1cc
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x43a139
jmp 0x43a1dc
movq -0x40(%rbp), %rax
cmpl $0x2, 0x3c(%rax)
jbe 0x43a20b
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rdx
leaq 0x173038(%rip), %rsi    # 0x5ad230
movb $0x0, %al
callq 0x3cb660
movl $0x1, -0x4(%rbp)
jmp 0x43a3c4
movq -0x30(%rbp), %rax
leaq 0x173045(%rip), %rcx    # 0x5ad25b
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x190(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x190(%rax)
cmpl $0x0, -0x5c(%rbp)
je 0x43a281
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x42f7d0
movq -0x88(%rbp), %rax
movq $0x0, 0x68(%rax)
jmp 0x43a28e
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x42f7d0
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x43a2c0
jmp 0x43a2b2
movq -0x58(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x43a2a5
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x43a341
cmpq $0x0, -0x48(%rbp)
je 0x43a335
movq -0x48(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl (%rcx), %eax
je 0x43a335
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rdx
movq -0x48(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %r8d
leaq 0x172f5f(%rip), %rsi    # 0x5ad272
movb $0x0, %al
callq 0x3cb660
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x190(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x43a3c4
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq $0x46, %rdx
movq -0x40(%rbp), %rcx
addq $0x8, %rcx
callq 0x43af90
cmpl $0x0, -0x5c(%rbp)
je 0x43a3a2
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x43a386
movq -0x30(%rbp), %rax
leaq 0x172f18(%rip), %rcx    # 0x5ad298
movq %rcx, 0x18(%rax)
jmp 0x43a395
movq -0x30(%rbp), %rax
leaq 0x172f29(%rip), %rcx    # 0x5ad2ba
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x42f7d0
movq -0x30(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x190(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq