// File: /workspace/github_c_makefile_star2_O1/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 0x48194
movq %rcx, %r13
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
testq %rcx, %rcx
je 0x4819b
movq (%r13), %rbx
movw $0x8000, %cx            # imm = 0x8000
jmp 0x481b5
xorl %ebx, %ebx
jmp 0x483a9
movq %r15, %rdi
movl %r14d, %esi
callq 0x483bb
movq %r12, %rdi
movl %eax, %esi
callq 0x115e9
movq %rax, %rbx
xorl %ecx, %ecx
movq %rbx, -0x30(%rbp)
testq %rbx, %rbx
je 0x483a9
movl %r14d, %esi
movl $0x48, %edx
andl $0x1, %esi
je 0x481ef
movl $0x202c, %edx           # imm = 0x202C
cmpq $0x0, 0x10(%r15)
jne 0x481ef
cmpq $0x0, 0x18(%r15)
jne 0x481ef
cmpq $0x0, 0x20(%r15)
movl $0x4010, %eax           # imm = 0x4010
cmovel %eax, %edx
movl %ecx, -0x40(%rbp)
movl %r14d, -0x38(%rbp)
movl %edx, -0x3c(%rbp)
movl %edx, %ecx
andl $0x7c, %ecx
movzwl 0x2(%r15), %eax
xorl %r14d, %r14d
btl $0xa, %eax
jb 0x48231
movq 0x8(%r15), %rdx
testq %rdx, %rdx
je 0x48231
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r14d
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4821b
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
incl %r14d
movl %ecx, %edx
movl %esi, -0x34(%rbp)
testl %esi, %esi
movq %rdx, -0x58(%rbp)
jne 0x48293
btl $0xd, %eax
movq %r12, -0x50(%rbp)
movl $0x48, %r12d
movl $0x2c, %ecx
cmovaeq %r12, %rcx
btl $0xe, %eax
movq %r13, -0x48(%rbp)
movl $0x10, %r13d
cmovaeq %rcx, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x82f0
subq %r13, %r12
addq -0x30(%rbp), %r13
movq %r13, %rdi
movq -0x48(%rbp), %r13
xorl %esi, %esi
movq %r12, %rdx
movq -0x50(%rbp), %r12
callq 0x8200
jmp 0x4829e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x82f0
movzwl 0x2(%rbx), %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movl -0x3c(%rbp), %edx
andl $0x6000, %edx           # imm = 0x6000
movl -0x40(%rbp), %ecx
orl %edx, %ecx
orl %eax, %ecx
movw %cx, 0x2(%rbx)
testl %r14d, %r14d
je 0x482d8
movq -0x58(%rbp), %rdi
addq -0x30(%rbp), %rdi
movq %rdi, 0x8(%rbx)
movq 0x8(%r15), %rsi
movl %r14d, %edx
callq 0x82f0
movzwl 0x2(%r15), %eax
movzwl 0x2(%rbx), %ecx
orw %ax, %cx
btl $0xe, %ecx
jb 0x4830d
btl $0xb, %eax
movq 0x20(%r15), %rsi
movq %r12, %rdi
jb 0x48301
movl -0x34(%rbp), %edx
callq 0x48556
jmp 0x48309
movl -0x34(%rbp), %edx
callq 0x4841f
movq %rax, 0x20(%rbx)
movzwl 0x2(%rbx), %r14d
testl $0x6000, %r14d          # imm = 0x6000
je 0x48376
movq %r15, %rdi
movl -0x38(%rbp), %esi
callq 0x486a6
cltq
addq %rax, -0x30(%rbp)
btl $0xd, %r14d
jae 0x48367
movq 0x10(%r15), %rsi
leaq -0x30(%rbp), %r14
movq %r12, %rdi
movl $0x1, %edx
movq %r14, %rcx
callq 0x48163
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rsi
movq %r12, %rdi
movl $0x1, %edx
movq %r14, %rcx
callq 0x48163
movq %rax, 0x18(%rbx)
testq %r13, %r13
je 0x483a9
movq -0x30(%rbp), %rax
movq %rax, (%r13)
jmp 0x483a9
movb $0x0, 0x36(%rbx)
testb $0x40, 0x3(%r15)
jne 0x483a9
movq 0x10(%r15), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x48163
movq %rax, 0x10(%rbx)
movq 0x18(%r15), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x48163
movq %rax, 0x18(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq