// File: /workspace/github_c_makefile_star2_O2/skeeto[P]flappy/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: {
      static const u16 aFlag[] = { MEM_Blob|MEM_Ephem, MEM_Str|MEM_Ephem };
      u32 len = (serial_type-12)/2;
      pMem->z = (char *)buf;
      pMem->n = len;
      pMem->xDel = 0;
      pMem->flags = aFlag[serial_type&1];
      return len;
    }
  }
  return 0;
}

// Assembly:
pushq %rbx
movq %rdx, %rbx
cmpl $0xb, %esi
ja 0x2aeb1
xorl %eax, %eax
movl %esi, %ecx
leaq 0x3491e(%rip), %rdx     # 0x5f6e4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movw $0x1, %cx
jmp 0x2ae90
addl $-0x8, %esi
movq %rsi, 0x18(%rbx)
jmp 0x2ae8c
movq (%rdi), %rax
bswapq %rax
cmpl $0x6, %esi
jne 0x2ae96
movq %rax, 0x18(%rbx)
pushq $0x8
jmp 0x2ae8b
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)
pushq $0x4
jmp 0x2ae8b
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)
pushq $0x3
jmp 0x2ae8b
movsbq (%rdi), %rax
movq %rax, 0x18(%rbx)
pushq $0x1
jmp 0x2ae8b
movsbq (%rdi), %rax
shlq $0x8, %rax
movzbl 0x1(%rdi), %ecx
orq %rax, %rcx
movq %rcx, 0x18(%rbx)
pushq $0x2
jmp 0x2ae8b
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)
pushq $0x6
popq %rax
movw $0x4, %cx
movw %cx, 0x24(%rbx)
popq %rbx
retq
movq %rax, 0x10(%rbx)
movq %rax, %xmm0
callq 0x169dd
testl %eax, %eax
pushq $0x8
popq %rax
pushq $0x1
popq %rcx
cmovel %eax, %ecx
jmp 0x2ae90
leal -0xc(%rsi), %eax
shrl %eax
movq %rdi, 0x8(%rbx)
movl %eax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
andl $0x1, %esi
leaq 0x381dc(%rip), %rcx     # 0x630a8
movzwl (%rcx,%rsi,2), %ecx
jmp 0x2ae90