// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %cl, -0x19(%rbp)
movb %al, -0x1a(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x1, -0x4c(%rbp)
leaq 0x3868f(%rip), %rax     # 0xa89df
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x70379
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x70782
jmp 0x7037b
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x9c, %eax
jne 0x7039a
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x7037b
cmpl $0x9d, -0x34(%rbp)
jne 0x703ae
movq -0x18(%rbp), %rax
movzbl 0x36(%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x26, -0x34(%rbp)
jne 0x7042f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6e110
movb %al, -0x5d(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movb -0x19(%rbp), %cl
movb -0x5d(%rbp), %al
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movzbl %cl, %edx
movzbl %al, %ecx
callq 0x70310
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x70424
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %edx
movzbl -0x5d(%rbp), %esi
callq 0x42ff0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %edx
movzbl -0x1a(%rbp), %esi
callq 0x483d0
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x70782
cmpl $0x9b, -0x34(%rbp)
jne 0x70484
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x84, %eax
je 0x7045c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x85, %eax
jne 0x70484
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x34(%rbp)
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
leaq 0x36f7f(%rip), %rax     # 0xa73ff
movq %rax, -0x58(%rbp)
cmpl $0x61, -0x34(%rbp)
je 0x704a0
cmpl $0x85, -0x34(%rbp)
je 0x704a0
cmpl $0x84, -0x34(%rbp)
jne 0x705b4
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x70790
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x704bd
jmp 0x7075d
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x704e9
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq 0x8(%rax), %rsi
movslq -0x4c(%rbp), %rax
imulq %rax, %rsi
callq 0x14ce0
jmp 0x70535
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x38023(%rip), %rsi     # 0xa8523
movb $0x0, %al
callq 0x17940
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x70517
jmp 0x7075d
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %ecx
leaq -0x62820(%rip), %r8     # 0xdd10
callq 0x1b880
cmpl $0x84, -0x34(%rbp)
je 0x70547
cmpl $0x85, -0x34(%rbp)
jne 0x70565
movzbl -0x1a(%rbp), %eax
cmpl $0x41, %eax
jne 0x70565
movq -0x48(%rbp), %rdi
movl $0x43, %esi
movl $0x1, %edx
callq 0x483d0
jmp 0x70577
movq -0x48(%rbp), %rdi
movl $0x1, %edx
movzbl -0x1a(%rbp), %esi
callq 0x483d0
movq -0x48(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
je 0x70596
movq -0x48(%rbp), %rax
movzwl 0x8(%rax), %ecx
andl $-0x3, %ecx
movw %cx, 0x8(%rax)
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
je 0x705af
movq -0x48(%rbp), %rdi
movzbl -0x19(%rbp), %esi
callq 0x38510
movl %eax, -0x5c(%rbp)
jmp 0x7074a
cmpl $0x9b, -0x34(%rbp)
jne 0x706a3
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movb -0x19(%rbp), %al
leaq -0x48(%rbp), %r8
movzbl %al, %edx
movzbl -0x1a(%rbp), %ecx
callq 0x702c0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x7069e
cmpq $0x0, -0x48(%rbp)
je 0x7069e
movq -0x48(%rbp), %rdi
callq 0x48400
movq -0x48(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x70639
movq -0x48(%rbp), %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x48(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x7068b
movq -0x48(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, (%rax)
jne 0x70679
movq -0x48(%rbp), %rax
movsd 0x35250(%rip), %xmm0    # 0xa58a8
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0xffffbe00, %eax       # imm = 0xFFFFBE00
orl $0x8, %eax
movw %ax, %cx
movq -0x48(%rbp), %rax
movw %cx, 0x8(%rax)
jmp 0x70689
movq -0x48(%rbp), %rax
xorl %ecx, %ecx
subq (%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
jmp 0x7068b
movq -0x48(%rbp), %rdi
movb -0x1a(%rbp), %al
movzbl %al, %esi
movzbl -0x19(%rbp), %edx
callq 0x483d0
jmp 0x70748
cmpl $0x65, -0x34(%rbp)
jne 0x706c8
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x70790
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x706c6
jmp 0x7075d
jmp 0x70746
cmpl $0x86, -0x34(%rbp)
jne 0x70744
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x70790
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x706eb
jmp 0x7075d
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xc6c0
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x64(%rbp), %edx
callq 0x6e020
movq -0x70(%rbp), %rdi
movq %rax, %rsi
movl -0x64(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
xorl %ecx, %ecx
leaq -0x62a2f(%rip), %r8     # 0xdd10
callq 0x14990
jmp 0x70746
jmp 0x70748
jmp 0x7074a
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x70782
movq -0x10(%rbp), %rax
movb $0x1, 0x51(%rax)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xd260
movq -0x48(%rbp), %rdi
callq 0x14710
movl $0x7, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)