int _bin_double(const void *a, const void *b) {
  double b0, b1;
  b0 = (*(double *)a - *(double *)b);
  b1 = (*(double *)a - *((double *)b + 1));
  return (int)(((b0 >= 0) - (b0 < 0)) + ((b1 >= 0) - (b1 < 0)));
}


x86 assembly (clang, -O0):
<_bin_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
sub    %ecx,%eax
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %cl
and    $0x1,%cl
movzbl %cl,%ecx
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
seta   %dl
and    $0x1,%dl
movzbl %dl,%edx
sub    %edx,%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_bin_double>:
movsd  (%rdi),%xmm0
movapd %xmm0,%xmm1
subsd  (%rsi),%xmm1
subsd  0x8(%rsi),%xmm0
xorpd  %xmm2,%xmm2
xor    %eax,%eax
ucomisd %xmm2,%xmm1
setae  %al
xor    %ecx,%ecx
ucomisd %xmm1,%xmm2
seta   %cl
xor    %edx,%edx
ucomisd %xmm0,%xmm2
seta   %dl
sub    %ecx,%eax
ucomisd %xmm2,%xmm0
sbb    $0xffffffff,%eax
sub    %edx,%eax
ret

LLVM IR (-O0):
define i32 @_bin_double(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*
%9 = load double, double* %8
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to double*
%12 = load double, double* %11
%13 = fsub double %9, %12
store double %13, double* %5
%14 = load i8*, i8** %3
%15 = bitcast i8* %14 to double*
%16 = load double, double* %15
%17 = load i8*, i8** %4
%18 = bitcast i8* %17 to double*
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fsub double %16, %20
store double %21, double* %6
%22 = load double, double* %5
%23 = fcmp oge double %22, 0.000000e+00
%24 = zext i1 %23 to i32
%25 = load double, double* %5
%26 = fcmp olt double %25, 0.000000e+00
%27 = zext i1 %26 to i32
%28 = sub nsw i32 %24, %27
%29 = load double, double* %6
%30 = fcmp oge double %29, 0.000000e+00
%31 = zext i1 %30 to i32
%32 = load double, double* %6
%33 = fcmp olt double %32, 0.000000e+00
%34 = zext i1 %33 to i32
%35 = sub nsw i32 %31, %34
%36 = add nsw i32 %28, %35
ret i32 %36
}

LLVM IR (-O2):
define i32 @_bin_double(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to double*
%4 = load double, double* %3
%5 = bitcast i8* %1 to double*
%6 = load double, double* %5
%7 = fsub double %4, %6
%8 = getelementptr inbounds i8, i8* %1, i64 8
%9 = bitcast i8* %8 to double*
%10 = load double, double* %9
%11 = fsub double %4, %10
%12 = fcmp oge double %7, 0.000000e+00
%13 = zext i1 %12 to i32
%14 = fcmp olt double %7, 0.000000e+00
%15 = sext i1 %14 to i32
%16 = fcmp oge double %11, 0.000000e+00
%17 = zext i1 %16 to i32
%18 = fcmp olt double %11, 0.000000e+00
%19 = sext i1 %18 to i32
%20 = add nsw i32 %15, %13
%21 = add nsw i32 %20, %17
%22 = add nsw i32 %21, %19
ret i32 %22
}