// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/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: { /* Internal use only: NULL with virtual table
               ** UPDATE no-change flag set */
      pMem->flags = MEM_Null|MEM_Zero;
      pMem->n = 0;
      pMem->u.nZero = 0;
      break;
    }
    case 11:   /* Reserved for future use */
    case 0: {  /* Null */
      /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */
      pMem->flags = MEM_Null;
      break;
    }
    case 1: {
      /* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement
      ** integer. */
      pMem->u.i = ONE_BYTE_INT(buf);
      pMem->flags = MEM_Int;
      testcase( pMem->u.i<0 );
      return 1;
    }
    case 2: { /* 2-byte signed integer */
      /* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit
      ** twos-complement integer. */
      pMem->u.i = TWO_BYTE_INT(buf);
      pMem->flags = MEM_Int;
      testcase( pMem->u.i<0 );
      return 2;
    }
    case 3: { /* 3-byte signed integer */
      /* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit
      ** twos-complement integer. */
      pMem->u.i = THREE_BYTE_INT(buf);
      pMem->flags = MEM_Int;
      testcase( pMem->u.i<0 );
      return 3;
    }
    case 4: { /* 4-byte signed integer */
      /* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit
      ** twos-complement integer. */
      pMem->u.i = FOUR_BYTE_INT(buf);
#ifdef __HP_cc
      /* Work around a sign-extension bug in the HP compiler for HP/UX */
      if( buf[0]&0x80 ) pMem->u.i |= 0xffffffff80000000LL;
#endif
      pMem->flags = MEM_Int;
      testcase( pMem->u.i<0 );
      return 4;
    }
    case 5: { /* 6-byte signed integer */
      /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit
      ** twos-complement integer. */
      pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
      pMem->flags = MEM_Int;
      testcase( pMem->u.i<0 );
      return 6;
    }
    case 6:   /* 8-byte signed integer */
    case 7: { /* IEEE floating point */
      /* These use local variables, so do them in a separate routine
      ** to avoid having to move the frame pointer in the common case */
      return serialGet(buf,serial_type,pMem);
    }
    case 8:    /* Integer 0 */
    case 9: {  /* Integer 1 */
      /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */
      /* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */
      pMem->u.i = serial_type-8;
      pMem->flags = MEM_Int;
      return 0;
    }
    default: {
      /* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in
      ** length.
      ** EVIDENCE-OF: R-28401-00140 Value is a string in the text encoding and
      ** (N-13)/2 bytes in length. */
      static const u16 aFlag[] = { MEM_Blob|MEM_Ephem, MEM_Str|MEM_Ephem };
      pMem->z = (char *)buf;
      pMem->n = (serial_type-12)/2;
      pMem->flags = aFlag[serial_type&1];
      return pMem->n;
    }
  }
  return 0;
}

// Assembly:
cmpl $0xb, %esi
ja 0x2427e4
movl %esi, %eax
leaq 0x12e2be(%rip), %rcx    # 0x370950
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x1, 0x8(%rdx)
jmp 0x24275e
movzbl (%rdi), %eax
shll $0x18, %eax
movzbl 0x1(%rdi), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzwl 0x2(%rdi), %eax
rolw $0x8, %ax
movzwl %ax, %r8d
orl %ecx, %r8d
movzbl 0x4(%rdi), %eax
shll $0x18, %eax
movzbl 0x5(%rdi), %r9d
shll $0x10, %r9d
orl %eax, %r9d
movzbl 0x6(%rdi), %eax
shll $0x8, %eax
movzbl 0x7(%rdi), %edi
shlq $0x20, %r8
orq %r9, %r8
orq %rdi, %r8
orq %rax, %r8
movw $0x4, %di
pushq $0x8
popq %rax
cmpl $0x6, %esi
je 0x242713
movq %r8, %rsi
shlq $0xc, %rsi
pushq $0x1
popq %rdi
cmovel %eax, %edi
notl %ecx
testl $0x7ff00000, %ecx       # imm = 0x7FF00000
cmovnel %eax, %edi
movq %r8, (%rdx)
movw %di, 0x8(%rdx)
retq
addl $-0x8, %esi
movq %rsi, (%rdx)
movw $0x4, 0x8(%rdx)
jmp 0x24275e
movl 0x2(%rdi), %eax
bswapl %eax
movsbl (%rdi), %ecx
shll $0x8, %ecx
movzbl 0x1(%rdi), %esi
orl %ecx, %esi
shlq $0x20, %rsi
orq %rax, %rsi
movq %rsi, (%rdx)
movw $0x4, 0x8(%rdx)
pushq $0x6
jmp 0x2427e2
movw $0x4001, 0x8(%rdx)      # imm = 0x4001
andl $0x0, 0xc(%rdx)
andl $0x0, (%rdx)
xorl %eax, %eax
retq
movsbq (%rdi), %rax
shlq $0x18, %rax
movzbl 0x1(%rdi), %ecx
shll $0x10, %ecx
orq %rax, %rcx
movzbl 0x2(%rdi), %eax
shll $0x8, %eax
orq %rcx, %rax
movzbl 0x3(%rdi), %ecx
orq %rax, %rcx
movq %rcx, (%rdx)
movw $0x4, 0x8(%rdx)
pushq $0x4
jmp 0x2427e2
movsbq (%rdi), %rax
shlq $0x8, %rax
movzbl 0x1(%rdi), %ecx
orq %rax, %rcx
movq %rcx, (%rdx)
movw $0x4, 0x8(%rdx)
pushq $0x2
jmp 0x2427e2
movsbq (%rdi), %rax
movq %rax, (%rdx)
movw $0x4, 0x8(%rdx)
pushq $0x1
jmp 0x2427e2
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, (%rdx)
movw $0x4, 0x8(%rdx)
pushq $0x3
popq %rax
retq
movq %rdi, 0x10(%rdx)
leal -0xc(%rsi), %eax
shrl %eax
movl %eax, 0xc(%rdx)
andl $0x1, %esi
leaq 0x1334b2(%rip), %rcx    # 0x375cac
movzwl (%rcx,%rsi,2), %ecx
movw %cx, 0x8(%rdx)
retq