#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 */
double NAN;
double eval(char op, double d1, double d2) {
  switch (op) {
  case '+':
    return d1 + d2;
  case '-':
    return d1 - d2;
  case '*':
    return d1 * d2;
  case '/':
    return d1 / d2;
  default:
    return NAN;
  }
}


x86 assembly (clang, -O0):
<eval>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     118e <eval+0x8e>
mov    -0x28(%rbp),%rax
lea    0xecb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119e <eval+0x9e>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119e <eval+0x9e>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119e <eval+0x9e>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119e <eval+0x9e>
mov    0x2e63(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval>:
add    $0xffffffd6,%edi
cmp    $0x5,%edi
ja     1122 <eval+0x22>
lea    0xef1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mulsd  %xmm1,%xmm0
ret
addsd  %xmm1,%xmm0
ret
mov    0x2ecf(%rip),%rax
movsd  (%rax),%xmm0
ret
subsd  %xmm1,%xmm0
ret
divsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define double @eval(i8 signext %0, double %1, double %2) {
%4 = alloca double
%5 = alloca i8
%6 = alloca double
%7 = alloca double
store i8 %0, i8* %5
store double %1, double* %6
store double %2, double* %7
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
switch i32 %9, label %26 [
i32 43, label %10
i32 45, label %14
i32 42, label %18
i32 47, label %22
]
10: ; preds = %3
%11 = load double, double* %6
%12 = load double, double* %7
%13 = fadd double %11, %12
store double %13, double* %4
br label %28
14: ; preds = %3
%15 = load double, double* %6
%16 = load double, double* %7
%17 = fsub double %15, %16
store double %17, double* %4
br label %28
18: ; preds = %3
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fmul double %19, %20
store double %21, double* %4
br label %28
22: ; preds = %3
%23 = load double, double* %6
%24 = load double, double* %7
%25 = fdiv double %23, %24
store double %25, double* %4
br label %28
26: ; preds = %3
%27 = load double, double* @NAN
store double %27, double* %4
br label %28
28: ; preds = %26, %22, %18, %14, %10
%29 = load double, double* %4
ret double %29
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
define double @eval(i8 signext %0, double %1, double %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %13 [
i32 43, label %5
i32 45, label %7
i32 42, label %9
i32 47, label %11
]
5: ; preds = %3
%6 = fadd double %1, %2
br label %15
7: ; preds = %3
%8 = fsub double %1, %2
br label %15
9: ; preds = %3
%10 = fmul double %1, %2
br label %15
11: ; preds = %3
%12 = fdiv double %1, %2
br label %15
13: ; preds = %3
%14 = load double, double* @NAN
br label %15
15: ; preds = %13, %11, %9, %7, %5
%16 = phi double [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
ret double %16
}