double roxml_double_oper(double a, double b, int op) {
  if (op == 9)
    return (a + b);
  else if (op == 10)
    return (a - b);
  else if (op == 11)
    return (a * b);
  else if (op == 12)
    return (a / b);
  return 0;
}


x86 assembly (clang, -O0):
<roxml_double_oper>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jne    112f <roxml_double_oper+0x2f>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a0 <roxml_double_oper+0xa0>
cmpl   $0xa,-0x1c(%rbp)
jne    114d <roxml_double_oper+0x4d>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a0 <roxml_double_oper+0xa0>
cmpl   $0xb,-0x1c(%rbp)
jne    116b <roxml_double_oper+0x6b>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a0 <roxml_double_oper+0xa0>
cmpl   $0xc,-0x1c(%rbp)
jne    1189 <roxml_double_oper+0x89>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a0 <roxml_double_oper+0xa0>
jmp    118e <roxml_double_oper+0x8e>
jmp    1193 <roxml_double_oper+0x93>
jmp    1198 <roxml_double_oper+0x98>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<roxml_double_oper>:
add    $0xfffffff7,%edi
cmp    $0x3,%edi
ja     111d <roxml_double_oper+0x1d>
lea    0xef1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
addsd  %xmm1,%xmm0
ret
xorps  %xmm0,%xmm0
ret
subsd  %xmm1,%xmm0
ret
mulsd  %xmm1,%xmm0
ret
divsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @roxml_double_oper(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 9
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fadd double %11, %12
store double %13, double* %4
br label %39
14: ; preds = %3
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load double, double* %5
%19 = load double, double* %6
%20 = fsub double %18, %19
store double %20, double* %4
br label %39
21: ; preds = %14
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 11
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load double, double* %5
%26 = load double, double* %6
%27 = fmul double %25, %26
store double %27, double* %4
br label %39
28: ; preds = %21
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 12
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load double, double* %5
%33 = load double, double* %6
%34 = fdiv double %32, %33
store double %34, double* %4
br label %39
35: ; preds = %28
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
store double 0.000000e+00, double* %4
br label %39
39: ; preds = %38, %31, %24, %17, %10
%40 = load double, double* %4
ret double %40
}

LLVM IR (-O2):
define double @roxml_double_oper(double %0, double %1, i32 %2) {
switch i32 %2, label %12 [
i32 9, label %4
i32 10, label %6
i32 11, label %8
i32 12, label %10
]
4: ; preds = %3
%5 = fadd double %0, %1
br label %12
6: ; preds = %3
%7 = fsub double %0, %1
br label %12
8: ; preds = %3
%9 = fmul double %0, %1
br label %12
10: ; preds = %3
%11 = fdiv double %0, %1
br label %12
12: ; preds = %3, %10, %8, %6, %4
%13 = phi double [ %5, %4 ], [ %7, %6 ], [ %9, %8 ], [ %11, %10 ], [ 0.000000e+00, %3 ]
ret double %13
}