#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 *, float);
void abc(void *a, int b) {
  if (b == 1)
    printf("%d", *(int *)a);
  else if (b == 2)
    printf("%c", *(char *)a);
  else if (b == 3)
    printf("%f", *(float *)a);
}


x86 assembly (clang, -O0):
<abc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1142 <abc+0x32>
mov    -0x8(%rbp),%rax
cvtsi2ssl (%rax),%xmm0
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
jmp    1190 <abc+0x80>
cmpl   $0x2,-0xc(%rbp)
jne    1168 <abc+0x58>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cvtsi2ss %eax,%xmm0
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <abc+0x7b>
cmpl   $0x3,-0xc(%rbp)
jne    1186 <abc+0x76>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <abc+0x7b>
jmp    1190 <abc+0x80>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abc>:
cmp    $0x3,%esi
je     112f <abc+0x1f>
cmp    $0x2,%esi
je     113f <abc+0x2f>
cmp    $0x1,%esi
jne    1152 <abc+0x42>
cvtsi2ssl (%rdi),%xmm0
lea    0xed6(%rip),%rdi
jmp    1030 <printf@plt>
movss  (%rdi),%xmm0
lea    0xecc(%rip),%rdi
jmp    1030 <printf@plt>
movsbl (%rdi),%eax
cvtsi2ss %eax,%xmm0
lea    0xeb6(%rip),%rdi
jmp    1030 <printf@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"%f\00"
define void @abc(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = sitofp i32 %10 to float
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %11)
br label %31
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sitofp i8 %18 to float
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %19)
br label %30
21: ; preds = %13
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i8*, i8** %3
%26 = bitcast i8* %25 to float*
%27 = load float, float* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float %27)
br label %29
29: ; preds = %24, %21
br label %30
30: ; preds = %29, %16
br label %31
31: ; preds = %30, %7
ret void
}

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