int compare_tree_asc(const void *p1, const void *p2) {
  const double *x1 = (const double *)p1;
  const double *x2 = (const double *)p2;
  return (x1[1] > x2[1]) ? -1 : (x1[1] < x2[1]) ? 1 : (x1[0] >= x2[0]) ? -1 : 1;
}


x86 assembly (clang, -O0):
<compare_tree_asc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
ucomisd 0x8(%rax),%xmm0
jbe    1141 <compare_tree_asc+0x41>
mov    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <compare_tree_asc+0x94>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    116a <compare_tree_asc+0x6a>
mov    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118e <compare_tree_asc+0x8e>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_tree_asc>:
movsd  0x8(%rdi),%xmm0
movsd  0x8(%rsi),%xmm1
mov    $0xffffffff,%eax
ucomisd %xmm1,%xmm0
ja     1132 <compare_tree_asc+0x32>
mov    $0x1,%eax
ucomisd %xmm0,%xmm1
ja     1132 <compare_tree_asc+0x32>
movsd  (%rdi),%xmm0
xor    %eax,%eax
ucomisd (%rsi),%xmm0
setb   %al
add    %eax,%eax
add    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @compare_tree_asc(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double*
%6 = alloca double*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to double*
store double* %8, double** %5
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to double*
store double* %10, double** %6
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = load double*, double** %6
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = fcmp ogt double %13, %16
br i1 %17, label %18, label %19
18: ; preds = %2
br label %40
19: ; preds = %2
%20 = load double*, double** %5
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
%23 = load double*, double** %6
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = fcmp olt double %22, %25
br i1 %26, label %27, label %28
27: ; preds = %19
br label %38
28: ; preds = %19
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = load double*, double** %6
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = fcmp oge double %31, %34
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 -1, i32 1
br label %38
38: ; preds = %28, %27
%39 = phi i32 [ 1, %27 ], [ %37, %28 ]
br label %40
40: ; preds = %38, %18
%41 = phi i32 [ -1, %18 ], [ %39, %38 ]
ret i32 %41
}

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