#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 /*<<< orphan*/ sortstr(char *, char *, int);
int numcmp(char *s1, char *s2) {
  double v1, v2;
  char str[5000];
  sortstr(s1, str, 5000);
  v1 = atof(s1);
  sortstr(s2, str, 5000);
  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    $0x13b0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x13b0(%rbp),%rsi
mov    $0x1388,%edx
call   1040 <sortstr@plt>
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x13b0(%rbp),%rsi
mov    $0x1388,%edx
call   1040 <sortstr@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    1199 <numcmp+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <numcmp+0x9c>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b5 <numcmp+0x95>
movl   $0x1,-0x4(%rbp)
jmp    11bc <numcmp+0x9c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x13b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numcmp>:
push   %r15
push   %r14
push   %rbx
sub    $0x13a0,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%r15
mov    %r15,%rsi
mov    $0x1388,%edx
call   1040 <sortstr@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1388,%edx
call   1040 <sortstr@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    $0x13a0,%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 [5000 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [5000 x i8], [5000 x i8]* %8, i64 0, i64 0
%11 = call i32 @sortstr(i8* %9, i8* %10, i32 5000)
%12 = load i8*, i8** %4
%13 = call double @atof(i8* %12)
store double %13, double* %6
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [5000 x i8], [5000 x i8]* %8, i64 0, i64 0
%16 = call i32 @sortstr(i8* %14, i8* %15, i32 5000)
%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 [5000 x i8]
%4 = getelementptr inbounds [5000 x i8], [5000 x i8]* %3, i64 0, i64 0
%5 = call i32 @sortstr(i8* %0, i8* %4, i32 5000)
%6 = call double @atof(i8* %0)
%7 = call i32 @sortstr(i8* %1, i8* %4, i32 5000)
%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
}