double xcmpl(x, y)
double x, y;
{
  double ans;
  ans = -2.0;
  if (x == y) {
    printf("x == y ");
    ans = 0.0;
  }
  if (x < y) {
    printf("x < y");
    ans = -1.0;
  }
  if (x > y) {
    printf("x > y");
    ans = 1.0;
  }
  return (ans);
}


x86 assembly (clang, -O0):
<xcmpl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xed6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    115b <xcmpl+0x4b>
jp     115b <xcmpl+0x4b>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118a <xcmpl+0x7a>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b5 <xcmpl+0xa5>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  0xe60(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcmpl>:
sub    $0x18,%rsp
ucomisd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
jne    1194 <xcmpl+0x84>
jp     1194 <xcmpl+0x84>
lea    0xee9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm1
jbe    116e <xcmpl+0x5e>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
movsd  0xe9a(%rip),%xmm0
ucomisd %xmm1,%xmm2
ja     1179 <xcmpl+0x69>
add    $0x18,%rsp
ret
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0xe81(%rip),%xmm0
add    $0x18,%rsp
ret
movapd %xmm0,%xmm2
movsd  0xe60(%rip),%xmm0
ucomisd %xmm2,%xmm1
ja     114c <xcmpl+0x3c>
jmp    116e <xcmpl+0x5e>

LLVM IR (-O0):
@.str = [8 x i8] c"x == y \00"
@.str.1 = [6 x i8] c"x < y\00"
@.str.2 = [6 x i8] c"x > y\00"
define double @xcmpl(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
store double -2.000000e+00, double* %5
%6 = load double, double* %3
%7 = load double, double* %4
%8 = fcmp oeq double %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %5
br label %11
11: ; preds = %9, %2
%12 = load double, double* %3
%13 = load double, double* %4
%14 = fcmp olt double %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store double -1.000000e+00, double* %5
br label %17
17: ; preds = %15, %11
%18 = load double, double* %3
%19 = load double, double* %4
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store double 1.000000e+00, double* %5
br label %23
23: ; preds = %21, %17
%24 = load double, double* %5
ret double %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"x == y \00"
@.str.1 = [6 x i8] c"x < y\00"
@.str.2 = [6 x i8] c"x > y\00"
define double @xcmpl(double %0, double %1) {
%3 = fcmp oeq double %0, %1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = phi double [ 0.000000e+00, %4 ], [ -2.000000e+00, %2 ]
%8 = fcmp olt double %0, %1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = phi double [ -1.000000e+00, %9 ], [ %7, %6 ]
%13 = fcmp ogt double %0, %1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = phi double [ 1.000000e+00, %14 ], [ %12, %11 ]
ret double %17
}