#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ fread(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void get_binary_item(FILE *fp, int type, int *int_val, unsigned int *uint_val,
                     double *double_val) {
  char c[8];
  void *ptr;
  ptr = (void *)c;
  switch (type) {
  case 1:
    fread(ptr, 1, 1, fp);
    *int_val = *((char *)ptr);
    *uint_val = *int_val;
    *double_val = *int_val;
    break;
  case 4:
    fread(ptr, 1, 1, fp);
    *uint_val = *((unsigned char *)ptr);
    *int_val = *uint_val;
    *double_val = *uint_val;
    break;
  case 2:
    fread(ptr, 2, 1, fp);
    *int_val = *((short int *)ptr);
    *uint_val = *int_val;
    *double_val = *int_val;
    break;
  case 5:
    fread(ptr, 2, 1, fp);
    *uint_val = *((unsigned short int *)ptr);
    *int_val = *uint_val;
    *double_val = *uint_val;
    break;
  case 3:
    fread(ptr, 4, 1, fp);
    *int_val = *((int *)ptr);
    *uint_val = *int_val;
    *double_val = *int_val;
    break;
  case 6:
    fread(ptr, 4, 1, fp);
    *uint_val = *((unsigned int *)ptr);
    *int_val = *uint_val;
    *double_val = *uint_val;
    break;
  case 7:
    fread(ptr, 4, 1, fp);
    *double_val = *((float *)ptr);
    *int_val = *double_val;
    *uint_val = *double_val;
    break;
  case 8:
    fread(ptr, 8, 1, fp);
    *double_val = *((double *)ptr);
    *int_val = *double_val;
    *uint_val = *double_val;
    break;
  default:
    fprintf(stderr, "get_binary_item: bad type = %d\n", type);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<get_binary_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x7,%eax
ja     13b5 <get_binary_item+0x285>
mov    -0x40(%rbp),%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cvtsi2sd %rax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
movswl (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
movzwl (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cvtsi2sd %rax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cvtsi2sd %rax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
cvttsd2si (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cvttsd2si (%rax),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
cvttsd2si (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cvttsd2si (%rax),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    13d7 <get_binary_item+0x2a7>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xc58(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_binary_item>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %esi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x7,%eax
ja     128d <get_binary_item+0x15d>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdi,%rcx
lea    0xea6(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movsbl 0x8(%rsp),%eax
jmp    11e7 <get_binary_item+0xb7>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x8(%rsp),%eax
jmp    11e7 <get_binary_item+0xb7>
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movzbl 0x8(%rsp),%eax
jmp    1212 <get_binary_item+0xe2>
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movzwl 0x8(%rsp),%eax
jmp    1212 <get_binary_item+0xe2>
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movswl 0x8(%rsp),%eax
mov    %eax,(%rbx)
mov    %eax,(%r15)
cvtsi2sdl (%rbx),%xmm0
movsd  %xmm0,(%r14)
jmp    1283 <get_binary_item+0x153>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%r15)
mov    %eax,(%rbx)
mov    (%r15),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r14)
jmp    1283 <get_binary_item+0x153>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,(%r14)
cvttss2si %xmm0,%eax
mov    %eax,(%rbx)
cvttss2si %xmm0,%rax
jmp    1280 <get_binary_item+0x150>
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
cvttsd2si %xmm0,%rax
mov    %eax,(%r15)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"get_binary_item: bad type = %d\0A\00"
define void @get_binary_item(i32* %0, i32 %1, i32* %2, i32* %3, double* %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca double*
%11 = alloca [8 x i8]
%12 = alloca i8*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store double* %4, double** %10
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
store i8* %13, i8** %12
%14 = load i32, i32* %7
switch i32 %14, label %140 [
i32 1, label %15
i32 4, label %30
i32 2, label %45
i32 5, label %61
i32 3, label %77
i32 6, label %92
i32 7, label %107
i32 8, label %124
]
15: ; preds = %5
%16 = load i8*, i8** %12
%17 = load i32*, i32** %6
%18 = call i32 @fread(i8* %16, i32 1, i32 1, i32* %17)
%19 = load i8*, i8** %12
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i32*, i32** %8
store i32 %21, i32* %22
%23 = load i32*, i32** %8
%24 = load i32, i32* %23
%25 = load i32*, i32** %9
store i32 %24, i32* %25
%26 = load i32*, i32** %8
%27 = load i32, i32* %26
%28 = sitofp i32 %27 to double
%29 = load double*, double** %10
store double %28, double* %29
br label %145
30: ; preds = %5
%31 = load i8*, i8** %12
%32 = load i32*, i32** %6
%33 = call i32 @fread(i8* %31, i32 1, i32 1, i32* %32)
%34 = load i8*, i8** %12
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = load i32*, i32** %9
store i32 %36, i32* %37
%38 = load i32*, i32** %9
%39 = load i32, i32* %38
%40 = load i32*, i32** %8
store i32 %39, i32* %40
%41 = load i32*, i32** %9
%42 = load i32, i32* %41
%43 = uitofp i32 %42 to double
%44 = load double*, double** %10
store double %43, double* %44
br label %145
45: ; preds = %5
%46 = load i8*, i8** %12
%47 = load i32*, i32** %6
%48 = call i32 @fread(i8* %46, i32 2, i32 1, i32* %47)
%49 = load i8*, i8** %12
%50 = bitcast i8* %49 to i16*
%51 = load i16, i16* %50
%52 = sext i16 %51 to i32
%53 = load i32*, i32** %8
store i32 %52, i32* %53
%54 = load i32*, i32** %8
%55 = load i32, i32* %54
%56 = load i32*, i32** %9
store i32 %55, i32* %56
%57 = load i32*, i32** %8
%58 = load i32, i32* %57
%59 = sitofp i32 %58 to double
%60 = load double*, double** %10
store double %59, double* %60
br label %145
61: ; preds = %5
%62 = load i8*, i8** %12
%63 = load i32*, i32** %6
%64 = call i32 @fread(i8* %62, i32 2, i32 1, i32* %63)
%65 = load i8*, i8** %12
%66 = bitcast i8* %65 to i16*
%67 = load i16, i16* %66
%68 = zext i16 %67 to i32
%69 = load i32*, i32** %9
store i32 %68, i32* %69
%70 = load i32*, i32** %9
%71 = load i32, i32* %70
%72 = load i32*, i32** %8
store i32 %71, i32* %72
%73 = load i32*, i32** %9
%74 = load i32, i32* %73
%75 = uitofp i32 %74 to double
%76 = load double*, double** %10
store double %75, double* %76
br label %145
77: ; preds = %5
%78 = load i8*, i8** %12
%79 = load i32*, i32** %6
%80 = call i32 @fread(i8* %78, i32 4, i32 1, i32* %79)
%81 = load i8*, i8** %12
%82 = bitcast i8* %81 to i32*
%83 = load i32, i32* %82
%84 = load i32*, i32** %8
store i32 %83, i32* %84
%85 = load i32*, i32** %8
%86 = load i32, i32* %85
%87 = load i32*, i32** %9
store i32 %86, i32* %87
%88 = load i32*, i32** %8
%89 = load i32, i32* %88
%90 = sitofp i32 %89 to double
%91 = load double*, double** %10
store double %90, double* %91
br label %145
92: ; preds = %5
%93 = load i8*, i8** %12
%94 = load i32*, i32** %6
%95 = call i32 @fread(i8* %93, i32 4, i32 1, i32* %94)
%96 = load i8*, i8** %12
%97 = bitcast i8* %96 to i32*
%98 = load i32, i32* %97
%99 = load i32*, i32** %9
store i32 %98, i32* %99
%100 = load i32*, i32** %9
%101 = load i32, i32* %100
%102 = load i32*, i32** %8
store i32 %101, i32* %102
%103 = load i32*, i32** %9
%104 = load i32, i32* %103
%105 = uitofp i32 %104 to double
%106 = load double*, double** %10
store double %105, double* %106
br label %145
107: ; preds = %5
%108 = load i8*, i8** %12
%109 = load i32*, i32** %6
%110 = call i32 @fread(i8* %108, i32 4, i32 1, i32* %109)
%111 = load i8*, i8** %12
%112 = bitcast i8* %111 to float*
%113 = load float, float* %112
%114 = fpext float %113 to double
%115 = load double*, double** %10
store double %114, double* %115
%116 = load double*, double** %10
%117 = load double, double* %116
%118 = fptosi double %117 to i32
%119 = load i32*, i32** %8
store i32 %118, i32* %119
%120 = load double*, double** %10
%121 = load double, double* %120
%122 = fptoui double %121 to i32
%123 = load i32*, i32** %9
store i32 %122, i32* %123
br label %145
124: ; preds = %5
%125 = load i8*, i8** %12
%126 = load i32*, i32** %6
%127 = call i32 @fread(i8* %125, i32 8, i32 1, i32* %126)
%128 = load i8*, i8** %12
%129 = bitcast i8* %128 to double*
%130 = load double, double* %129
%131 = load double*, double** %10
store double %130, double* %131
%132 = load double*, double** %10
%133 = load double, double* %132
%134 = fptosi double %133 to i32
%135 = load i32*, i32** %8
store i32 %134, i32* %135
%136 = load double*, double** %10
%137 = load double, double* %136
%138 = fptoui double %137 to i32
%139 = load i32*, i32** %9
store i32 %138, i32* %139
br label %145
140: ; preds = %5
%141 = load i32, i32* @stderr
%142 = load i32, i32* %7
%143 = call i32 @fprintf(i32 %141, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %142)
%144 = call i32 @exit(i32 -1)
unreachable
145: ; preds = %124, %107, %92, %77, %61, %45, %30, %15
ret void
}

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