#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*/ printf(char *, ...);
void printData(int type, void *data) {
  switch (type) {
  case 0x00000001:
    printf("%d", *(int *)data);
    return;
  case 0x00000002:
    printf("%hd", *(short *)data);
    return;
  case 0x00000004:
    printf("%f", *(float *)data);
    return;
  case 0x00000008:
    printf("%f", *(double *)data);
    return;
  case 0x00000010:
    printf("%ld", *(long *)data);
    return;
  case 0x00000020:
    printf("%lld", *(long long *)data);
    return;
  case 0x00000040:
    printf("%c", *(char *)data);
    return;
  case 0x00000080:
    printf("%s", (char *)data);
    return;
  }
}


x86 assembly (clang, -O0):
<printData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     11ac <printData+0x9c>
jmp    1133 <printData+0x23>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11c5 <printData+0xb5>
jmp    1144 <printData+0x34>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     11df <printData+0xcf>
jmp    1155 <printData+0x45>
mov    -0x14(%rbp),%eax
sub    $0x8,%eax
je     11fe <printData+0xee>
jmp    1166 <printData+0x56>
mov    -0x14(%rbp),%eax
sub    $0x10,%eax
je     1219 <printData+0x109>
jmp    1177 <printData+0x67>
mov    -0x14(%rbp),%eax
sub    $0x20,%eax
je     1233 <printData+0x123>
jmp    1188 <printData+0x78>
mov    -0x14(%rbp),%eax
sub    $0x40,%eax
je     124d <printData+0x13d>
jmp    1199 <printData+0x89>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
je     1267 <printData+0x157>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
movswl (%rax),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xdfa(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <printData+0x169>
mov    -0x10(%rbp),%rsi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printData>:
lea    -0x1(%rdi),%eax
cmp    $0x3f,%eax
ja     1148 <printData+0x28>
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    (%rsi),%esi
lea    0xfbf(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
cmp    $0x80,%edi
jne    115e <printData+0x3e>
lea    0xfbc(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
ret
movswl (%rsi),%esi
lea    0xf9a(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
movss  (%rsi),%xmm0
cvtss2sd %xmm0,%xmm0
jmp    117e <printData+0x5e>
movsd  (%rsi),%xmm0
lea    0xf82(%rip),%rdi
mov    $0x1,%al
jmp    1040 <printf@plt>
mov    (%rsi),%rsi
lea    0xf74(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
mov    (%rsi),%rsi
lea    0xf67(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
movsbl (%rsi),%edi
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%hd\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [5 x i8] c"%lld\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [3 x i8] c"%s\00"
define void @printData(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %46 [
i32 1, label %6
i32 2, label %11
i32 4, label %17
i32 8, label %23
i32 16, label %28
i32 32, label %33
i32 64, label %38
i32 128, label %43
]
6: ; preds = %2
%7 = load i8*, i8** %4
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %46
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i16*
%14 = load i16, i16* %13
%15 = sext i16 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %46
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = bitcast i8* %18 to float*
%20 = load float, float* %19
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %46
23: ; preds = %2
%24 = load i8*, i8** %4
%25 = bitcast i8* %24 to double*
%26 = load double, double* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %46
28: ; preds = %2
%29 = load i8*, i8** %4
%30 = bitcast i8* %29 to i64*
%31 = load i64, i64* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %31)
br label %46
33: ; preds = %2
%34 = load i8*, i8** %4
%35 = bitcast i8* %34 to i64*
%36 = load i64, i64* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %36)
br label %46
38: ; preds = %2
%39 = load i8*, i8** %4
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %41)
br label %46
43: ; preds = %2
%44 = load i8*, i8** %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %6, %11, %17, %23, %28, %33, %38, %43, %2
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%hd\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [5 x i8] c"%lld\00"
@.str.6 = [3 x i8] c"%s\00"
define void @printData(i32 %0, i8* %1) {
switch i32 %0, label %35 [
i32 1, label %3
i32 2, label %7
i32 4, label %12
i32 8, label %17
i32 16, label %21
i32 32, label %25
i32 64, label %29
i32 128, label %33
]
3: ; preds = %2
%4 = bitcast i8* %1 to i32*
%5 = load i32, i32* %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %35
7: ; preds = %2
%8 = bitcast i8* %1 to i16*
%9 = load i16, i16* %8
%10 = sext i16 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %35
12: ; preds = %2
%13 = bitcast i8* %1 to float*
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %15)
br label %35
17: ; preds = %2
%18 = bitcast i8* %1 to double*
%19 = load double, double* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %19)
br label %35
21: ; preds = %2
%22 = bitcast i8* %1 to i64*
%23 = load i64, i64* %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %23)
br label %35
25: ; preds = %2
%26 = bitcast i8* %1 to i64*
%27 = load i64, i64* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %27)
br label %35
29: ; preds = %2
%30 = load i8, i8* %1
%31 = sext i8 %30 to i32
%32 = tail call i32 @putchar(i32 %31)
br label %35
33: ; preds = %2
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %1)
br label %35
35: ; preds = %3, %7, %12, %17, %21, %25, %29, %33, %2
ret void
}