// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: exprDup
static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){
  Expr *pNew;           /* Value to return */
  u8 *zAlloc;           /* Memory space from which to build Expr object */
  u32 staticFlag;       /* EP_Static if space not obtained from malloc */

  assert( db!=0 );
  assert( p );
  assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE );
  assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE );

  /* Figure out where to write the new Expr structure. */
  if( pzBuffer ){
    zAlloc = *pzBuffer;
    staticFlag = EP_Static;
  }else{
    zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));
    staticFlag = 0;
  }
  pNew = (Expr *)zAlloc;

  if( pNew ){
    /* Set nNewSize to the size allocated for the structure pointed to
    ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or
    ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed
    ** by the copy of the p->u.zToken string (if any).
    */
    const unsigned nStructSize = dupedExprStructSize(p, dupFlags);
    const int nNewSize = nStructSize & 0xfff;
    int nToken;
    if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
      nToken = sqlite3Strlen30(p->u.zToken) + 1;
    }else{
      nToken = 0;
    }
    if( dupFlags ){
      assert( ExprHasProperty(p, EP_Reduced)==0 );
      memcpy(zAlloc, p, nNewSize);
    }else{
      u32 nSize = (u32)exprStructSize(p);
      memcpy(zAlloc, p, nSize);
      if( nSize<EXPR_FULLSIZE ){
        memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
      }
    }

    /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
    pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken);
    pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);
    pNew->flags |= staticFlag;
    ExprClearVVAProperties(pNew);
    if( dupFlags ){
      ExprSetVVAProperty(pNew, EP_Immutable);
    }

    /* Copy the p->u.zToken string, if any. */
    if( nToken ){
      char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize];
      memcpy(zToken, p->u.zToken, nToken);
    }

    if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){
      /* Fill in the pNew->x.pSelect or pNew->x.pList member. */
      if( ExprHasProperty(p, EP_xIsSelect) ){
        pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags);
      }else{
        pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);
      }
    }

    /* Fill in pNew->pLeft and pNew->pRight. */
    if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){
      zAlloc += dupedExprNodeSize(p, dupFlags);
      if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
        pNew->pLeft = p->pLeft ?
                      exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
        pNew->pRight = p->pRight ?
                       exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
      }
#ifndef SQLITE_OMIT_WINDOWFUNC
      if( ExprHasProperty(p, EP_WinFunc) ){
        pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin);
        assert( ExprHasProperty(pNew, EP_WinFunc) );
      }
#endif /* SQLITE_OMIT_WINDOWFUNC */
      if( pzBuffer ){
        *pzBuffer = zAlloc;
      }
    }else{
      if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
        if( pNew->op==TK_SELECT_COLUMN ){
          pNew->pLeft = p->pLeft;
          assert( p->iColumn==0 || p->pRight==0 );
          assert( p->pRight==0  || p->pRight==p->pLeft );
        }else{
          pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
        }
        pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
      }
    }
  }
  return pNew;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r12
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
testq %rcx, %rcx
je 0x26988f
movq (%r12), %rbx
movl $0x8000000, %eax        # imm = 0x8000000
jmp 0x2698a9
movq %r15, %rdi
movl %ebp, %esi
callq 0x269aa7
movslq %eax, %rsi
movq %r14, %rdi
callq 0x22d205
movq %rax, %rbx
xorl %eax, %eax
testq %rbx, %rbx
je 0x269a95
movl %eax, 0x14(%rsp)
movq %r12, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %r15, %rdi
movl %ebp, 0x4(%rsp)
movl %ebp, %esi
callq 0x269afc
movl %eax, %r13d
movl %eax, %r12d
andl $0xfff, %r12d           # imm = 0xFFF
movl 0x4(%r15), %ebp
xorl %r14d, %r14d
btl $0xa, %ebp
jb 0x2698fc
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x2698fc
callq 0x2211ac
movl %eax, %r14d
incl %r14d
movl %r12d, %r12d
cmpl $0x0, 0x4(%rsp)
je 0x269916
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x17630
jmp 0x269951
btl $0xd, %ebp
pushq $0x48
popq %rax
pushq $0x2c
popq %rcx
cmovael %eax, %ecx
btl $0xe, %ebp
pushq $0x10
popq %rbp
cmovael %ecx, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x17630
cmpl $0x47, %ebp
ja 0x269951
leaq (%rbx,%rbp), %rdi
pushq $0x48
popq %rdx
subq %rbp, %rdx
xorl %esi, %esi
callq 0x17380
movl $0xf7fe9fff, %eax       # imm = 0xF7FE9FFF
andl 0x4(%rbx), %eax
andl $0x6000, %r13d          # imm = 0x6000
orl 0x14(%rsp), %r13d
orl %eax, %r13d
movl %r13d, 0x4(%rbx)
testl %r14d, %r14d
je 0x26998b
addq %rbx, %r12
movq %r12, 0x8(%rbx)
movq 0x8(%r15), %rsi
movl %r14d, %edx
movq %r12, %rdi
callq 0x17630
movl 0x4(%rbx), %r13d
movl 0x4(%r15), %eax
orl %eax, %r13d
testl $0x804000, %r13d        # imm = 0x804000
movq 0x20(%rsp), %r14
movl 0x4(%rsp), %r12d
jne 0x2699c5
btl $0xb, %eax
movq 0x20(%r15), %rsi
movq %r14, %rdi
movl %r12d, %edx
jb 0x2699bc
callq 0x269d84
jmp 0x2699c1
callq 0x269b29
movq %rax, 0x20(%rbx)
movl 0x4(%rbx), %ebp
testl $0x1006000, %ebp        # imm = 0x1006000
je 0x269a0d
movq %r15, %rdi
movl %r12d, %esi
callq 0x269ea6
cltq
addq %rbx, %rax
movq %rax, 0x8(%rsp)
testl $0x804000, %ebp         # imm = 0x804000
movq 0x18(%rsp), %r12
jne 0x269a6d
movq 0x10(%r15), %rsi
testq %rsi, %rsi
je 0x269a46
pushq $0x1
popq %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
callq 0x269866
jmp 0x269a48
movzwl 0x5(%r15), %eax
testw $0x8040, %ax            # imm = 0x8040
jne 0x269a95
cmpb $-0x51, (%rbx)
movq 0x10(%r15), %rax
je 0x269a2e
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x267197
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x267197
movq %rax, 0x18(%rbx)
jmp 0x269a95
xorl %eax, %eax
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0x269a67
pushq $0x1
popq %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
callq 0x269866
jmp 0x269a69
xorl %eax, %eax
movq %rax, 0x18(%rbx)
testb $0x1, 0x7(%r15)
je 0x269a87
movq 0x40(%r15), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x269ee8
movq %rax, 0x40(%rbx)
testq %r12, %r12
je 0x269a95
movq 0x8(%rsp), %rax
movq %rax, (%r12)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq