#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 floor(double);
char *func(int inputval) {
  int temp = floor((double)inputval / 10);
  switch (temp) {
  case (0):
    return "foo";
    break;
  case (1):
    return "bar";
    break;
  case (2):
    return "baz";
    break;
  default:
    return "other";
  }
}


x86 assembly (clang, -O0):
<func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xed8(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1169 <func+0x59>
jmp    1147 <func+0x37>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1179 <func+0x69>
jmp    1158 <func+0x48>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1189 <func+0x79>
jmp    1199 <func+0x89>
lea    0xe98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <func+0x94>
lea    0xe8c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <func+0x94>
lea    0xe80(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <func+0x94>
lea    0xe74(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func>:
push   %rax
cvtsi2sd %edi,%xmm0
divsd  0xee3(%rip),%xmm0
call   1030 <floor@plt>
cmp    $0x2,%eax
ja     1139 <func+0x29>
cltq
lea    0xeec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xed4(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [4 x i8] c"baz\00"
@.str.3 = [6 x i8] c"other\00"
define i8* @func(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = sitofp i32 %5 to double
%7 = fdiv double %6, 1.000000e+01
%8 = call i32 @floor(double %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
switch i32 %9, label %13 [
i32 0, label %10
i32 1, label %11
i32 2, label %12
]
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %14
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %14
12: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %14
13: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %14
14: ; preds = %13, %12, %11, %10
%15 = load i8*, i8** %2
ret i8* %15
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [4 x i8] c"baz\00"
@.str.3 = [6 x i8] c"other\00"
@reltable.func = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.func to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.func to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.func to i64)) to i32)]
define i8* @func(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fdiv double %2, 1.000000e+01
%4 = tail call i32 @floor(double %3)
%5 = icmp ult i32 %4, 3
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.func to i8*), i64 %8)
br label %10
10: ; preds = %1, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %1 ]
ret i8* %11
}