#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 print(char t, void *data) {
  switch (t) {
  case 0:
    printf("%d", *(short *)data);
    break;
  case 1:
    printf("%f", *(float *)data);
    break;
  case 2:
    printf("%s", (char *)data);
    break;
  }
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1158 <print+0x48>
jmp    1136 <print+0x26>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1172 <print+0x62>
jmp    1147 <print+0x37>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1191 <print+0x81>
jmp    11a3 <print+0x93>
mov    -0x10(%rbp),%rax
movswl (%rax),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a3 <print+0x93>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11a3 <print+0x93>
mov    -0x10(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
cmp    $0x2,%edi
je     112f <print+0x1f>
cmp    $0x1,%edi
je     113d <print+0x2d>
test   %edi,%edi
jne    1153 <print+0x43>
movswl (%rsi),%esi
lea    0xed8(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
movss  (%rsi),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb7(%rip),%rdi
mov    $0x1,%al
jmp    1030 <printf@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [3 x i8] c"%s\00"
define void @print(i8 signext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
store i8 %0, i8* %3
store i8* %1, i8** %4
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
switch i32 %6, label %22 [
i32 0, label %7
i32 1, label %13
i32 2, label %19
]
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i16*
%10 = load i16, i16* %9
%11 = sext i16 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %22
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to float*
%16 = load float, float* %15
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %17)
br label %22
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %2, %19, %13, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [3 x i8] c"%s\00"
define void @print(i8 signext %0, i8* %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %16 [
i32 0, label %4
i32 1, label %9
i32 2, label %14
]
4: ; preds = %2
%5 = bitcast i8* %1 to i16*
%6 = load i16, i16* %5
%7 = sext i16 %6 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %16
9: ; preds = %2
%10 = bitcast i8* %1 to float*
%11 = load float, float* %10
%12 = fpext float %11 to double
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %12)
br label %16
14: ; preds = %2
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %16
16: ; preds = %2, %14, %9, %4
ret void
}