// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movq %rsi, %r15
movq %rdi, %r14
testq %rcx, %rcx
je 0x2cbfc1
movq (%r12), %rbx
movl $0x8000000, %ecx        # imm = 0x8000000
jmp 0x2cbfdc
movq %r15, %rdi
movl %r13d, %esi
callq 0x2cc230
movslq %eax, %rsi
movq %r14, %rdi
callq 0x28c518
movq %rax, %rbx
xorl %ecx, %ecx
movq %rbx, 0x8(%rsp)
testq %rbx, %rbx
je 0x2cc21e
movq %r12, 0x18(%rsp)
movl $0x48, %ebp
testl %r13d, %r13d
movq %r14, 0x20(%rsp)
movl %r13d, 0x10(%rsp)
je 0x2cc029
cmpb $-0x51, (%r15)
je 0x2cc029
testb $0x1, 0x7(%r15)
jne 0x2cc029
movl $0x202c, %ebp           # imm = 0x202C
cmpq $0x0, 0x10(%r15)
jne 0x2cc029
cmpq $0x0, 0x20(%r15)
movl $0x4010, %eax           # imm = 0x4010
cmovel %eax, %ebp
movl %ecx, 0x14(%rsp)
movl %ebp, %r14d
andl $0x7c, %r14d
movl 0x4(%r15), %r12d
xorl %r13d, %r13d
btl $0xa, %r12d
jb 0x2cc05d
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x2cc05d
callq 0x172f0
movq %rax, %r13
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
incl %r13d
movl %r14d, %r14d
cmpl $0x0, 0x10(%rsp)
je 0x2cc077
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x17660
jmp 0x2cc0c3
btl $0xd, %r12d
movl $0x48, %eax
movl $0x2c, %ecx
cmovael %eax, %ecx
btl $0xe, %r12d
movl $0x10, %r12d
cmovael %ecx, %r12d
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x17660
cmpl $0x47, %r12d
ja 0x2cc0c3
movq 0x8(%rsp), %rdi
addq %r12, %rdi
movl $0x48, %edx
subq %r12, %rdx
xorl %esi, %esi
callq 0x173a0
movl $0xf7fe9fff, %eax       # imm = 0xF7FE9FFF
andl 0x4(%rbx), %eax
andl $0x6000, %ebp           # imm = 0x6000
orl 0x14(%rsp), %ebp
orl %eax, %ebp
movl %ebp, 0x4(%rbx)
testl %r13d, %r13d
je 0x2cc0f7
addq 0x8(%rsp), %r14
movq %r14, 0x8(%rbx)
movq 0x8(%r15), %rsi
movl %r13d, %edx
movq %r14, %rdi
callq 0x17660
movl 0x4(%r15), %eax
movl 0x4(%rbx), %ecx
orl %eax, %ecx
testl $0x804000, %ecx         # imm = 0x804000
movq 0x20(%rsp), %r14
movl 0x10(%rsp), %r12d
jne 0x2cc132
btl $0xb, %eax
movq 0x20(%r15), %rsi
movq %r14, %rdi
movl %r12d, %edx
jb 0x2cc129
callq 0x2cc525
jmp 0x2cc12e
callq 0x2cc285
movq %rax, 0x20(%rbx)
movl 0x4(%rbx), %ebp
testl $0x1006000, %ebp        # imm = 0x1006000
je 0x2cc179
movq %r15, %rdi
movl %r12d, %esi
callq 0x2cc693
cltq
addq %rax, 0x8(%rsp)
testl $0x804000, %ebp         # imm = 0x804000
movq 0x18(%rsp), %r12
jne 0x2cc1d1
movq 0x10(%r15), %rsi
testq %rsi, %rsi
je 0x2cc1a8
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movl $0x1, %edx
callq 0x2cbf97
jmp 0x2cc1aa
movzwl 0x5(%r15), %eax
testl $0x8040, %eax           # imm = 0x8040
jne 0x2cc21e
cmpb $-0x51, (%rbx)
movq 0x10(%r15), %rax
je 0x2cc1fd
testq %rax, %rax
je 0x2cc1fb
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2cbf97
jmp 0x2cc1fd
xorl %eax, %eax
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0x2cc1cb
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movl $0x1, %edx
callq 0x2cbf97
jmp 0x2cc1cd
xorl %eax, %eax
movq %rax, 0x18(%rbx)
testb $0x1, 0x7(%r15)
je 0x2cc1eb
movq 0x40(%r15), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2cc6ed
movq %rax, 0x40(%rbx)
testq %r12, %r12
je 0x2cc21e
movq 0x8(%rsp), %rax
movq %rax, (%r12)
jmp 0x2cc21e
xorl %eax, %eax
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0x2cc218
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2cbf97
jmp 0x2cc21a
xorl %eax, %eax
movq %rax, 0x18(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq