#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 memcmp(char *, char *, int);
double strtod(char const *, char **);
int general_numcompare(const char *sa, const char *sb) {
  char *ea;
  char *eb;
  double a = strtod(sa, &ea);
  double b = strtod(sb, &eb);
  if (sa == ea)
    return sb == eb ? 0 : -1;
  if (sb == eb)
    return 1;
  return (a < b    ? -1
          : a > b  ? 1
          : a == b ? 0
          : b == b ? -1
          : a == a ? 1
                   : memcmp((char *)&a, (char *)&b, sizeof a));
}


x86 assembly (clang, -O0):
<general_numcompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    117f <general_numcompare+0x5f>
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rsi
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    %rsi,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1270 <general_numcompare+0x150>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    1199 <general_numcompare+0x79>
movl   $0x1,-0x4(%rbp)
jmp    1270 <general_numcompare+0x150>
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ba <general_numcompare+0x9a>
mov    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    126a <general_numcompare+0x14a>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11d7 <general_numcompare+0xb7>
mov    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1264 <general_numcompare+0x144>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    11f7 <general_numcompare+0xd7>
jp     11f7 <general_numcompare+0xd7>
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
jmp    125e <general_numcompare+0x13e>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    121a <general_numcompare+0xfa>
jp     121a <general_numcompare+0xfa>
mov    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
jmp    1258 <general_numcompare+0x138>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    123d <general_numcompare+0x11d>
jp     123d <general_numcompare+0x11d>
mov    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1252 <general_numcompare+0x132>
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<general_numcompare>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x20(%rsp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1030 <strtod@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rsp),%rcx
cmp    %rbx,0x20(%rsp)
je     117d <general_numcompare+0x5d>
mov    $0x1,%eax
cmp    %r14,%rcx
je     11a4 <general_numcompare+0x84>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1189 <general_numcompare+0x69>
mov    $0xffffffff,%eax
jmp    11a4 <general_numcompare+0x84>
xor    %eax,%eax
cmp    %r14,%rcx
setne  %al
neg    %eax
jmp    11a4 <general_numcompare+0x84>
ucomisd %xmm0,%xmm1
ja     11a4 <general_numcompare+0x84>
xor    %eax,%eax
ucomisd %xmm0,%xmm1
jne    1199 <general_numcompare+0x79>
jnp    11a4 <general_numcompare+0x84>
ucomisd %xmm0,%xmm0
mov    $0xffffffff,%eax
jp     11ac <general_numcompare+0x8c>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
ucomisd %xmm1,%xmm1
mov    $0x1,%eax
jnp    11a4 <general_numcompare+0x84>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
jmp    11a4 <general_numcompare+0x84>

LLVM IR (-O0):
define i32 @general_numcompare(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca double
%9 = alloca double
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = call double @strtod(i8* %10, i8** %6)
store double %11, double* %8
%12 = load i8*, i8** %5
%13 = call double @strtod(i8* %12, i8** %7)
store double %13, double* %9
%14 = load i8*, i8** %4
%15 = load i8*, i8** %6
%16 = icmp eq i8* %14, %15
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = load i8*, i8** %7
%20 = icmp eq i8* %18, %19
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 0, i32 -1
store i32 %22, i32* %3
br label %67
23: ; preds = %2
%24 = load i8*, i8** %5
%25 = load i8*, i8** %7
%26 = icmp eq i8* %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %3
br label %67
28: ; preds = %23
%29 = load double, double* %8
%30 = load double, double* %9
%31 = fcmp olt double %29, %30
br i1 %31, label %32, label %33
32: ; preds = %28
br label %65
33: ; preds = %28
%34 = load double, double* %8
%35 = load double, double* %9
%36 = fcmp ogt double %34, %35
br i1 %36, label %37, label %38
37: ; preds = %33
br label %63
38: ; preds = %33
%39 = load double, double* %8
%40 = load double, double* %9
%41 = fcmp oeq double %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
br label %61
43: ; preds = %38
%44 = load double, double* %9
%45 = load double, double* %9
%46 = fcmp oeq double %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
br label %59
48: ; preds = %43
%49 = load double, double* %8
%50 = load double, double* %8
%51 = fcmp oeq double %49, %50
br i1 %51, label %52, label %53
52: ; preds = %48
br label %57
53: ; preds = %48
%54 = bitcast double* %8 to i8*
%55 = bitcast double* %9 to i8*
%56 = call i32 @memcmp(i8* %54, i8* %55, i32 8)
br label %57
57: ; preds = %53, %52
%58 = phi i32 [ 1, %52 ], [ %56, %53 ]
br label %59
59: ; preds = %57, %47
%60 = phi i32 [ -1, %47 ], [ %58, %57 ]
br label %61
61: ; preds = %59, %42
%62 = phi i32 [ 0, %42 ], [ %60, %59 ]
br label %63
63: ; preds = %61, %37
%64 = phi i32 [ 1, %37 ], [ %62, %61 ]
br label %65
65: ; preds = %63, %32
%66 = phi i32 [ -1, %32 ], [ %64, %63 ]
store i32 %66, i32* %3
br label %67
67: ; preds = %65, %27, %17
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
define i32 @general_numcompare(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = bitcast i8** %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = call double @strtod(i8* %0, i8** %3)
store double %10, double* %5
%11 = bitcast double* %6 to i8*
%12 = call double @strtod(i8* %1, i8** %4)
store double %12, double* %6
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, %0
%15 = load i8*, i8** %4
br i1 %14, label %16, label %19
16: ; preds = %2
%17 = icmp ne i8* %15, %1
%18 = sext i1 %17 to i32
br label %33
19: ; preds = %2
%20 = icmp eq i8* %15, %1
br i1 %20, label %33, label %21
21: ; preds = %19
%22 = fcmp olt double %10, %12
br i1 %22, label %33, label %23
23: ; preds = %21
%24 = fcmp ogt double %10, %12
br i1 %24, label %33, label %25
25: ; preds = %23
%26 = fcmp oeq double %10, %12
br i1 %26, label %33, label %27
27: ; preds = %25
%28 = fcmp ord double %12, 0.000000e+00
br i1 %28, label %33, label %29
29: ; preds = %27
%30 = fcmp ord double %10, 0.000000e+00
br i1 %30, label %33, label %31
31: ; preds = %29
%32 = call i32 @memcmp(i8* %9, i8* %11, i32 8)
br label %33
33: ; preds = %21, %25, %31, %29, %27, %23, %19, %16
%34 = phi i32 [ %18, %16 ], [ 1, %19 ], [ -1, %21 ], [ 1, %23 ], [ 0, %25 ], [ -1, %27 ], [ %32, %31 ], [ 1, %29 ]
ret i32 %34
}