// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/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;
  }
  op = pExpr->op;
  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;

  /* 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_FLOAT ) pVal->type = SQLITE_FLOAT;
    }
    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){
      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->u.i==SMALLEST_INT64 ){
        pVal->flags &= MEM_Int;
        pVal->flags |= MEM_Real;
        pVal->r = (double)LARGEST_INT64;
      }else{
        pVal->u.i = -pVal->u.i;
      }
      pVal->r = -pVal->r;
      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

  if( pVal ){
    sqlite3VdbeMemStoreType(pVal);
  }
  *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 0x33e09(%rip), %rax     # 0x9baf9
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x67d19
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x680a8
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x85, -0x34(%rbp)
jne 0x67d37
movq -0x18(%rbp), %rax
movzbl 0x36(%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x9c, -0x34(%rbp)
jne 0x67d8c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x82, %eax
je 0x67d64
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x83, %eax
jne 0x67d8c
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 0x329b6(%rip), %rax     # 0x9a73e
movq %rax, -0x58(%rbp)
cmpl $0x5f, -0x34(%rbp)
je 0x67da8
cmpl $0x83, -0x34(%rbp)
je 0x67da8
cmpl $0x82, -0x34(%rbp)
jne 0x67ecf
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x680c0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x67dc5
jmp 0x68083
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x67df1
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq 0x8(%rax), %rsi
movslq -0x4c(%rbp), %rax
imulq %rax, %rsi
callq 0x13cd0
jmp 0x67e50
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x337b7(%rip), %rsi     # 0x9b5bf
movb $0x0, %al
callq 0x16a10
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x67e1f
jmp 0x68083
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %ecx
leaq -0x5ba18(%rip), %r8     # 0xc420
callq 0x1a930
cmpl $0x83, -0x34(%rbp)
jne 0x67e4e
movq -0x48(%rbp), %rax
movb $0x2, 0x26(%rax)
jmp 0x67e50
cmpl $0x82, -0x34(%rbp)
je 0x67e62
cmpl $0x83, -0x34(%rbp)
jne 0x67e80
movzbl -0x1a(%rbp), %eax
cmpl $0x62, %eax
jne 0x67e80
movq -0x48(%rbp), %rdi
movl $0x63, %esi
movl $0x1, %edx
callq 0x680e0
jmp 0x67e92
movq -0x48(%rbp), %rdi
movl $0x1, %edx
movzbl -0x1a(%rbp), %esi
callq 0x680e0
movq -0x48(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
je 0x67eb1
movq -0x48(%rbp), %rax
movzwl 0x24(%rax), %ecx
andl $-0x3, %ecx
movw %cx, 0x24(%rax)
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
je 0x67eca
movq -0x48(%rbp), %rdi
movzbl -0x19(%rbp), %esi
callq 0x35730
movl %eax, -0x5c(%rbp)
jmp 0x68060
cmpl $0x9c, -0x34(%rbp)
jne 0x67fb3
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 0x67c60
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x67fae
cmpq $0x0, -0x48(%rbp)
je 0x67fae
movq -0x48(%rbp), %rdi
callq 0x3f400
movq -0x48(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, 0x18(%rax)
jne 0x67f60
movq -0x48(%rbp), %rax
movzwl 0x24(%rax), %ecx
andl $0x4, %ecx
movw %cx, 0x24(%rax)
movq -0x48(%rbp), %rax
movzwl 0x24(%rax), %ecx
orl $0x8, %ecx
movw %cx, 0x24(%rax)
movq -0x48(%rbp), %rax
movsd 0x30c17(%rip), %xmm0    # 0x98b70
movsd %xmm0, 0x10(%rax)
jmp 0x67f72
movq -0x48(%rbp), %rax
xorl %ecx, %ecx
subq 0x18(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x48(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x48(%rbp), %rdi
movb -0x1a(%rbp), %al
movzbl %al, %esi
movzbl -0x19(%rbp), %edx
callq 0x680e0
jmp 0x6805e
cmpl $0x63, -0x34(%rbp)
jne 0x67fdb
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x680c0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x67fd6
jmp 0x68083
jmp 0x6805c
cmpl $0x84, -0x34(%rbp)
jne 0x6805a
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x680c0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x68001
jmp 0x68083
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xbcc0
subl $0x1, %eax
movl %eax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x60(%rbp), %edx
callq 0x65d10
movq -0x68(%rbp), %rdi
movq %rax, %rsi
movl -0x60(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
xorl %ecx, %ecx
leaq -0x5bc35(%rip), %r8     # 0xc420
callq 0x13980
jmp 0x6805c
jmp 0x6805e
jmp 0x68060
cmpq $0x0, -0x48(%rbp)
je 0x68070
movq -0x48(%rbp), %rdi
callq 0x15fa0
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x680a8
movq -0x10(%rbp), %rax
movb $0x1, 0x50(%rax)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xc760
movq -0x48(%rbp), %rdi
callq 0x1a980
movl $0x7, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)