// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeSerialGet
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
  const unsigned char *buf,     /* Buffer to deserialize from */
  u32 serial_type,              /* Serial type to deserialize */
  Mem *pMem                     /* Memory cell to write value into */
){
  switch( serial_type ){
    case 10:   /* Reserved for future use */
    case 11:   /* Reserved for future use */
    case 0: {  /* NULL */
      pMem->flags = MEM_Null;
      break;
    }
    case 1: { /* 1-byte signed integer */
      pMem->u.i = (signed char)buf[0];
      pMem->flags = MEM_Int;
      return 1;
    }
    case 2: { /* 2-byte signed integer */
      pMem->u.i = (((signed char)buf[0])<<8) | buf[1];
      pMem->flags = MEM_Int;
      return 2;
    }
    case 3: { /* 3-byte signed integer */
      pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2];
      pMem->flags = MEM_Int;
      return 3;
    }
    case 4: { /* 4-byte signed integer */
      pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
      pMem->flags = MEM_Int;
      return 4;
    }
    case 5: { /* 6-byte signed integer */
      u64 x = (((signed char)buf[0])<<8) | buf[1];
      u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];
      x = (x<<32) | y;
      pMem->u.i = *(i64*)&x;
      pMem->flags = MEM_Int;
      return 6;
    }
    case 6:   /* 8-byte signed integer */
    case 7: { /* IEEE floating point */
      u64 x;
      u32 y;
#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)
      /* Verify that integers and floating point values use the same
      ** byte order.  Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is
      ** defined that 64-bit floating point values really are mixed
      ** endian.
      */
      static const u64 t1 = ((u64)0x3ff00000)<<32;
      static const double r1 = 1.0;
      u64 t2 = t1;
      swapMixedEndianFloat(t2);
      assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
#endif

      x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
      y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
      x = (x<<32) | y;
      if( serial_type==6 ){
        pMem->u.i = *(i64*)&x;
        pMem->flags = MEM_Int;
      }else{
        assert( sizeof(x)==8 && sizeof(pMem->r)==8 );
        swapMixedEndianFloat(x);
        memcpy(&pMem->r, &x, sizeof(x));
        pMem->flags = sqlite3IsNaN(pMem->r) ? MEM_Null : MEM_Real;
      }
      return 8;
    }
    case 8:    /* Integer 0 */
    case 9: {  /* Integer 1 */
      pMem->u.i = serial_type-8;
      pMem->flags = MEM_Int;
      return 0;
    }
    default: {
      u32 len = (serial_type-12)/2;
      pMem->z = (char *)buf;
      pMem->n = len;
      pMem->xDel = 0;
      if( serial_type&0x01 ){
        pMem->flags = MEM_Str | MEM_Ephem;
      }else{
        pMem->flags = MEM_Blob | MEM_Ephem;
      }
      return len;
    }
  }
  return 0;
}

// Assembly:
cmpl $0xb, %esi
ja 0x2cf97
movl %esi, %eax
leaq 0x4863b(%rip), %rcx     # 0x754a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x1, 0x24(%rdx)
jmp 0x2ce83
addl $-0x8, %esi
movq %rsi, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
xorl %eax, %eax
retq
movq (%rdi), %rax
bswapq %rax
cmpl $0x6, %esi
jne 0x2cf5c
movq %rax, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
movl $0x8, %eax
retq
movzbl (%rdi), %eax
shll $0x18, %eax
movzbl 0x1(%rdi), %ecx
shll $0x10, %ecx
cltq
orq %rcx, %rax
movzbl 0x2(%rdi), %ecx
shll $0x8, %ecx
orq %rax, %rcx
movzbl 0x3(%rdi), %eax
orq %rcx, %rax
movq %rax, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
movl $0x4, %eax
retq
movsbq (%rdi), %rax
shlq $0x10, %rax
movzbl 0x1(%rdi), %ecx
shll $0x8, %ecx
orq %rax, %rcx
movzbl 0x2(%rdi), %eax
orq %rcx, %rax
movq %rax, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
movl $0x3, %eax
retq
movsbq (%rdi), %rax
movq %rax, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
movl $0x1, %eax
retq
movsbq (%rdi), %rax
shlq $0x8, %rax
movzbl 0x1(%rdi), %ecx
orq %rax, %rcx
movq %rcx, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
movl $0x2, %eax
retq
movsbl (%rdi), %eax
shll $0x8, %eax
movzbl 0x1(%rdi), %ecx
orl %eax, %ecx
movl 0x2(%rdi), %eax
bswapl %eax
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%rdx)
movw $0x4, 0x24(%rdx)
movl $0x6, %eax
retq
pushq %rbp
movq %rsp, %rbp
movq %rax, 0x10(%rdx)
movq %rax, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
ucomisd -0x10(%rbp), %xmm0
movl $0x1, %ecx
movl $0x8, %esi
cmovnel %ecx, %esi
movl $0x8, %eax
cmovpl %ecx, %esi
movw %si, 0x24(%rdx)
popq %rbp
retq
leal -0xc(%rsi), %eax
shrl %eax
movq %rdi, 0x8(%rdx)
movl %eax, 0x20(%rdx)
movq $0x0, 0x28(%rdx)
testb $0x1, %sil
jne 0x2cfb8
movw $0x1010, 0x24(%rdx)     # imm = 0x1010
retq
movw $0x1002, 0x24(%rdx)     # imm = 0x1002
retq