// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdx, %rbx
cmpl $0xb, %esi
ja 0x2a055
movl %esi, %eax
leaq 0x3d51e(%rip), %rcx     # 0x6745c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x1, 0x24(%rbx)
jmp 0x29f5c
addl $-0x8, %esi
movq %rsi, 0x18(%rbx)
movw $0x4, 0x24(%rbx)
xorl %eax, %eax
jmp 0x2a02f
movq (%rdi), %rax
bswapq %rax
cmpl $0x6, %esi
jne 0x2a036
movq %rax, 0x18(%rbx)
movw $0x4, 0x24(%rbx)
pushq $0x8
jmp 0x2a02e
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(%rbx)
movw $0x4, 0x24(%rbx)
pushq $0x4
jmp 0x2a02e
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(%rbx)
movw $0x4, 0x24(%rbx)
pushq $0x3
jmp 0x2a02e
movsbq (%rdi), %rax
movq %rax, 0x18(%rbx)
movw $0x4, 0x24(%rbx)
pushq $0x1
jmp 0x2a02e
movsbq (%rdi), %rax
shlq $0x8, %rax
movzbl 0x1(%rdi), %ecx
orq %rax, %rcx
movq %rcx, 0x18(%rbx)
movw $0x4, 0x24(%rbx)
pushq $0x2
jmp 0x2a02e
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(%rbx)
movw $0x4, 0x24(%rbx)
pushq $0x6
popq %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rax, 0x10(%rbx)
movq %rax, %xmm0
callq 0x1570b
testl %eax, %eax
pushq $0x8
popq %rax
pushq $0x1
popq %rcx
cmovel %eax, %ecx
movw %cx, 0x24(%rbx)
jmp 0x2a02f
leal -0xc(%rsi), %eax
shrl %eax
movq %rdi, 0x8(%rbx)
movl %eax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
testb $0x1, %sil
jne 0x2a074
movw $0x1010, 0x24(%rbx)     # imm = 0x1010
jmp 0x2a02f
movw $0x1002, 0x24(%rbx)     # imm = 0x1002
jmp 0x2a02f