#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 */
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
unsigned int strtol(char *, char **, int);
void get_ascii_item(char *word, int type, int *int_val, unsigned int *uint_val,
                    double *double_val) {
  switch (type) {
  case 1:
  case 4:
  case 2:
  case 5:
  case 3:
    *int_val = atoi(word);
    *uint_val = (unsigned int)*int_val;
    *double_val = (double)*int_val;
    break;
  case 6:
    *uint_val = strtol(word, (char **)NULL, 10);
    *int_val = (int)*uint_val;
    *double_val = (double)*uint_val;
    break;
  case 7:
  case 8:
    *double_val = atof(word);
    *int_val = (int)*double_val;
    *uint_val = (unsigned int)*double_val;
    break;
  default:
    fprintf(stderr, "get_ascii_item: bad type = %d\n", type);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<get_ascii_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
add    $0xffffffff,%eax
sub    $0x5,%eax
jb     11a7 <get_ascii_item+0x57>
jmp    1182 <get_ascii_item+0x32>
mov    -0x2c(%rbp),%eax
sub    $0x6,%eax
je     11d9 <get_ascii_item+0x89>
jmp    1193 <get_ascii_item+0x43>
mov    -0x2c(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     1217 <get_ascii_item+0xc7>
jmp    124c <get_ascii_item+0xfc>
mov    -0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%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    126e <get_ascii_item+0x11e>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%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    126e <get_ascii_item+0x11e>
mov    -0x8(%rbp),%rdi
call   1030 <atof@plt>
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    126e <get_ascii_item+0x11e>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xda1(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ascii_item>:
push   %r15
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %esi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x5,%eax
jae    117d <get_ascii_item+0x2d>
call   1060 <atoi@plt>
mov    %eax,(%rbx)
mov    %eax,(%r15)
cvtsi2sdl (%rbx),%xmm0
movsd  %xmm0,(%r14)
jmp    119d <get_ascii_item+0x4d>
lea    -0x7(%rdx),%eax
cmp    $0x2,%eax
jae    11a3 <get_ascii_item+0x53>
call   1030 <atof@plt>
movsd  %xmm0,(%r14)
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
cvttsd2si %xmm0,%rax
mov    %eax,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret
cmp    $0x6,%edx
jne    11c3 <get_ascii_item+0x73>
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,(%r15)
mov    %eax,(%rbx)
mov    (%r15),%eax
cvtsi2sd %rax,%xmm0
jmp    1176 <get_ascii_item+0x26>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"get_ascii_item: bad type = %d\0A\00"
define void @get_ascii_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*
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
%11 = load i32, i32* %7
switch i32 %11, label %46 [
i32 1, label %12
i32 4, label %12
i32 2, label %12
i32 5, label %12
i32 3, label %12
i32 6, label %23
i32 7, label %34
i32 8, label %34
]
12: ; preds = %5, %5, %5, %5, %5
%13 = load i8*, i8** %6
%14 = call i32 @atoi(i8* %13)
%15 = load i32*, i32** %8
store i32 %14, i32* %15
%16 = load i32*, i32** %8
%17 = load i32, i32* %16
%18 = load i32*, i32** %9
store i32 %17, i32* %18
%19 = load i32*, i32** %8
%20 = load i32, i32* %19
%21 = sitofp i32 %20 to double
%22 = load double*, double** %10
store double %21, double* %22
br label %51
23: ; preds = %5
%24 = load i8*, i8** %6
%25 = call i32 @strtol(i8* %24, i8** null, i32 10)
%26 = load i32*, i32** %9
store i32 %25, i32* %26
%27 = load i32*, i32** %9
%28 = load i32, i32* %27
%29 = load i32*, i32** %8
store i32 %28, i32* %29
%30 = load i32*, i32** %9
%31 = load i32, i32* %30
%32 = uitofp i32 %31 to double
%33 = load double*, double** %10
store double %32, double* %33
br label %51
34: ; preds = %5, %5
%35 = load i8*, i8** %6
%36 = call double @atof(i8* %35)
%37 = load double*, double** %10
store double %36, double* %37
%38 = load double*, double** %10
%39 = load double, double* %38
%40 = fptosi double %39 to i32
%41 = load i32*, i32** %8
store i32 %40, i32* %41
%42 = load double*, double** %10
%43 = load double, double* %42
%44 = fptoui double %43 to i32
%45 = load i32*, i32** %9
store i32 %44, i32* %45
br label %51
46: ; preds = %5
%47 = load i32, i32* @stderr
%48 = load i32, i32* %7
%49 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = call i32 @exit(i32 -1)
unreachable
51: ; preds = %34, %23, %12
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"get_ascii_item: bad type = %d\0A\00"
define void @get_ascii_item(i8* nocapture %0, i32 %1, i32* nocapture %2, i32* nocapture %3, double* nocapture writeonly %4) {
switch i32 %1, label %18 [
i32 1, label %6
i32 4, label %6
i32 2, label %6
i32 5, label %6
i32 3, label %6
i32 6, label %10
i32 7, label %14
i32 8, label %14
]
6: ; preds = %5, %5, %5, %5, %5
%7 = tail call i32 @atoi(i8* %0)
store i32 %7, i32* %2
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to double
store double %9, double* %4
br label %22
10: ; preds = %5
%11 = tail call i32 @strtol(i8* nocapture %0, i8** null, i32 10)
store i32 %11, i32* %3
store i32 %11, i32* %2
%12 = load i32, i32* %3
%13 = uitofp i32 %12 to double
store double %13, double* %4
br label %22
14: ; preds = %5, %5
%15 = tail call double @atof(i8* %0)
store double %15, double* %4
%16 = fptosi double %15 to i32
store i32 %16, i32* %2
%17 = fptoui double %15 to i32
store i32 %17, i32* %3
br label %22
18: ; preds = %5
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %1)
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %14, %10, %6
ret void
}