#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 *, ...);
int testSwitch(float val1, char oper, float val2) {
  switch (oper) {
  case '+':
    printf("%.2f\n", val1 + val2);
    break;
  case '-':
    printf("%.2f\n", val1 - val2);
    break;
  case '*':
    printf("%.2f\n", val1 * val2);
    break;
  case '/':
    if (val2 == 0)
      printf("Division by zero.\n");
    else
      printf("%.2f\n", val1 / val2);
    break;
  default:
    printf("Unknown operator.\n");
    break;
  }
  return (0);
}


x86 assembly (clang, -O0):
<testSwitch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
movss  %xmm0,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movss  %xmm1,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     1200 <testSwitch+0xf0>
mov    -0x18(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x4(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    120e <testSwitch+0xfe>
movss  -0x4(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe90(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    120e <testSwitch+0xfe>
movss  -0x4(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    120e <testSwitch+0xfe>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11df <testSwitch+0xcf>
jp     11df <testSwitch+0xcf>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <testSwitch+0xeb>
movss  -0x4(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    120e <testSwitch+0xfe>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testSwitch>:
push   %rax
add    $0xffffffd6,%edi
cmp    $0x5,%edi
ja     1145 <testSwitch+0x25>
lea    0xed0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mulss  %xmm1,%xmm0
jmp    1170 <testSwitch+0x50>
addss  %xmm1,%xmm0
jmp    1170 <testSwitch+0x50>
lea    0xee4(%rip),%rdi
jmp    1165 <testSwitch+0x45>
subss  %xmm1,%xmm0
jmp    1170 <testSwitch+0x50>
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jne    116c <testSwitch+0x4c>
jp     116c <testSwitch+0x4c>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
jmp    1182 <testSwitch+0x62>
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.2f\0A\00"
@.str.1 = [19 x i8] c"Division by zero.\0A\00"
@.str.2 = [19 x i8] c"Unknown operator.\0A\00"
define i32 @testSwitch(float %0, i8 signext %1, float %2) {
%4 = alloca float
%5 = alloca i8
%6 = alloca float
store float %0, float* %4
store i8 %1, i8* %5
store float %2, float* %6
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
switch i32 %8, label %39 [
i32 43, label %9
i32 45, label %15
i32 42, label %21
i32 47, label %27
]
9: ; preds = %3
%10 = load float, float* %4
%11 = load float, float* %6
%12 = fadd float %10, %11
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %13)
br label %41
15: ; preds = %3
%16 = load float, float* %4
%17 = load float, float* %6
%18 = fsub float %16, %17
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %19)
br label %41
21: ; preds = %3
%22 = load float, float* %4
%23 = load float, float* %6
%24 = fmul float %22, %23
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %25)
br label %41
27: ; preds = %3
%28 = load float, float* %6
%29 = fcmp oeq float %28, 0.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %38
32: ; preds = %27
%33 = load float, float* %4
%34 = load float, float* %6
%35 = fdiv float %33, %34
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %36)
br label %38
38: ; preds = %32, %30
br label %41
39: ; preds = %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39, %38, %21, %15, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.2f\0A\00"
@str = [18 x i8] c"Division by zero.\00"
@str.3 = [18 x i8] c"Unknown operator.\00"
define i32 @testSwitch(float %0, i8 signext %1, float %2) {
%4 = sext i8 %1 to i32
switch i32 %4, label %25 [
i32 43, label %5
i32 45, label %9
i32 42, label %13
i32 47, label %17
]
5: ; preds = %3
%6 = fadd float %0, %2
%7 = fpext float %6 to double
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %7)
br label %27
9: ; preds = %3
%10 = fsub float %0, %2
%11 = fpext float %10 to double
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %11)
br label %27
13: ; preds = %3
%14 = fmul float %0, %2
%15 = fpext float %14 to double
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %15)
br label %27
17: ; preds = %3
%18 = fcmp oeq float %2, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %27
21: ; preds = %17
%22 = fdiv float %0, %2
%23 = fpext float %22 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %23)
br label %27
25: ; preds = %3
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
br label %27
27: ; preds = %19, %21, %25, %13, %9, %5
ret i32 0
}