#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 const *);
int /*<<< orphan*/ substr(char const *, char *);
int numcmp(const char *s1, const char *s2) {
  double v1;
  double v2;
  char str[1000];
  substr(s1, str);
  v1 = atof(s1);
  substr(s2, str);
  v2 = atof(s2);
  if (v1 < v2)
    return -1;
  else if (v1 > v2)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<numcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <substr@plt>
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <substr@plt>
mov    -0x18(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118f <numcmp+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b2 <numcmp+0x92>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11ab <numcmp+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <numcmp+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numcmp>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%r15
mov    %r15,%rsi
call   1040 <substr@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <substr@plt>
mov    %r14,%rdi
call   1030 <atof@plt>
xor    %ecx,%ecx
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %cl
ucomisd %xmm1,%xmm0
mov    $0xffffffff,%eax
cmovbe %ecx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @numcmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca double
%8 = alloca [1000 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%11 = call i32 @substr(i8* %9, i8* %10)
%12 = load i8*, i8** %4
%13 = call double @atof(i8* %12)
store double %13, double* %6
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%16 = call i32 @substr(i8* %14, i8* %15)
%17 = load i8*, i8** %5
%18 = call double @atof(i8* %17)
store double %18, double* %7
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %23
22: ; preds = %2
store i32 -1, i32* %3
br label %29
23: ; preds = %2
%24 = load double, double* %6
%25 = load double, double* %7
%26 = fcmp ogt double %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %3
br label %29
28: ; preds = %23
store i32 0, i32* %3
br label %29
29: ; preds = %28, %27, %22
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @numcmp(i8* %0, i8* %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @substr(i8* %0, i8* %4)
%6 = call double @atof(i8* %0)
%7 = call i32 @substr(i8* %1, i8* %4)
%8 = call double @atof(i8* %1)
%9 = fcmp olt double %6, %8
%10 = fcmp ogt double %6, %8
%11 = zext i1 %10 to i32
%12 = select i1 %9, i32 -1, i32 %11
ret i32 %12
}