#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
double get_item_value(char *item, int type) {
  unsigned char *puchar;
  char *pchar;
  short int *pshort;
  unsigned short int *pushort;
  int *pint;
  unsigned int *puint;
  float *pfloat;
  double *pdouble;
  int int_value;
  unsigned int uint_value;
  double double_value;
  switch (type) {
  case 1:
    pchar = (char *)item;
    int_value = *pchar;
    return ((double)int_value);
  case 4:
    puchar = (unsigned char *)item;
    int_value = *puchar;
    return ((double)int_value);
  case 2:
    pshort = (short int *)item;
    int_value = *pshort;
    return ((double)int_value);
  case 5:
    pushort = (unsigned short int *)item;
    int_value = *pushort;
    return ((double)int_value);
  case 3:
    pint = (int *)item;
    int_value = *pint;
    return ((double)int_value);
  case 6:
    puint = (unsigned int *)item;
    uint_value = *puint;
    return ((double)uint_value);
  case 7:
    pfloat = (float *)item;
    double_value = *pfloat;
    return (double_value);
  case 8:
    pdouble = (double *)item;
    double_value = *pdouble;
    return (double_value);
  default:
    fprintf(stderr, "get_item_value: bad type = %d\n", type);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<get_item_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x70(%rbp)
sub    $0x7,%eax
ja     126b <get_item_value+0x14b>
mov    -0x70(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movswl (%rax),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movzwl (%rax),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128d <get_item_value+0x16d>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xda2(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_item_value>:
push   %rax
mov    %esi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x7,%eax
ja     1172 <get_item_value+0x52>
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl (%rdi),%eax
jmp    1153 <get_item_value+0x33>
cvtsi2sdl (%rdi),%xmm0
pop    %rax
ret
movzbl (%rdi),%eax
jmp    1153 <get_item_value+0x33>
movzwl (%rdi),%eax
jmp    1153 <get_item_value+0x33>
movswl (%rdi),%eax
cvtsi2sd %eax,%xmm0
pop    %rax
ret
mov    (%rdi),%eax
cvtsi2sd %rax,%xmm0
pop    %rax
ret
movss  (%rdi),%xmm0
cvtss2sd %xmm0,%xmm0
pop    %rax
ret
movsd  (%rdi),%xmm0
pop    %rax
ret
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"get_item_value: bad type = %d\0A\00"
define double @get_item_value(i8* %0, i32 %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i16*
%9 = alloca i16*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca float*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
%17 = load i32, i32* %5
switch i32 %17, label %75 [
i32 1, label %18
i32 4, label %25
i32 2, label %32
i32 5, label %40
i32 3, label %48
i32 6, label %55
i32 7, label %62
i32 8, label %69
]
18: ; preds = %2
%19 = load i8*, i8** %4
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
store i32 %22, i32* %14
%23 = load i32, i32* %14
%24 = sitofp i32 %23 to double
store double %24, double* %3
br label %80
25: ; preds = %2
%26 = load i8*, i8** %4
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
store i32 %29, i32* %14
%30 = load i32, i32* %14
%31 = sitofp i32 %30 to double
store double %31, double* %3
br label %80
32: ; preds = %2
%33 = load i8*, i8** %4
%34 = bitcast i8* %33 to i16*
store i16* %34, i16** %8
%35 = load i16*, i16** %8
%36 = load i16, i16* %35
%37 = sext i16 %36 to i32
store i32 %37, i32* %14
%38 = load i32, i32* %14
%39 = sitofp i32 %38 to double
store double %39, double* %3
br label %80
40: ; preds = %2
%41 = load i8*, i8** %4
%42 = bitcast i8* %41 to i16*
store i16* %42, i16** %9
%43 = load i16*, i16** %9
%44 = load i16, i16* %43
%45 = zext i16 %44 to i32
store i32 %45, i32* %14
%46 = load i32, i32* %14
%47 = sitofp i32 %46 to double
store double %47, double* %3
br label %80
48: ; preds = %2
%49 = load i8*, i8** %4
%50 = bitcast i8* %49 to i32*
store i32* %50, i32** %10
%51 = load i32*, i32** %10
%52 = load i32, i32* %51
store i32 %52, i32* %14
%53 = load i32, i32* %14
%54 = sitofp i32 %53 to double
store double %54, double* %3
br label %80
55: ; preds = %2
%56 = load i8*, i8** %4
%57 = bitcast i8* %56 to i32*
store i32* %57, i32** %11
%58 = load i32*, i32** %11
%59 = load i32, i32* %58
store i32 %59, i32* %15
%60 = load i32, i32* %15
%61 = uitofp i32 %60 to double
store double %61, double* %3
br label %80
62: ; preds = %2
%63 = load i8*, i8** %4
%64 = bitcast i8* %63 to float*
store float* %64, float** %12
%65 = load float*, float** %12
%66 = load float, float* %65
%67 = fpext float %66 to double
store double %67, double* %16
%68 = load double, double* %16
store double %68, double* %3
br label %80
69: ; preds = %2
%70 = load i8*, i8** %4
%71 = bitcast i8* %70 to double*
store double* %71, double** %13
%72 = load double*, double** %13
%73 = load double, double* %72
store double %73, double* %16
%74 = load double, double* %16
store double %74, double* %3
br label %80
75: ; preds = %2
%76 = load i32, i32* @stderr
%77 = load i32, i32* %5
%78 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %77)
%79 = call i32 @exit(i32 -1)
unreachable
80: ; preds = %69, %62, %55, %48, %40, %32, %25, %18
%81 = load double, double* %3
ret double %81
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"get_item_value: bad type = %d\0A\00"
define double @get_item_value(i8* nocapture %0, i32 %1) {
switch i32 %1, label %32 [
i32 1, label %3
i32 4, label %6
i32 2, label %9
i32 5, label %13
i32 3, label %17
i32 6, label %21
i32 7, label %25
i32 8, label %29
]
3: ; preds = %2
%4 = load i8, i8* %0
%5 = sitofp i8 %4 to double
br label %36
6: ; preds = %2
%7 = load i8, i8* %0
%8 = uitofp i8 %7 to double
br label %36
9: ; preds = %2
%10 = bitcast i8* %0 to i16*
%11 = load i16, i16* %10
%12 = sitofp i16 %11 to double
br label %36
13: ; preds = %2
%14 = bitcast i8* %0 to i16*
%15 = load i16, i16* %14
%16 = uitofp i16 %15 to double
br label %36
17: ; preds = %2
%18 = bitcast i8* %0 to i32*
%19 = load i32, i32* %18
%20 = sitofp i32 %19 to double
br label %36
21: ; preds = %2
%22 = bitcast i8* %0 to i32*
%23 = load i32, i32* %22
%24 = uitofp i32 %23 to double
br label %36
25: ; preds = %2
%26 = bitcast i8* %0 to float*
%27 = load float, float* %26
%28 = fpext float %27 to double
br label %36
29: ; preds = %2
%30 = bitcast i8* %0 to double*
%31 = load double, double* %30
br label %36
32: ; preds = %2
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %1)
%35 = tail call i32 @exit(i32 -1)
unreachable
36: ; preds = %29, %25, %21, %17, %13, %9, %6, %3
%37 = phi double [ %31, %29 ], [ %28, %25 ], [ %24, %21 ], [ %20, %17 ], [ %16, %13 ], [ %12, %9 ], [ %8, %6 ], [ %5, %3 ]
ret double %37
}