#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 */
double atof(char *);
int numeric_cmp(char *a, char *b, bool reverse) {
  double a_val = atof(a);
  double b_val = atof(b);
  if (a_val < b_val) {
    return (reverse ? 1 : -1);
  } else if (a_val > b_val) {
    return (reverse ? -1 : 1);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<numeric_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    116e <numeric_cmp+0x5e>
mov    -0x1c(%rbp),%edx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <numeric_cmp+0x90>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1199 <numeric_cmp+0x89>
mov    -0x1c(%rbp),%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <numeric_cmp+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numeric_cmp>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <atof@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    113a <numeric_cmp+0x2a>
cmp    $0x1,%ebp
jmp    1144 <numeric_cmp+0x34>
xor    %eax,%eax
ucomisd %xmm0,%xmm1
jbe    1149 <numeric_cmp+0x39>
neg    %ebp
sbb    %eax,%eax
or     $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @numeric_cmp(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = call double @atof(i8* %10)
store double %11, double* %8
%12 = load i8*, i8** %6
%13 = call double @atof(i8* %12)
store double %13, double* %9
%14 = load double, double* %8
%15 = load double, double* %9
%16 = fcmp olt double %14, %15
br i1 %16, label %17, label %22
17: ; preds = %3
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 1, i32 -1
store i32 %21, i32* %4
br label %32
22: ; preds = %3
%23 = load double, double* %8
%24 = load double, double* %9
%25 = fcmp ogt double %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 -1, i32 1
store i32 %30, i32* %4
br label %32
31: ; preds = %22
store i32 0, i32* %4
br label %32
32: ; preds = %31, %26, %17
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @numeric_cmp(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = tail call double @atof(i8* %0)
%5 = tail call double @atof(i8* %1)
%6 = fcmp olt double %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = icmp eq i32 %2, 0
%9 = select i1 %8, i32 -1, i32 1
br label %15
10: ; preds = %3
%11 = fcmp ogt double %4, %5
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = icmp eq i32 %2, 0
%14 = select i1 %13, i32 1, i32 -1
br label %15
15: ; preds = %10, %12, %7
%16 = phi i32 [ %9, %7 ], [ %14, %12 ], [ 0, %10 ]
ret i32 %16
}