#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 */
struct dirent {
  char *d_name;
};

/* Variables and functions */
long strtol(char const *, char **, int);
int numsort(const struct dirent **file1, const struct dirent **file2) {
  const char *a = (*file1)->d_name;
  const char *b = (*file2)->d_name;
  char *ptr;
  long num_a = strtol(a, &ptr, 10);
  long num_b = strtol(b, &ptr, 10);
  return num_a > num_b ? 1 : (num_a == num_b ? 0 : -1);
}


x86 assembly (clang, -O0):
<numsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jle    1183 <numsort+0x73>
mov    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119b <numsort+0x8b>
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rsi
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    %rsi,%rdx
cmove  %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numsort>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%rax
mov    (%rax),%rdi
mov    (%rsi),%rax
mov    (%rax),%r15
lea    0x8(%rsp),%r14
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
xor    %ecx,%ecx
cmp    %rax,%rbx
setne  %cl
neg    %ecx
cmp    %rax,%rbx
mov    $0x1,%eax
cmovle %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
define i32 @numsort(%struct.dirent** %0, %struct.dirent** %1) {
%3 = alloca %struct.dirent**
%4 = alloca %struct.dirent**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
store %struct.dirent** %0, %struct.dirent*** %3
store %struct.dirent** %1, %struct.dirent*** %4
%10 = load %struct.dirent**, %struct.dirent*** %3
%11 = load %struct.dirent*, %struct.dirent** %10
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i32 0, i32 0
%13 = load i8*, i8** %12
store i8* %13, i8** %5
%14 = load %struct.dirent**, %struct.dirent*** %4
%15 = load %struct.dirent*, %struct.dirent** %14
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i32 0, i32 0
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %5
%19 = call i64 @strtol(i8* %18, i8** %7, i32 10)
store i64 %19, i64* %8
%20 = load i8*, i8** %6
%21 = call i64 @strtol(i8* %20, i8** %7, i32 10)
store i64 %21, i64* %9
%22 = load i64, i64* %8
%23 = load i64, i64* %9
%24 = icmp sgt i64 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %2
br label %32
26: ; preds = %2
%27 = load i64, i64* %8
%28 = load i64, i64* %9
%29 = icmp eq i64 %27, %28
%30 = zext i1 %29 to i64
%31 = select i1 %29, i32 0, i32 -1
br label %32
32: ; preds = %26, %25
%33 = phi i32 [ 1, %25 ], [ %31, %26 ]
ret i32 %33
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
define i32 @numsort(%struct.dirent** nocapture %0, %struct.dirent** nocapture %1) {
%3 = alloca i8*
%4 = load %struct.dirent*, %struct.dirent** %0
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i64 0, i32 0
%6 = load i8*, i8** %5
%7 = load %struct.dirent*, %struct.dirent** %1
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = bitcast i8** %3 to i8*
%11 = call i64 @strtol(i8* %6, i8** %3, i32 10)
%12 = call i64 @strtol(i8* %9, i8** %3, i32 10)
%13 = icmp sgt i64 %11, %12
%14 = icmp ne i64 %11, %12
%15 = sext i1 %14 to i32
%16 = select i1 %13, i32 1, i32 %15
ret i32 %16
}