#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 {
  int /*<<< orphan*/ d_name;
};

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int num_sort(const struct dirent **a, const struct dirent **b) {
  int ia = atoi((*a)->d_name);
  int ib = atoi((*b)->d_name);
  if (ia == ib) {
    return 0;
  }
  if (ia < ib) {
    return -1;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<num_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1030 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1030 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    115a <num_sort+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1179 <num_sort+0x69>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1172 <num_sort+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    1179 <num_sort+0x69>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_sort>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rdi),%rax
mov    (%rax),%edi
call   1030 <atoi@plt>
mov    %eax,%ebp
mov    (%rbx),%rax
mov    (%rax),%edi
call   1030 <atoi@plt>
xor    %ecx,%ecx
xor    %edx,%edx
cmp    %eax,%ebp
setge  %dl
lea    -0x1(%rdx,%rdx,1),%eax
cmove  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
define i32 @num_sort(%struct.dirent** %0, %struct.dirent** %1) {
%3 = alloca i32
%4 = alloca %struct.dirent**
%5 = alloca %struct.dirent**
%6 = alloca i32
%7 = alloca i32
store %struct.dirent** %0, %struct.dirent*** %4
store %struct.dirent** %1, %struct.dirent*** %5
%8 = load %struct.dirent**, %struct.dirent*** %4
%9 = load %struct.dirent*, %struct.dirent** %8
%10 = getelementptr inbounds %struct.dirent, %struct.dirent* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @atoi(i32 %11)
store i32 %12, i32* %6
%13 = load %struct.dirent**, %struct.dirent*** %5
%14 = load %struct.dirent*, %struct.dirent** %13
%15 = getelementptr inbounds %struct.dirent, %struct.dirent* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @atoi(i32 %16)
store i32 %17, i32* %7
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %2
store i32 0, i32* %3
br label %28
22: ; preds = %2
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 -1, i32* %3
br label %28
27: ; preds = %22
store i32 1, i32* %3
br label %28
28: ; preds = %27, %26, %21
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
define i32 @num_sort(%struct.dirent** nocapture %0, %struct.dirent** nocapture %1) {
%3 = load %struct.dirent*, %struct.dirent** %0
%4 = getelementptr inbounds %struct.dirent, %struct.dirent* %3, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i32 @atoi(i32 %5)
%7 = load %struct.dirent*, %struct.dirent** %1
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @atoi(i32 %9)
%11 = icmp eq i32 %6, %10
%12 = icmp slt i32 %6, %10
%13 = select i1 %12, i32 -1, i32 1
%14 = select i1 %11, i32 0, i32 %13
ret i32 %14
}