// File: /workspace/github_c_makefile_star2_O3/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, %r14
movq $0x0, -0x50(%rbp)
testq %rsi, %rsi
je 0x52f18
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %r12
movzbl (%r15), %ebx
cmpl $0x9c, %ebx
jne 0x52e9f
movq 0x10(%r15), %r15
jmp 0x52e8d
cmpl $0x9d, %ebx
jne 0x52eab
movb 0x36(%r15), %bl
cmpb $-0x65, %bl
je 0x52f26
movzbl %bl, %eax
cmpl $0x26, %eax
jne 0x52f4d
movl %ecx, -0x30(%rbp)
movq 0x8(%r15), %rdi
xorl %esi, %esi
callq 0x51369
movq 0x10(%r15), %rsi
movq %r14, %r15
movzbl %al, %r14d
movzbl %r13b, %edx
movq %r12, %rdi
movl %r14d, %ecx
movq %r15, %r8
callq 0x52e5f
movl %eax, %ebx
movq (%r15), %rdi
testq %rdi, %rdi
je 0x5323b
movl %r14d, %esi
movl $0x1, %edx
callq 0x31ff6
movq (%r15), %rdi
movsbl -0x30(%rbp), %esi
movl $0x1, %edx
callq 0x31f29
jmp 0x5323b
movq $0x0, (%r14)
xorl %ebx, %ebx
jmp 0x5323b
movq 0x10(%r15), %r15
movb (%r15), %bl
movl %ebx, %eax
andb $-0x2, %al
cmpb $-0x7c, %al
movq %r14, -0x38(%rbp)
jne 0x53101
leaq 0x29b7d(%rip), %rsi     # 0x7cac1
movq $-0x1, %rdi
jmp 0x52f5d
movq %r14, -0x38(%rbp)
leaq 0x2b149(%rip), %rsi     # 0x7e0a1
movl $0x1, %edi
movzbl %bl, %eax
xorl %r14d, %r14d
cmpl $0x83, %eax
jle 0x5301c
leal -0x84(%rax), %edx
cmpl $0x2, %edx
jb 0x5306f
movl $0x0, %ebx
cmpl $0x86, %eax
jne 0x53234
movl $0x38, %esi
movq %r12, %rdi
callq 0x145aa
xorl %ebx, %ebx
testq %rax, %rax
je 0x5317e
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x30(%rax)
movw $0x1, 0x8(%rax)
movq %r12, 0x28(%rax)
movq 0x8(%r15), %r15
addq $0x2, %r15
movq %r15, %rdi
callq 0xa190
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq %rax, -0x30(%rbp)
leal -0x1(%rax), %r13d
movq %r12, %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x512e2
shrl $0x1f, %r13d
movq -0x30(%rbp), %rcx
leal (%rcx,%r13), %edx
decl %edx
sarl %edx
leaq -0x46d59(%rip), %r8     # 0xc2b1
movq %r14, %rdi
movq %rax, %rsi
xorl %ecx, %ecx
callq 0x11bc0
jmp 0x53234
cmpl $0x61, %eax
je 0x5306f
movl $0x0, %ebx
cmpl $0x65, %eax
jne 0x53234
movl $0x38, %esi
movq %r12, %rdi
callq 0x145aa
xorl %ebx, %ebx
testq %rax, %rax
je 0x5317e
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x30(%rax)
movw $0x1, 0x8(%rax)
movq %r12, 0x28(%rax)
jmp 0x53234
movq %rdi, -0x40(%rbp)
movq %rsi, -0x48(%rbp)
movl %ecx, -0x30(%rbp)
movl $0x38, %esi
movq %r12, %rdi
callq 0x145aa
testq %rax, %rax
je 0x5317e
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x30(%rax)
movw $0x1, 0x8(%rax)
movq %r12, 0x28(%rax)
testb $0x4, 0x5(%r15)
jne 0x53199
movq 0x8(%r15), %rcx
leaq 0x2ab1c(%rip), %rsi     # 0x7dbe5
movq %r12, %rdi
movq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x1494e
testq %rax, %rax
je 0x53181
leaq -0x46e36(%rip), %r8     # 0xc2b1
movq %r14, %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
callq 0x11bc0
jmp 0x531af
movzbl %r13b, %r13d
movl %ecx, -0x30(%rbp)
movzbl %cl, %ecx
leaq -0x50(%rbp), %rbx
movq %r12, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %rbx, %r8
callq 0x52e5f
testl %eax, %eax
sete %al
movq (%rbx), %r14
testq %r14, %r14
setne %cl
andb %al, %cl
xorl %ebx, %ebx
cmpb $0x1, %cl
jne 0x53234
movq %r14, %rdi
callq 0x3617d
movzwl 0x8(%r14), %eax
testb $0x8, %al
jne 0x5320e
movq (%r14), %rcx
negq %rcx
movl -0x30(%rbp), %edx
jno 0x53223
movabsq $0x43e0000000000000, %rcx # imm = 0x43E0000000000000
movq %rcx, (%r14)
andl $0xffffbe00, %eax       # imm = 0xFFFFBE00
orl $0x8, %eax
movw %ax, 0x8(%r14)
jmp 0x53226
xorl %r14d, %r14d
movb $0x1, 0x51(%r12)
movq %r14, %rdi
callq 0x11a2a
movl $0x7, %ebx
jmp 0x5323b
movslq 0x8(%r15), %rax
movq -0x40(%rbp), %rcx
imulq %rax, %rcx
movq %rcx, (%r14)
movw $0x4, 0x8(%r14)
movl -0x30(%rbp), %ecx
andb $-0x1c, %bl
xorb $-0x7c, %bl
movzbl %cl, %eax
xorb $0x41, %cl
orb %bl, %cl
movl $0x43, %ecx
cmovnel %eax, %ecx
movsbl %cl, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x31f29
movzwl 0x8(%r14), %eax
testb $0xc, %al
je 0x531eb
andl $0xfffd, %eax           # imm = 0xFFFD
movw %ax, 0x8(%r14)
xorl %ebx, %ebx
cmpb $0x1, %r13b
je 0x53234
andl $0x2, %eax
je 0x53234
cmpb %r13b, 0xa(%r14)
je 0x53234
movzbl %r13b, %esi
movq %r14, %rdi
callq 0x2a679
movl %eax, %ebx
jmp 0x53234
movsd (%r14), %xmm0
xorps 0x27dc6(%rip), %xmm0    # 0x7afe0
movlps %xmm0, (%r14)
movl -0x30(%rbp), %edx
jmp 0x53226
movq %rcx, (%r14)
movsbl %dl, %esi
movq %r14, %rdi
movl %r13d, %edx
callq 0x31f29
movq -0x38(%rbp), %rax
movq %r14, (%rax)
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq