#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*/ *stderr;
void write_ascii_item(FILE *fp, int int_val, unsigned int uint_val,
                      double double_val, int type) {
  switch (type) {
  case 1:
  case 2:
  case 3:
    fprintf(fp, "%d ", int_val);
    break;
  case 4:
  case 5:
  case 6:
    fprintf(fp, "%u ", uint_val);
    break;
  case 7:
  case 8:
    fprintf(fp, "%g ", double_val);
    break;
  default:
    fprintf(stderr, "write_ascii_item: bad type = %d\n", type);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<write_ascii_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
add    $0xffffffff,%eax
sub    $0x3,%eax
jb     1179 <write_ascii_item+0x59>
jmp    1151 <write_ascii_item+0x31>
mov    -0x20(%rbp),%eax
add    $0xfffffffc,%eax
sub    $0x3,%eax
jb     1191 <write_ascii_item+0x71>
jmp    1165 <write_ascii_item+0x45>
mov    -0x20(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     11a9 <write_ascii_item+0x89>
jmp    11c3 <write_ascii_item+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe79(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11e6 <write_ascii_item+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe65(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11e6 <write_ascii_item+0xc6>
mov    -0x8(%rbp),%rdi
cvttsd2si -0x18(%rbp),%edx
lea    0xe4f(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11e6 <write_ascii_item+0xc6>
mov    0x2e16(%rip),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe35(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_ascii_item>:
cmp    $0x8,%ecx
ja     116f <write_ascii_item+0x4f>
mov    %esi,%eax
mov    $0xe,%esi
bt     %ecx,%esi
jb     1147 <write_ascii_item+0x27>
mov    $0x70,%eax
bt     %ecx,%eax
jae    1155 <write_ascii_item+0x35>
lea    0xec2(%rip),%rsi
jmp    1030 <fprintf@plt>
lea    0xeb2(%rip),%rsi
mov    %eax,%edx
jmp    1030 <fprintf@plt>
mov    $0x180,%eax
bt     %ecx,%eax
jae    116f <write_ascii_item+0x4f>
cvttsd2si %xmm0,%edx
lea    0xe9e(%rip),%rsi
jmp    1030 <fprintf@plt>
push   %rax
mov    0x2e69(%rip),%rax
mov    (%rax),%rdi
lea    0xe8b(%rip),%rsi
mov    %ecx,%edx
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%u \00"
@.str.2 = [4 x i8] c"%g \00"
@stderr = global i32* null
@.str.3 = [33 x i8] c"write_ascii_item: bad type = %d\0A\00"
define void @write_ascii_item(i32* nocapture %0, i32 %1, i32 %2, double %3, i32 %4) {
switch i32 %4, label %13 [
i32 1, label %6
i32 2, label %6
i32 3, label %6
i32 4, label %8
i32 5, label %8
i32 6, label %8
i32 7, label %10
i32 8, label %10
]
6: ; preds = %5, %5, %5
%7 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %17
8: ; preds = %5, %5, %5
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %17
10: ; preds = %5, %5
%11 = fptosi double %3 to i32
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %17
13: ; preds = %5
%14 = load i32*, i32** @stderr
%15 = tail call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %10, %8, %6
ret void
}