// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: valueFromExpr
static int valueFromExpr(
  sqlite3 *db,                    /* The database connection */
  Expr *pExpr,                    /* The expression to evaluate */
  u8 enc,                         /* Encoding to use */
  u8 affinity,                    /* Affinity to use */
  sqlite3_value **ppVal,          /* Write the new value here */
  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */
){
  int op;
  char *zVal = 0;
  sqlite3_value *pVal = 0;
  int negInt = 1;
  const char *zNeg = "";
  int rc = SQLITE_OK;

  if( !pExpr ){
    *ppVal = 0;
    return SQLITE_OK;
  }
  while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;

  /* Compressed expressions only appear when parsing the DEFAULT clause
  ** on a table column definition, and hence only when pCtx==0.  This
  ** check ensures that an EP_TokenOnly expression is never passed down
  ** into valueFromFunction(). */
  assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );

  if( op==TK_CAST ){
    u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
    rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
    testcase( rc!=SQLITE_OK );
    if( *ppVal ){
      sqlite3VdbeMemCast(*ppVal, aff, SQLITE_UTF8);
      sqlite3ValueApplyAffinity(*ppVal, affinity, SQLITE_UTF8);
    }
    return rc;
  }

  /* Handle negative integers in a single step.  This is needed in the
  ** case when the value is -9223372036854775808.
  */
  if( op==TK_UMINUS
   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){
    pExpr = pExpr->pLeft;
    op = pExpr->op;
    negInt = -1;
    zNeg = "-";
  }

  if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){
    pVal = valueNew(db, pCtx);
    if( pVal==0 ) goto no_mem;
    if( ExprHasProperty(pExpr, EP_IntValue) ){
      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
    }else{
      zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
      if( zVal==0 ) goto no_mem;
      sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
    }
    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){
      sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
    }else{
      sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
    }
    if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;
    if( enc!=SQLITE_UTF8 ){
      rc = sqlite3VdbeChangeEncoding(pVal, enc);
    }
  }else if( op==TK_UMINUS ) {
    /* This branch happens for multiple negative signs.  Ex: -(-5) */
    if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) 
     && pVal!=0
    ){
      sqlite3VdbeMemNumerify(pVal);
      if( pVal->flags & MEM_Real ){
        pVal->u.r = -pVal->u.r;
      }else if( pVal->u.i==SMALLEST_INT64 ){
        pVal->u.r = -(double)SMALLEST_INT64;
        MemSetTypeFlag(pVal, MEM_Real);
      }else{
        pVal->u.i = -pVal->u.i;
      }
      sqlite3ValueApplyAffinity(pVal, affinity, enc);
    }
  }else if( op==TK_NULL ){
    pVal = valueNew(db, pCtx);
    if( pVal==0 ) goto no_mem;
  }
#ifndef SQLITE_OMIT_BLOB_LITERAL
  else if( op==TK_BLOB ){
    int nVal;
    assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
    assert( pExpr->u.zToken[1]=='\'' );
    pVal = valueNew(db, pCtx);
    if( !pVal ) goto no_mem;
    zVal = &pExpr->u.zToken[2];
    nVal = sqlite3Strlen30(zVal)-1;
    assert( zVal[nVal]=='\'' );
    sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
                         0, SQLITE_DYNAMIC);
  }
#endif

#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  else if( op==TK_FUNCTION && pCtx!=0 ){
    rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
  }
#endif

  *ppVal = pVal;
  return rc;

no_mem:
  db->mallocFailed = 1;
  sqlite3DbFree(db, zVal);
  assert( *ppVal==0 );
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  if( pCtx==0 ) sqlite3ValueFree(pVal);
#else
  assert( pCtx==0 ); sqlite3ValueFree(pVal);
#endif
  return SQLITE_NOMEM;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
andq $0x0, -0x38(%rbp)
testq %rsi, %rsi
je 0x4cbb5
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %r13
movzbl (%r14), %ebx
cmpl $0x9c, %ebx
jne 0x4cb3b
movq 0x10(%r14), %r14
jmp 0x4cb29
cmpl $0x9d, %ebx
jne 0x4cb47
movb 0x36(%r14), %bl
cmpb $-0x65, %bl
je 0x4cbc0
movzbl %bl, %eax
cmpl $0x26, %eax
jne 0x4cbde
movl %ecx, -0x2c(%rbp)
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x4b6e5
movq 0x10(%r14), %rsi
movzbl %al, %r14d
movzbl %r12b, %edx
movq %r13, %rdi
movl %r14d, %ecx
movq %r15, %r8
callq 0x4cafe
movl %eax, %ebx
movq (%r15), %rdi
testq %rdi, %rdi
je 0x4ce35
movq %r15, %r12
pushq $0x1
popq %r15
movl %r14d, %esi
movl %r15d, %edx
callq 0x2ed4e
movq (%r12), %rdi
movsbl -0x2c(%rbp), %esi
movl %r15d, %edx
callq 0x2ecaa
jmp 0x4ce35
andq $0x0, (%r15)
xorl %ebx, %ebx
jmp 0x4ce35
movq 0x10(%r14), %r14
movb (%r14), %bl
movl %ebx, %eax
andb $-0x2, %al
cmpb $-0x7c, %al
jne 0x4cc7d
leaq 0x20ed7(%rip), %rsi     # 0x6dab1
pushq $-0x1
jmp 0x4cbe7
leaq 0x224ac(%rip), %rsi     # 0x6f091
pushq $0x1
popq %rdi
movzbl %bl, %eax
leal -0x84(%rax), %edx
cmpl $0x2, %edx
movq %r15, -0x40(%rbp)
jb 0x4cc17
cmpl $0x86, %eax
je 0x4cd1c
cmpl $0x65, %eax
je 0x4cd05
cmpl $0x61, %eax
jne 0x4cd98
movq %rdi, -0x48(%rbp)
movq %rsi, -0x50(%rbp)
movl %ecx, -0x2c(%rbp)
movq %r13, %rdi
callq 0x1616a
testq %rax, %rax
je 0x4cd76
movq %rax, %r15
testb $0x4, 0x5(%r14)
jne 0x4cda2
movq 0x8(%r14), %rcx
leaq 0x21f89(%rip), %rsi     # 0x6ebd5
movq %r13, %rdi
movq -0x50(%rbp), %rdx
xorl %eax, %eax
callq 0x13638
testq %rax, %rax
je 0x4cd79
leaq -0x4097e(%rip), %rcx    # 0xc2ec
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x16191
jmp 0x4cdb6
movq %r15, -0x40(%rbp)
movzbl %r12b, %r12d
movl %ecx, -0x2c(%rbp)
movzbl %cl, %ecx
leaq -0x38(%rbp), %rbx
movq %r13, %rdi
movq %r14, %rsi
movl %r12d, %edx
movq %rbx, %r8
callq 0x4caf7
testl %eax, %eax
sete %al
movq (%rbx), %r15
testq %r15, %r15
setne %cl
andb %al, %cl
xorl %ebx, %ebx
cmpb $0x1, %cl
jne 0x4ce2e
movq %r15, %rdi
callq 0x309c9
movq -0x38(%rbp), %rax
testb $0x8, 0x8(%rax)
jne 0x4ce06
movq (%rax), %rcx
negq %rcx
movl -0x2c(%rbp), %edx
jno 0x4ce19
movabsq $0x43e0000000000000, %rcx # imm = 0x43E0000000000000
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movl $0xffffbe00, %ecx       # imm = 0xFFFFBE00
andl 0x8(%rax), %ecx
orl $0x8, %ecx
movw %cx, 0x8(%rax)
jmp 0x4ce1c
movq %r13, %rdi
callq 0x1616a
xorl %ebx, %ebx
testq %rax, %rax
je 0x4cd76
movq %rax, %r15
jmp 0x4ce2e
movq %r13, %rdi
callq 0x1616a
xorl %ebx, %ebx
testq %rax, %rax
je 0x4cd76
movq %rax, %r15
movq 0x8(%r14), %r14
addq $0x2, %r14
movq %r14, %rdi
callq 0xb080
movl %eax, %r12d
decl %r12d
movq %r13, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x4b66d
movq %rax, %rsi
pushq $0x2
popq %rcx
movl %r12d, %eax
cltd
idivl %ecx
leaq -0x40a79(%rip), %r8     # 0xc2ec
movq %r15, %rdi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x10f88
jmp 0x4ce2e
xorl %r15d, %r15d
movb $0x1, 0x51(%r13)
movq %r13, %rdi
xorl %esi, %esi
callq 0xb856
movq %r15, %rdi
callq 0x10e69
pushq $0x7
popq %rbx
jmp 0x4ce35
xorl %r15d, %r15d
xorl %ebx, %ebx
jmp 0x4ce2e
movslq 0x8(%r14), %rax
movq -0x48(%rbp), %rsi
imulq %rax, %rsi
movq %r15, %rdi
callq 0x111c8
andb $-0x1c, %bl
xorb $-0x7c, %bl
movl -0x2c(%rbp), %ecx
movzbl %cl, %eax
xorb $0x41, %cl
orb %bl, %cl
pushq $0x43
popq %rcx
cmovnel %eax, %ecx
movsbl %cl, %esi
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x2ecaa
movzwl 0x8(%r15), %eax
testb $0xc, %al
je 0x4cdee
andl $0xfffd, %eax           # imm = 0xFFFD
movw %ax, 0x8(%r15)
xorl %ebx, %ebx
cmpb $0x1, %r12b
je 0x4ce2e
movzbl %r12b, %esi
movq %r15, %rdi
callq 0x26930
movl %eax, %ebx
jmp 0x4ce2e
movsd (%rax), %xmm0
xorps 0x1f1bf(%rip), %xmm0    # 0x6bfd0
movlps %xmm0, (%rax)
movl -0x2c(%rbp), %edx
jmp 0x4ce1c
movq %rcx, (%rax)
movq -0x38(%rbp), %r15
movsbl %dl, %esi
movq %r15, %rdi
movl %r12d, %edx
callq 0x2ecaa
movq -0x40(%rbp), %rax
movq %r15, (%rax)
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq