#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;
double old_write_ascii_item(FILE *fp, 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;
    fprintf(fp, "%d ", int_value);
    return ((double)int_value);
  case 4:
    puchar = (unsigned char *)item;
    int_value = *puchar;
    fprintf(fp, "%d ", int_value);
    return ((double)int_value);
  case 2:
    pshort = (short int *)item;
    int_value = *pshort;
    fprintf(fp, "%d ", int_value);
    return ((double)int_value);
  case 5:
    pushort = (unsigned short int *)item;
    int_value = *pushort;
    fprintf(fp, "%d ", int_value);
    return ((double)int_value);
  case 3:
    pint = (int *)item;
    int_value = *pint;
    fprintf(fp, "%d ", int_value);
    return ((double)int_value);
  case 6:
    puint = (unsigned int *)item;
    uint_value = *puint;
    fprintf(fp, "%u ", uint_value);
    return ((double)uint_value);
  case 7:
    pfloat = (float *)item;
    double_value = *pfloat;
    fprintf(fp, "%g ", double_value);
    return (double_value);
  case 8:
    pdouble = (double *)item;
    double_value = *pdouble;
    fprintf(fp, "%g ", double_value);
    return (double_value);
  default:
    fprintf(stderr, "old_write_ascii_item: bad type = %d\n", type);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<old_write_ascii_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0x7,%eax
ja     130e <old_write_ascii_item+0x1ee>
mov    -0x78(%rbp),%rax
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xe6d(%rip),%rsi
call   1030 <fprintf@plt>
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movswl (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xe39(%rip),%rsi
call   1030 <fprintf@plt>
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movzwl (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xe05(%rip),%rsi
call   1030 <fprintf@plt>
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xdd2(%rip),%rsi
call   1030 <fprintf@plt>
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x68(%rbp),%edx
lea    0xda3(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x68(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
cvttsd2si -0x70(%rbp),%edx
lea    0xd67(%rip),%rsi
call   1030 <fprintf@plt>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
cvttsd2si -0x70(%rbp),%edx
lea    0xd2e(%rip),%rsi
call   1030 <fprintf@plt>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1331 <old_write_ascii_item+0x211>
mov    0x2ccb(%rip),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd0a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<old_write_ascii_item>:
push   %rbx
sub    $0x10,%rsp
lea    -0x1(%rdx),%eax
cmp    $0x7,%eax
ja     11bc <old_write_ascii_item+0x9c>
lea    0xec8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl (%rsi),%ebx
jmp    1157 <old_write_ascii_item+0x37>
mov    (%rsi),%ebx
jmp    1157 <old_write_ascii_item+0x37>
movzbl (%rsi),%ebx
jmp    1157 <old_write_ascii_item+0x37>
movzwl (%rsi),%ebx
jmp    1157 <old_write_ascii_item+0x37>
movswl (%rsi),%ebx
lea    0xec2(%rip),%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
cvtsi2sd %ebx,%xmm0
jmp    11b6 <old_write_ascii_item+0x96>
mov    (%rsi),%ebx
lea    0xeb0(%rip),%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
cvtsi2sd %rbx,%xmm0
jmp    11b6 <old_write_ascii_item+0x96>
movss  (%rsi),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
cvttss2si %xmm0,%edx
jmp    11a4 <old_write_ascii_item+0x84>
movsd  (%rsi),%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%edx
lea    0xe7d(%rip),%rsi
call   1030 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e1d(%rip),%rax
mov    (%rax),%rdi
lea    0xe5f(%rip),%rsi
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 = [37 x i8] c"old_write_ascii_item: bad type = %d\0A\00"
define double @old_write_ascii_item(i32* %0, i8* %1, i32 %2) {
%4 = alloca double
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i16*
%11 = alloca i16*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca float*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%19 = load i32, i32* %7
switch i32 %19, label %103 [
i32 1, label %20
i32 4, label %30
i32 2, label %40
i32 5, label %51
i32 3, label %62
i32 6, label %72
i32 7, label %82
i32 8, label %93
]
20: ; preds = %3
%21 = load i8*, i8** %6
store i8* %21, i8** %9
%22 = load i8*, i8** %9
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
store i32 %24, i32* %16
%25 = load i32*, i32** %5
%26 = load i32, i32* %16
%27 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %16
%29 = sitofp i32 %28 to double
store double %29, double* %4
br label %108
30: ; preds = %3
%31 = load i8*, i8** %6
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
store i32 %34, i32* %16
%35 = load i32*, i32** %5
%36 = load i32, i32* %16
%37 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %16
%39 = sitofp i32 %38 to double
store double %39, double* %4
br label %108
40: ; preds = %3
%41 = load i8*, i8** %6
%42 = bitcast i8* %41 to i16*
store i16* %42, i16** %10
%43 = load i16*, i16** %10
%44 = load i16, i16* %43
%45 = sext i16 %44 to i32
store i32 %45, i32* %16
%46 = load i32*, i32** %5
%47 = load i32, i32* %16
%48 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %16
%50 = sitofp i32 %49 to double
store double %50, double* %4
br label %108
51: ; preds = %3
%52 = load i8*, i8** %6
%53 = bitcast i8* %52 to i16*
store i16* %53, i16** %11
%54 = load i16*, i16** %11
%55 = load i16, i16* %54
%56 = zext i16 %55 to i32
store i32 %56, i32* %16
%57 = load i32*, i32** %5
%58 = load i32, i32* %16
%59 = call i32 @fprintf(i32* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %16
%61 = sitofp i32 %60 to double
store double %61, double* %4
br label %108
62: ; preds = %3
%63 = load i8*, i8** %6
%64 = bitcast i8* %63 to i32*
store i32* %64, i32** %12
%65 = load i32*, i32** %12
%66 = load i32, i32* %65
store i32 %66, i32* %16
%67 = load i32*, i32** %5
%68 = load i32, i32* %16
%69 = call i32 @fprintf(i32* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %16
%71 = sitofp i32 %70 to double
store double %71, double* %4
br label %108
72: ; preds = %3
%73 = load i8*, i8** %6
%74 = bitcast i8* %73 to i32*
store i32* %74, i32** %13
%75 = load i32*, i32** %13
%76 = load i32, i32* %75
store i32 %76, i32* %17
%77 = load i32*, i32** %5
%78 = load i32, i32* %17
%79 = call i32 @fprintf(i32* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %17
%81 = uitofp i32 %80 to double
store double %81, double* %4
br label %108
82: ; preds = %3
%83 = load i8*, i8** %6
%84 = bitcast i8* %83 to float*
store float* %84, float** %14
%85 = load float*, float** %14
%86 = load float, float* %85
%87 = fpext float %86 to double
store double %87, double* %18
%88 = load i32*, i32** %5
%89 = load double, double* %18
%90 = fptosi double %89 to i32
%91 = call i32 @fprintf(i32* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = load double, double* %18
store double %92, double* %4
br label %108
93: ; preds = %3
%94 = load i8*, i8** %6
%95 = bitcast i8* %94 to double*
store double* %95, double** %15
%96 = load double*, double** %15
%97 = load double, double* %96
store double %97, double* %18
%98 = load i32*, i32** %5
%99 = load double, double* %18
%100 = fptosi double %99 to i32
%101 = call i32 @fprintf(i32* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %100)
%102 = load double, double* %18
store double %102, double* %4
br label %108
103: ; preds = %3
%104 = load i32*, i32** @stderr
%105 = load i32, i32* %7
%106 = call i32 @fprintf(i32* %104, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %105)
%107 = call i32 @exit(i32 -1)
unreachable
108: ; preds = %93, %82, %72, %62, %51, %40, %30, %20
%109 = load double, double* %4
ret double %109
}

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