// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl -0x14(%rbp), %eax
movq %rax, -0x48(%rbp)
subq $0xb, %rax
ja 0x3bbe1
movq -0x48(%rbp), %rax
leaq 0x6de71(%rip), %rcx     # 0xa97d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movw $0x1, 0x24(%rax)
jmp 0x3bc37
movq -0x10(%rbp), %rax
movsbq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x3bc3e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
orl %ecx, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
movl $0x2, -0x4(%rbp)
jmp 0x3bc3e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
shll $0x10, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
orl %ecx, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
movl $0x3, -0x4(%rbp)
jmp 0x3bc3e
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
movl $0x4, -0x4(%rbp)
jmp 0x3bc3e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
orl %ecx, %eax
cltq
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x4(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
shlq $0x20, %rax
movl -0x2c(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
movl $0x6, -0x4(%rbp)
jmp 0x3bc3e
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x6(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x7(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rax
shlq $0x20, %rax
movl -0x3c(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpl $0x6, -0x14(%rbp)
jne 0x3bb79
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
jmp 0x3bbb0
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0x1bd50
movl %eax, %edx
movl $0x8, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x24(%rax)
movl $0x8, -0x4(%rbp)
jmp 0x3bc3e
movl -0x14(%rbp), %eax
subl $0x8, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movw $0x4, 0x24(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3bc3e
movl -0x14(%rbp), %eax
subl $0xc, %eax
shrl %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x40(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x28(%rax)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3bc25
movq -0x20(%rbp), %rax
movw $0x1002, 0x24(%rax)     # imm = 0x1002
jmp 0x3bc2f
movq -0x20(%rbp), %rax
movw $0x1010, 0x24(%rax)     # imm = 0x1010
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3bc3e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)