// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq $0x0, -0x30(%rbp)
testq %rsi, %rsi
je 0x540cf
movq %rsi, %rbx
movq %rdi, %r12
movzbl (%rbx), %r15d
cmpl $0x9c, %r15d
jne 0x54046
movq 0x10(%rbx), %rbx
jmp 0x54033
cmpl $0x9d, %r15d
jne 0x54053
movb 0x36(%rbx), %r15b
leaq 0x2c037(%rip), %r8      # 0x80091
movl $0x1, %r14d
cmpb $-0x65, %r15b
je 0x540df
movzbl %r15b, %eax
cmpl $0x26, %eax
jne 0x54109
movl %ecx, %r15d
movq 0x8(%rbx), %rdi
xorl %esi, %esi
movl %edx, %r14d
callq 0x524cd
movq 0x10(%rbx), %rsi
movzbl %al, %ebx
movzbl %r14b, %edx
movq %r12, %rdi
movl %ebx, %ecx
movq %r13, %r8
callq 0x54008
movl %eax, %r14d
movq (%r13), %rdi
testq %rdi, %rdi
je 0x54438
movl %ebx, %esi
movl $0x1, %edx
callq 0x32b5d
movq (%r13), %rdi
movsbl %r15b, %esi
movl $0x1, %edx
callq 0x32ae8
jmp 0x54438
movq $0x0, (%r13)
xorl %r14d, %r14d
jmp 0x54438
movq 0x10(%rbx), %rax
movb (%rax), %sil
movl %esi, %edi
andb $-0x2, %dil
movb $-0x65, %r15b
cmpb $-0x7c, %dil
jne 0x54109
leaq 0x2a9b5(%rip), %r8      # 0x7eab1
movq $-0x1, %r14
movl %esi, %r15d
movq %rax, %rbx
movzbl %r15b, %eax
movl $0x0, -0x34(%rbp)
cmpl $0x83, %eax
movq %r13, -0x50(%rbp)
jle 0x541bf
leal -0x84(%rax), %esi
cmpl $0x2, %esi
jb 0x5420c
cmpl $0x86, %eax
je 0x542ac
cmpl $0x9b, %eax
jne 0x54429
movq 0x10(%rbx), %rsi
movzbl %dl, %ebx
movl %ecx, %r15d
movzbl %cl, %ecx
leaq -0x30(%rbp), %r14
movq %r12, %rdi
movl %ebx, %edx
movq %r14, %r8
callq 0x54008
testl %eax, %eax
sete %al
movq (%r14), %r14
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x54429
movq %r14, %rdi
callq 0x36da7
movzwl 0x8(%r14), %eax
testb $0x8, %al
jne 0x54406
movq (%r14), %rcx
negq %rcx
jno 0x54418
movabsq $0x43e0000000000000, %rcx # imm = 0x43E0000000000000
movq %rcx, (%r14)
andl $0xffffbe00, %eax       # imm = 0xFFFFBE00
orl $0x8, %eax
movw %ax, 0x8(%r14)
jmp 0x5441b
cmpl $0x61, %eax
je 0x5420c
cmpl $0x65, %eax
jne 0x54429
movl $0x38, %esi
movq %r12, %rdi
callq 0x144ee
testq %rax, %rax
je 0x5435c
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 %rax, -0x30(%rbp)
jmp 0x54429
movq %r8, -0x48(%rbp)
movl %edx, -0x38(%rbp)
movl %ecx, -0x3c(%rbp)
movl $0x38, %esi
movq %r12, %rdi
callq 0x144ee
movq %rax, %r13
testq %rax, %rax
je 0x542a3
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movups %xmm0, 0x20(%r13)
movups %xmm0, 0x10(%r13)
movq $0x0, 0x30(%r13)
movw $0x1, 0x8(%r13)
movq %r12, 0x28(%r13)
movq %r13, -0x30(%rbp)
testb $0x4, 0x5(%rbx)
jne 0x5433b
movq 0x8(%rbx), %rcx
leaq 0x2b96c(%rip), %rsi     # 0x7fbd5
xorl %ebx, %ebx
movq %r12, %rdi
movq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x148c2
testq %rax, %rax
je 0x54362
leaq -0x4811f(%rip), %r8     # 0xc16a
movq %r13, %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
callq 0x11b32
jmp 0x543a3
movq %r13, -0x30(%rbp)
jmp 0x54360
movl $0x38, %esi
movq %r12, %rdi
callq 0x144ee
movq %rax, %r14
testq %rax, %rax
je 0x54387
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movq $0x0, 0x30(%r14)
movw $0x1, 0x8(%r14)
movq %r12, 0x28(%r14)
movq %r14, -0x30(%rbp)
movq 0x8(%rbx), %rbx
addq $0x2, %rbx
movq %rbx, %rdi
callq 0xa190
movq %rax, %r15
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
leal -0x1(%r15), %r13d
movq %r12, %rdi
movq %rbx, %rsi
movl %r13d, %edx
callq 0x5244c
shrl $0x1f, %r13d
leal (%r15,%r13), %edx
decl %edx
sarl %edx
leaq -0x481c2(%rip), %r8     # 0xc16a
movq %r14, %rdi
movq %rax, %rsi
xorl %ecx, %ecx
callq 0x11b32
jmp 0x5438d
movslq 0x8(%rbx), %rax
imulq %rax, %r14
movzwl 0x8(%r13), %eax
testl $0x2460, %eax           # imm = 0x2460
je 0x54398
movq %r13, %rdi
movq %r14, %rsi
callq 0x2b86a
jmp 0x543a3
movq %rax, -0x30(%rbp)
xorl %ebx, %ebx
movb $0x1, 0x51(%r12)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xb6df
movq -0x30(%rbp), %rdi
callq 0x1199c
movl $0x7, %r14d
jmp 0x54438
movq %r14, -0x30(%rbp)
xorl %ebx, %ebx
testq %r14, %r14
jne 0x54429
jmp 0x54362
movq %r14, (%r13)
movw $0x4, 0x8(%r13)
andb $-0x1c, %r15b
xorb $-0x7c, %r15b
movl -0x3c(%rbp), %ecx
movzbl %cl, %eax
xorb $0x41, %cl
orb %r15b, %cl
movl $0x43, %ecx
cmovnel %eax, %ecx
movsbl %cl, %esi
movq %r13, %rdi
movl $0x1, %edx
callq 0x32ae8
movzwl 0x8(%r13), %eax
testb $0xc, %al
je 0x543e2
andl $0xfffd, %eax           # imm = 0xFFFD
movw %ax, 0x8(%r13)
movl -0x38(%rbp), %eax
cmpb $0x1, %al
je 0x54429
testb $0x2, 0x8(%r13)
je 0x54429
cmpb %al, 0xa(%r13)
je 0x54429
movzbl %al, %esi
movq %r13, %rdi
callq 0x2aaa0
movl %eax, -0x34(%rbp)
jmp 0x54429
movsd (%r14), %xmm0
xorps 0x28bbe(%rip), %xmm0    # 0x7cfd0
movlps %xmm0, (%r14)
jmp 0x5441b
movq %rcx, (%r14)
movsbl %r15b, %esi
movq %r14, %rdi
movl %ebx, %edx
callq 0x32ae8
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rax, (%rcx)
movl -0x34(%rbp), %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq