int roxml_double_cmp(double a, double b, int op) {
  if (op == 7)
    return (a != b);
  else if (op == 5)
    return (a <= b);
  else if (op == 3)
    return (a < b);
  else if (op == 6)
    return (a >= b);
  else if (op == 4)
    return (a > b);
  else if (op == 8)
    return (a == b);
  return 0;
}


x86 assembly (clang, -O0):
<roxml_double_cmp>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jne    113a <roxml_double_cmp+0x3a>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
setne  %al
setp   %cl
or     %cl,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <roxml_double_cmp+0x11b>
cmpl   $0x5,-0x1c(%rbp)
jne    1162 <roxml_double_cmp+0x62>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <roxml_double_cmp+0x11b>
cmpl   $0x3,-0x1c(%rbp)
jne    118a <roxml_double_cmp+0x8a>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <roxml_double_cmp+0x11b>
cmpl   $0x6,-0x1c(%rbp)
jne    11ae <roxml_double_cmp+0xae>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <roxml_double_cmp+0x11b>
cmpl   $0x4,-0x1c(%rbp)
jne    11d2 <roxml_double_cmp+0xd2>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <roxml_double_cmp+0x11b>
cmpl   $0x8,-0x1c(%rbp)
jne    11fb <roxml_double_cmp+0xfb>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <roxml_double_cmp+0x11b>
jmp    1200 <roxml_double_cmp+0x100>
jmp    1205 <roxml_double_cmp+0x105>
jmp    120a <roxml_double_cmp+0x10a>
jmp    120f <roxml_double_cmp+0x10f>
jmp    1214 <roxml_double_cmp+0x114>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<roxml_double_cmp>:
add    $0xfffffffd,%edi
cmp    $0x5,%edi
ja     111e <roxml_double_cmp+0x1e>
lea    0xef1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
ucomisd %xmm0,%xmm1
jmp    1128 <roxml_double_cmp+0x28>
xor    %eax,%eax
movzbl %al,%eax
ret
ucomisd %xmm1,%xmm0
seta   %al
movzbl %al,%eax
ret
ucomisd %xmm0,%xmm1
jmp    1139 <roxml_double_cmp+0x39>
ucomisd %xmm1,%xmm0
setae  %al
movzbl %al,%eax
ret
cmpneqsd %xmm1,%xmm0
jmp    114c <roxml_double_cmp+0x4c>
cmpeqsd %xmm1,%xmm0
movq   %xmm0,%rax
and    $0x1,%eax
movzbl %al,%eax
ret

LLVM IR (-O0):
define i32 @roxml_double_cmp(double %0, double %1, i32 %2) {
%4 = alloca i32
%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, 7
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fcmp une double %11, %12
%14 = zext i1 %13 to i32
store i32 %14, i32* %4
br label %61
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 5
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load double, double* %5
%20 = load double, double* %6
%21 = fcmp ole double %19, %20
%22 = zext i1 %21 to i32
store i32 %22, i32* %4
br label %61
23: ; preds = %15
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load double, double* %5
%28 = load double, double* %6
%29 = fcmp olt double %27, %28
%30 = zext i1 %29 to i32
store i32 %30, i32* %4
br label %61
31: ; preds = %23
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 6
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load double, double* %5
%36 = load double, double* %6
%37 = fcmp oge double %35, %36
%38 = zext i1 %37 to i32
store i32 %38, i32* %4
br label %61
39: ; preds = %31
%40 = load i32, i32* %7
%41 = icmp eq i32 %40, 4
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load double, double* %5
%44 = load double, double* %6
%45 = fcmp ogt double %43, %44
%46 = zext i1 %45 to i32
store i32 %46, i32* %4
br label %61
47: ; preds = %39
%48 = load i32, i32* %7
%49 = icmp eq i32 %48, 8
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load double, double* %5
%52 = load double, double* %6
%53 = fcmp oeq double %51, %52
%54 = zext i1 %53 to i32
store i32 %54, i32* %4
br label %61
55: ; preds = %47
br label %56
56: ; preds = %55
br label %57
57: ; preds = %56
br label %58
58: ; preds = %57
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59
store i32 0, i32* %4
br label %61
61: ; preds = %60, %50, %42, %34, %26, %18, %10
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
define i32 @roxml_double_cmp(double %0, double %1, i32 %2) {
switch i32 %2, label %16 [
i32 7, label %4
i32 5, label %6
i32 3, label %8
i32 6, label %10
i32 4, label %12
i32 8, label %14
]
4: ; preds = %3
%5 = fcmp une double %0, %1
br label %16
6: ; preds = %3
%7 = fcmp ole double %0, %1
br label %16
8: ; preds = %3
%9 = fcmp olt double %0, %1
br label %16
10: ; preds = %3
%11 = fcmp oge double %0, %1
br label %16
12: ; preds = %3
%13 = fcmp ogt double %0, %1
br label %16
14: ; preds = %3
%15 = fcmp oeq double %0, %1
br label %16
16: ; preds = %3, %14, %12, %10, %8, %6, %4
%17 = phi i1 [ %5, %4 ], [ %7, %6 ], [ %9, %8 ], [ %11, %10 ], [ %13, %12 ], [ %15, %14 ], [ false, %3 ]
%18 = zext i1 %17 to i32
ret i32 %18
}