#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 */
unsigned long strtoul(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int util_scandir_hexsort(const struct dirent **de1, const struct dirent **de2) {
  unsigned long val1 = strtoul((*de1)->d_name, NULL, 16);
  unsigned long val2 = strtoul((*de2)->d_name, NULL, 16);
  if (val1 < val2)
    return -1;
  if (val1 == val2)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<util_scandir_hexsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1170 <util_scandir_hexsort+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <util_scandir_hexsort+0x81>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    118a <util_scandir_hexsort+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    1191 <util_scandir_hexsort+0x81>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_scandir_hexsort>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %rax,%rbx
mov    (%r14),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtoul@plt>
xor    %ecx,%ecx
cmp    %rax,%rbx
setne  %cl
mov    $0xffffffff,%eax
cmovae %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
define i32 @util_scandir_hexsort(%struct.dirent** %0, %struct.dirent** %1) {
%3 = alloca i32
%4 = alloca %struct.dirent**
%5 = alloca %struct.dirent**
%6 = alloca i64
%7 = alloca i64
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 i64 @strtoul(i32 %11, i32* null, i32 16)
store i64 %12, i64* %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 i64 @strtoul(i32 %16, i32* null, i32 16)
store i64 %17, i64* %7
%18 = load i64, i64* %6
%19 = load i64, i64* %7
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %2
store i32 -1, i32* %3
br label %28
22: ; preds = %2
%23 = load i64, i64* %6
%24 = load i64, i64* %7
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 0, 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 @util_scandir_hexsort(%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 i64 @strtoul(i32 %5, i32* null, i32 16)
%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 i64 @strtoul(i32 %9, i32* null, i32 16)
%11 = icmp ult i64 %6, %10
%12 = icmp ne i64 %6, %10
%13 = zext i1 %12 to i32
%14 = select i1 %11, i32 -1, i32 %13
ret i32 %14
}