// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3SelectDup
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){
  Select *pRet = 0;
  Select *pNext = 0;
  Select **pp = &pRet;
  Select *p;

  assert( db!=0 );
  for(p=pDup; p; p=p->pPrior){
    Select *pNew = sqlite3DbMallocRawNN(db, sizeof(*p) );
    if( pNew==0 ) break;
    pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags);
    pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags);
    pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags);
    pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags);
    pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags);
    pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags);
    pNew->op = p->op;
    pNew->pNext = pNext;
    pNew->pPrior = 0;
    pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags);
    pNew->iLimit = 0;
    pNew->iOffset = 0;
    pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
    pNew->addrOpenEphm[0] = -1;
    pNew->addrOpenEphm[1] = -1;
    pNew->nSelectRow = p->nSelectRow;
    pNew->pWith = withDup(db, p->pWith);
#ifndef SQLITE_OMIT_WINDOWFUNC
    pNew->pWin = 0;
    pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
    if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
#endif
    pNew->selId = p->selId;
    *pp = pNew;
    pp = &pNew->pPrior;
    pNext = pNew;
  }

  return pRet;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq $0x0, 0x10(%rsp)
testq %rsi, %rsi
je 0x2c2dda
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x10(%rsp), %r12
xorl %r13d, %r13d
movl %edx, 0xc(%rsp)
movq %r13, %rbp
movl $0x80, %esi
movq %r15, %rdi
callq 0x282a35
testq %rax, %rax
je 0x2c2dd3
movq %rax, %r13
movq 0x20(%rbx), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0x2c2deb
movq %rax, 0x20(%r13)
movq 0x28(%rbx), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0x2c30e3
movq %rax, 0x28(%r13)
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x2c2bd9
movq %r15, %rdi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x2c2864
jmp 0x2c2bdb
xorl %eax, %eax
movq %rax, 0x30(%r13)
movq 0x38(%rbx), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0x2c2deb
movq %rax, 0x38(%r13)
movq 0x40(%rbx), %rsi
testq %rsi, %rsi
je 0x2c2c0a
movq %r15, %rdi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x2c2864
jmp 0x2c2c0c
xorl %eax, %eax
movq %rax, 0x40(%r13)
movq 0x48(%rbx), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0x2c2deb
movq %rax, 0x48(%r13)
movb (%rbx), %al
movb %al, (%r13)
movq %rbp, 0x58(%r13)
movq $0x0, 0x50(%r13)
movq 0x60(%rbx), %rsi
testq %rsi, %rsi
movq %r12, 0x20(%rsp)
je 0x2c2c52
movq %r15, %rdi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x2c2864
jmp 0x2c2c54
xorl %eax, %eax
movq %rax, 0x60(%r13)
movq $0x0, 0x8(%r13)
movl 0x4(%rbx), %eax
andl $-0x21, %eax
movl %eax, 0x4(%r13)
movq $-0x1, 0x14(%r13)
movzwl 0x2(%rbx), %eax
movw %ax, 0x2(%r13)
movq 0x68(%rbx), %r12
testq %r12, %r12
je 0x2c2d11
movslq (%r12), %rsi
shlq $0x5, %rsi
orq $0x10, %rsi
movq %r15, %rdi
callq 0x279b27
testq %rax, %rax
je 0x2c2d11
movq %rax, %rbp
movl (%r12), %eax
movl %eax, (%rbp)
testl %eax, %eax
jle 0x2c2d13
movq %rbx, 0x18(%rsp)
movl $0x20, %ebx
xorl %r14d, %r14d
movq (%r12,%rbx), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x2c2b4a
movq %rax, (%rbp,%rbx)
movq -0x8(%r12,%rbx), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x2c2deb
movq %rax, -0x8(%rbp,%rbx)
movq -0x10(%r12,%rbx), %rsi
movq %r15, %rdi
callq 0x279928
movq %rax, -0x10(%rbp,%rbx)
incq %r14
movslq (%r12), %rax
addq $0x20, %rbx
cmpq %rax, %r14
jl 0x2c2cbc
movl 0xc(%rsp), %r14d
movq 0x18(%rsp), %rbx
jmp 0x2c2d13
xorl %ebp, %ebp
movq %rbp, 0x68(%r13)
xorl %eax, %eax
movq %rax, 0x70(%r13)
movq 0x78(%rbx), %rbp
movq %rax, 0x28(%rsp)
movl $0x0, %eax
testq %rbp, %rbp
je 0x2c2d65
movq %rbx, %r12
leaq 0x28(%rsp), %rbx
movq %r15, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x2c2fb9
movq %rax, (%rbx)
testq %rax, %rax
je 0x2c2d5d
addq $0x40, %rax
movq 0x40(%rbp), %rbp
movq %rax, %rbx
testq %rbp, %rbp
jne 0x2c2d38
movq 0x28(%rsp), %rax
movq %r12, %rbx
movq %rax, 0x78(%r13)
cmpq $0x0, 0x70(%rbx)
je 0x2c2dad
cmpb $0x0, 0x61(%r15)
jne 0x2c2dad
leaq 0x598(%rip), %rax       # 0x2c3316
movq %rax, 0x30(%rsp)
leaq 0x5ac(%rip), %rax       # 0x2c3336
movq %rax, 0x38(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0x28(%rsp)
movq %r13, 0x50(%rsp)
leaq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x2c0b5b
movl 0x10(%rbx), %eax
movl %eax, 0x10(%r13)
movq 0x20(%rsp), %rax
movq %r13, (%rax)
movq %r13, %rax
addq $0x50, %rax
movq 0x50(%rbx), %rbx
movq %rax, %r12
testq %rbx, %rbx
jne 0x2c2b7f
movq 0x10(%rsp), %rax
jmp 0x2c2ddc
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq