// File: /workspace/github_c_makefile_star2_O2/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 0x44150
movq %rcx, %r13
movq %rsi, %r12
movq %rdi, %r15
testq %rcx, %rcx
movl %edx, -0x30(%rbp)
je 0x44157
movq (%r13), %rbx
movw $0x8000, %r14w          # imm = 0x8000
jmp 0x44171
xorl %ebx, %ebx
jmp 0x4433b
movq %r12, %rdi
movl %edx, %esi
callq 0x4434d
movq %r15, %rdi
movl %eax, %esi
callq 0x103b4
movq %rax, %rbx
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x4433b
movq %r13, -0x58(%rbp)
movq %r15, -0x40(%rbp)
movl -0x30(%rbp), %esi
movl %esi, %eax
andl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq %r12, %rdi
callq 0x443b1
movl %eax, -0x34(%rbp)
movl %eax, %r15d
andl $0xfff, %r15d           # imm = 0xFFF
movzwl 0x2(%r12), %r13d
xorl %eax, %eax
btl $0xa, %r13d
jb 0x441c2
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x441c2
callq 0x8f8e
incl %eax
movl %eax, -0x38(%rbp)
movl %r15d, %r15d
cmpl $0x0, -0x2c(%rbp)
jne 0x44214
btl $0xd, %r13d
movq %r15, -0x50(%rbp)
pushq $0x48
popq %r15
pushq $0x2c
popq %rax
cmovaeq %r15, %rax
btl $0xe, %r13d
pushq $0x10
popq %r13
cmovaeq %rax, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x82c0
leaq (%rbx,%r13), %rdi
subq %r13, %r15
xorl %esi, %esi
movq %r15, %rdx
movq -0x50(%rbp), %r15
callq 0x81e0
jmp 0x44222
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x82c0
movq -0x40(%rbp), %r13
movzwl 0x2(%rbx), %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movl -0x34(%rbp), %ecx
andl $0x6000, %ecx           # imm = 0x6000
orl %ecx, %r14d
orl %eax, %r14d
movw %r14w, 0x2(%rbx)
movl -0x38(%rbp), %eax
testl %eax, %eax
je 0x44265
addq %rbx, %r15
movq %r15, 0x8(%rbx)
movq 0x8(%r12), %rsi
movl %eax, %edx
movq %r15, %rdi
callq 0x82c0
movzwl 0x2(%rbx), %r14d
movzwl 0x2(%r12), %eax
orl %eax, %r14d
btl $0xe, %r14d
jb 0x44299
btl $0xb, %eax
movq 0x20(%r12), %rsi
movq %r13, %rdi
jb 0x4428d
movl -0x2c(%rbp), %edx
callq 0x44502
jmp 0x44295
movl -0x2c(%rbp), %edx
callq 0x443e4
movq %rax, 0x20(%rbx)
movzwl 0x2(%rbx), %r14d
testw $0x6000, %r14w          # imm = 0x6000
je 0x44309
movq %r12, %rdi
movl -0x30(%rbp), %esi
callq 0x4463e
cltq
addq %rbx, %rax
movq %rax, -0x48(%rbp)
btl $0xd, %r14d
jae 0x442f7
movq 0x10(%r12), %rsi
pushq $0x1
popq %r14
leaq -0x48(%rbp), %r15
movq %r13, %rdi
movl %r14d, %edx
movq %r15, %rcx
callq 0x4411e
movq %rax, 0x10(%rbx)
movq 0x18(%r12), %rsi
movq %r13, %rdi
movl %r14d, %edx
movq %r15, %rcx
callq 0x4411e
movq %rax, 0x18(%rbx)
movq -0x58(%rbp), %rcx
testq %rcx, %rcx
je 0x4433b
movq -0x48(%rbp), %rax
movq %rax, (%rcx)
jmp 0x4433b
movb $0x0, 0x36(%rbx)
testb $0x40, 0x3(%r12)
jne 0x4433b
movq 0x10(%r12), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x440d6
movq %rax, 0x10(%rbx)
movq 0x18(%r12), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x440d6
movq %rax, 0x18(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq