// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: exprDup
static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
  Expr *pNew = 0;                      /* Value to return */
  if( p ){
    const int isReduced = (flags&EXPRDUP_REDUCE);
    u8 *zAlloc;
    u32 staticFlag = 0;

    assert( pzBuffer==0 || isReduced );

    /* Figure out where to write the new Expr structure. */
    if( pzBuffer ){
      zAlloc = *pzBuffer;
      staticFlag = EP_Static;
    }else{
      zAlloc = sqlite3DbMallocRaw(db, dupedExprSize(p, flags));
    }
    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, flags);
      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( isReduced ){
        assert( ExprHasProperty(p, EP_Reduced)==0 );
        memcpy(zAlloc, p, nNewSize);
      }else{
        int nSize = exprStructSize(p);
        memcpy(zAlloc, p, nSize);
        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);
      pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);
      pNew->flags |= staticFlag;

      /* 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) ){
        /* Fill in the pNew->x.pSelect or pNew->x.pList member. */
        if( ExprHasProperty(p, EP_xIsSelect) ){
          pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, isReduced);
        }else{
          pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced);
        }
      }

      /* Fill in pNew->pLeft and pNew->pRight. */
      if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly) ){
        zAlloc += dupedExprNodeSize(p, flags);
        if( ExprHasProperty(pNew, EP_Reduced) ){
          pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
          pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc);
        }
        if( pzBuffer ){
          *pzBuffer = zAlloc;
        }
      }else{
        pNew->flags2 = 0;
        if( !ExprHasAnyProperty(p, EP_TokenOnly) ){
          pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
          pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
        }
      }

    }
  }
  return pNew;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rsi, %rsi
je 0x484bd
movq %rcx, %r14
movq %rsi, %r13
movq %rdi, %r12
testq %rcx, %rcx
movl %edx, -0x30(%rbp)
je 0x484c4
movq (%r14), %rbx
movw $0x8000, %r15w          # imm = 0x8000
jmp 0x484de
xorl %ebx, %ebx
jmp 0x486ce
movq %r13, %rdi
movl %edx, %esi
callq 0x486e0
movq %r12, %rdi
movl %eax, %esi
callq 0x11721
movq %rax, %rbx
xorl %r15d, %r15d
testq %rbx, %rbx
je 0x486ce
movl -0x30(%rbp), %esi
movl $0x48, %ecx
andl $0x1, %esi
je 0x48514
movl $0x202c, %ecx           # imm = 0x202C
cmpq $0x0, 0x10(%r13)
jne 0x48514
cmpq $0x0, 0x18(%r13)
jne 0x48514
cmpq $0x0, 0x20(%r13)
movl $0x4010, %eax           # imm = 0x4010
cmovel %eax, %ecx
movq %r14, -0x60(%rbp)
movl %ecx, -0x34(%rbp)
andl $0x7c, %ecx
movzwl 0x2(%r13), %eax
xorl %r14d, %r14d
btl $0xa, %eax
jb 0x48551
movq 0x8(%r13), %rdx
testq %rdx, %rdx
je 0x48551
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r14d
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4853b
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
incl %r14d
movl %ecx, %edx
movl %esi, -0x2c(%rbp)
testl %esi, %esi
movq %rdx, -0x58(%rbp)
jne 0x485b1
btl $0xd, %eax
movq %r12, -0x50(%rbp)
movl $0x48, %r12d
movl $0x2c, %ecx
cmovaeq %r12, %rcx
btl $0xe, %eax
movq %r13, -0x40(%rbp)
movl $0x10, %r13d
cmovaeq %rcx, %r13
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
movq %r13, %rdx
callq 0x82f0
leaq (%rbx,%r13), %rdi
subq %r13, %r12
movq -0x40(%rbp), %r13
xorl %esi, %esi
movq %r12, %rdx
movq -0x50(%rbp), %r12
callq 0x8200
jmp 0x485bc
movq %rbx, %rdi
movq %r13, %rsi
callq 0x82f0
movzwl 0x2(%rbx), %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movl -0x34(%rbp), %ecx
andl $0x6000, %ecx           # imm = 0x6000
orl %ecx, %r15d
orl %eax, %r15d
movw %r15w, 0x2(%rbx)
testl %r14d, %r14d
je 0x485fa
movq -0x58(%rbp), %rdi
addq %rbx, %rdi
movq %rdi, 0x8(%rbx)
movq 0x8(%r13), %rsi
movl %r14d, %edx
callq 0x82f0
movzwl 0x2(%rbx), %r15d
movzwl 0x2(%r13), %eax
orl %eax, %r15d
btl $0xe, %r15d
jb 0x4862c
btl $0xb, %eax
movq 0x20(%r13), %rsi
movq %r12, %rdi
jb 0x48620
movl -0x2c(%rbp), %edx
callq 0x4887b
jmp 0x48628
movl -0x2c(%rbp), %edx
callq 0x48744
movq %rax, 0x20(%rbx)
movzwl 0x2(%rbx), %r14d
testl $0x6000, %r14d          # imm = 0x6000
je 0x4869b
movq %r13, %rdi
movl -0x30(%rbp), %esi
callq 0x489cb
cltq
addq %rbx, %rax
movq %rax, -0x48(%rbp)
btl $0xd, %r14d
jae 0x48689
movq 0x10(%r13), %rsi
leaq -0x48(%rbp), %r14
movq %r12, %rdi
movl $0x1, %edx
movq %r14, %rcx
callq 0x4848c
movq %rax, 0x10(%rbx)
movq 0x18(%r13), %rsi
movq %r12, %rdi
movl $0x1, %edx
movq %r14, %rcx
callq 0x4848c
movq %rax, 0x18(%rbx)
movq -0x60(%rbp), %rcx
testq %rcx, %rcx
je 0x486ce
movq -0x48(%rbp), %rax
movq %rax, (%rcx)
jmp 0x486ce
movb $0x0, 0x36(%rbx)
testb $0x40, 0x3(%r13)
jne 0x486ce
movq 0x10(%r13), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4848c
movq %rax, 0x10(%rbx)
movq 0x18(%r13), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4848c
movq %rax, 0x18(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq