#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;
void store_item(char *item, int type, int int_val, unsigned int uint_val,
                double double_val) {
  unsigned char *puchar;
  short int *pshort;
  unsigned short int *pushort;
  int *pint;
  unsigned int *puint;
  float *pfloat;
  double *pdouble;
  switch (type) {
  case 1:
    *item = int_val;
    break;
  case 4:
    puchar = (unsigned char *)item;
    *puchar = uint_val;
    break;
  case 2:
    pshort = (short *)item;
    *pshort = int_val;
    break;
  case 5:
    pushort = (unsigned short *)item;
    *pushort = uint_val;
    break;
  case 3:
    pint = (int *)item;
    *pint = int_val;
    break;
  case 6:
    puint = (unsigned int *)item;
    *puint = uint_val;
    break;
  case 7:
    pfloat = (float *)item;
    *pfloat = (float)double_val;
    break;
  case 8:
    pdouble = (double *)item;
    *pdouble = double_val;
    break;
  default:
    fprintf(stderr, "store_item: bad type = %d\n", type);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<store_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x7,%eax
ja     1223 <store_item+0x103>
mov    -0x60(%rbp),%rax
lea    0xea6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
mov    %ax,%cx
mov    -0x30(%rbp),%rax
mov    %cx,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %ax,%cx
mov    -0x38(%rbp),%rax
mov    %cx,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x50(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1245 <store_item+0x125>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1245 <store_item+0x125>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xdea(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_item>:
push   %rax
mov    %esi,%eax
lea    -0x1(%rax),%esi
cmp    $0x7,%esi
ja     1165 <store_item+0x45>
lea    0xece(%rip),%rax
movslq (%rax,%rsi,4),%rsi
add    %rax,%rsi
jmp    *%rsi
mov    %dl,(%rdi)
pop    %rax
ret
mov    %edx,(%rdi)
pop    %rax
ret
mov    %cl,(%rdi)
pop    %rax
ret
mov    %cx,(%rdi)
pop    %rax
ret
mov    %dx,(%rdi)
pop    %rax
ret
mov    %ecx,(%rdi)
pop    %rax
ret
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rdi)
pop    %rax
ret
movsd  %xmm0,(%rdi)
pop    %rax
ret
mov    0x2e74(%rip),%rcx
mov    (%rcx),%edi
lea    0xeab(%rip),%rsi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

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

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