int compare_keys(double *key1, double *key2) {
  int return_Val = 1;
  if (key1[0] < key2[0]) {
    return_Val = -1;
  } else if (key1[0] == key2[0] && key1[1] < key2[1]) {
    return_Val = -1;
  } else if (key1[0] == key2[0] && key1[1] == key2[1]) {
    return_Val = 0;
  }
  return return_Val;
}


x86 assembly (clang, -O0):
<compare_keys>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1139 <compare_keys+0x39>
movl   $0xffffffff,-0x14(%rbp)
jmp    11c8 <compare_keys+0xc8>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
jne    117d <compare_keys+0x7d>
jp     117d <compare_keys+0x7d>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    117d <compare_keys+0x7d>
movl   $0xffffffff,-0x14(%rbp)
jmp    11c3 <compare_keys+0xc3>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
jne    11be <compare_keys+0xbe>
jp     11be <compare_keys+0xbe>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
ucomisd 0x8(%rax),%xmm0
jne    11be <compare_keys+0xbe>
jp     11be <compare_keys+0xbe>
movl   $0x0,-0x14(%rbp)
jmp    11c3 <compare_keys+0xc3>
jmp    11c8 <compare_keys+0xc8>
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_keys>:
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm1
mov    $0xffffffff,%eax
ucomisd %xmm0,%xmm1
ja     113a <compare_keys+0x3a>
ucomisd %xmm1,%xmm0
jne    113b <compare_keys+0x3b>
jp     113b <compare_keys+0x3b>
movsd  0x8(%rdi),%xmm0
movsd  0x8(%rsi),%xmm1
ucomisd %xmm0,%xmm1
ja     113a <compare_keys+0x3a>
ucomisd %xmm1,%xmm0
mov    $0x1,%eax
jne    113a <compare_keys+0x3a>
jp     113a <compare_keys+0x3a>
xor    %eax,%eax
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @compare_keys(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
store i32 1, i32* %5
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = load double*, double** %4
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = fcmp olt double %8, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %5
br label %50
14: ; preds = %2
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = fcmp oeq double %17, %20
br i1 %21, label %22, label %31
22: ; preds = %14
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = fcmp olt double %25, %28
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 -1, i32* %5
br label %49
31: ; preds = %22, %14
%32 = load double*, double** %3
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = fcmp oeq double %34, %37
br i1 %38, label %39, label %48
39: ; preds = %31
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = fcmp oeq double %42, %45
br i1 %46, label %47, label %48
47: ; preds = %39
store i32 0, i32* %5
br label %48
48: ; preds = %47, %39, %31
br label %49
49: ; preds = %48, %30
br label %50
50: ; preds = %49, %13
%51 = load i32, i32* %5
ret i32 %51
}

LLVM IR (-O2):
define i32 @compare_keys(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = load double, double* %1
%5 = fcmp olt double %3, %4
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = fcmp oeq double %3, %4
br i1 %7, label %8, label %17
8: ; preds = %6
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %1, i64 1
%12 = load double, double* %11
%13 = fcmp olt double %10, %12
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = fcmp oeq double %10, %12
br i1 %15, label %16, label %17
16: ; preds = %14
br label %17
17: ; preds = %6, %8, %2, %16, %14
%18 = phi i32 [ 0, %16 ], [ 1, %14 ], [ -1, %2 ], [ -1, %8 ], [ 1, %6 ]
ret i32 %18
}