// File: /workspace/github_c_makefile_star2_O1/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 0x2a4930
movl %esi, %eax
leaq 0x1354ec(%rip), %rcx    # 0x3d9cb8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x1, 0x8(%rdx)
jmp 0x2a484c
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, %eax
orl %ecx, %eax
movzbl 0x4(%rdi), %r8d
shll $0x18, %r8d
movzbl 0x5(%rdi), %r9d
shll $0x10, %r9d
orl %r8d, %r9d
movzbl 0x6(%rdi), %r8d
shll $0x8, %r8d
movzbl 0x7(%rdi), %edi
shlq $0x20, %rax
orq %r9, %rax
orq %rdi, %rax
orq %r8, %rax
movq %rax, (%rdx)
cmpl $0x6, %esi
jne 0x2a490f
movw $0x4, 0x8(%rdx)
movl $0x8, %eax
retq
addl $-0x8, %esi
movq %rsi, (%rdx)
movw $0x4, 0x8(%rdx)
xorl %eax, %eax
retq
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)
movl $0x6, %eax
retq
movw $0x4001, 0x8(%rdx)      # imm = 0x4001
xorl %eax, %eax
movl %eax, 0xc(%rdx)
movl %eax, (%rdx)
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)
movl $0x4, %eax
retq
movsbq (%rdi), %rax
shlq $0x8, %rax
movzbl 0x1(%rdi), %ecx
orq %rax, %rcx
movq %rcx, (%rdx)
movw $0x4, 0x8(%rdx)
movl $0x2, %eax
retq
movsbq (%rdi), %rax
movq %rax, (%rdx)
movw $0x4, 0x8(%rdx)
movl $0x1, %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, (%rdx)
movw $0x4, 0x8(%rdx)
movl $0x3, %eax
retq
notl %ecx
shlq $0xc, %rax
movl $0x1, %esi
movl $0x8, %eax
cmovel %eax, %esi
testl $0x7ff00000, %ecx       # imm = 0x7FF00000
cmovnel %eax, %esi
movw %si, 0x8(%rdx)
retq
movq %rdi, 0x10(%rdx)
leal -0xc(%rsi), %eax
shrl %eax
movl %eax, 0xc(%rdx)
andl $0x1, %esi
leaq 0x13a636(%rip), %rcx    # 0x3def7c
movzwl (%rcx,%rsi,2), %ecx
movw %cx, 0x8(%rdx)
retq