#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 */
typedef scalar_t__ time_t;
struct dirent {
  int /*<<< orphan*/ d_name;
};
typedef int clock_t;

/* Variables and functions */
int /*<<< orphan*/ getTimeClockFromName(int /*<<< orphan*/, scalar_t__ *,
                                        int *);
int binlogsort(const struct dirent **app, const struct dirent **bpp) {
  time_t timea, timeb;
  clock_t clocka, clockb;
  getTimeClockFromName((*app)->d_name, &timea, &clocka);
  getTimeClockFromName((*bpp)->d_name, &timeb, &clockb);
  return timea == timeb ? clocka - clockb : timea - timeb;
}


x86 assembly (clang, -O0):
<binlogsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1030 <getTimeClockFromName@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <getTimeClockFromName@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    116b <binlogsort+0x5b>
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
cltq
mov    %rax,-0x30(%rbp)
jmp    1177 <binlogsort+0x67>
mov    -0x18(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binlogsort>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    (%rdi),%rax
mov    (%rax),%edi
lea    0x18(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1030 <getTimeClockFromName@plt>
mov    (%rbx),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <getTimeClockFromName@plt>
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%rdx
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
mov    %ecx,%eax
sub    %edx,%eax
cmp    %rdx,%rcx
cmove  %esi,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
define i32 @binlogsort(%struct.dirent** %0, %struct.dirent** %1) {
%3 = alloca %struct.dirent**
%4 = alloca %struct.dirent**
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store %struct.dirent** %0, %struct.dirent*** %3
store %struct.dirent** %1, %struct.dirent*** %4
%9 = load %struct.dirent**, %struct.dirent*** %3
%10 = load %struct.dirent*, %struct.dirent** %9
%11 = getelementptr inbounds %struct.dirent, %struct.dirent* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @getTimeClockFromName(i32 %12, i64* %5, i32* %7)
%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 i32, i32* %16
%18 = call i32 @getTimeClockFromName(i32 %17, i64* %6, i32* %8)
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %2
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = sub nsw i32 %23, %24
%26 = sext i32 %25 to i64
br label %31
27: ; preds = %2
%28 = load i64, i64* %5
%29 = load i64, i64* %6
%30 = sub nsw i64 %28, %29
br label %31
31: ; preds = %27, %22
%32 = phi i64 [ %26, %22 ], [ %30, %27 ]
%33 = trunc i64 %32 to i32
ret i32 %33
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
define i32 @binlogsort(%struct.dirent** nocapture %0, %struct.dirent** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = load %struct.dirent*, %struct.dirent** %0
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @getTimeClockFromName(i32 %13, i64* %3, i32* %5)
%15 = load %struct.dirent*, %struct.dirent** %1
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @getTimeClockFromName(i32 %17, i64* %4, i32* %6)
%19 = load i64, i64* %3
%20 = load i64, i64* %4
%21 = icmp eq i64 %19, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = sub nsw i32 %22, %23
%25 = zext i32 %24 to i64
%26 = sub nsw i64 %19, %20
%27 = select i1 %21, i64 %25, i64 %26
%28 = trunc i64 %27 to i32
ret i32 %28
}