#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double, double);
int compareDouble(void *pn, void *pm) {
  double n = *(double *)pn;
  double m = *(double *)pm;
  printf("comparing n = %f, m = %f\n", n, m);
  if (n < m) {
    return -1;
  } else if (n > m) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<compareDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1170 <compareDouble+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <compareDouble+0x83>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    118c <compareDouble+0x7c>
movl   $0x1,-0x4(%rbp)
jmp    1193 <compareDouble+0x83>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareDouble>:
sub    $0x18,%rsp
movsd  (%rdi),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsi),%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
xor    %ecx,%ecx
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
seta   %cl
ucomisd %xmm0,%xmm1
mov    $0xffffffff,%eax
cmovbe %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"comparing n = %f, m = %f\0A\00"
define i32 @compareDouble(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca double
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to double*
%10 = load double, double* %9
store double %10, double* %6
%11 = load i8*, i8** %5
%12 = bitcast i8* %11 to double*
%13 = load double, double* %12
store double %13, double* %7
%14 = load double, double* %6
%15 = load double, double* %7
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %14, double %15)
%17 = load double, double* %6
%18 = load double, double* %7
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 -1, i32* %3
br label %27
21: ; preds = %2
%22 = load double, double* %6
%23 = load double, double* %7
%24 = fcmp ogt double %22, %23
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 1, i32* %3
br label %27
26: ; preds = %21
store i32 0, i32* %3
br label %27
27: ; preds = %26, %25, %20
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [26 x i8] c"comparing n = %f, m = %f\0A\00"
define i32 @compareDouble(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 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %4, double %6)
%8 = fcmp olt double %4, %6
%9 = fcmp ogt double %4, %6
%10 = zext i1 %9 to i32
%11 = select i1 %8, i32 -1, i32 %10
ret i32 %11
}