#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 IndexEntry {
  int dummy;
};
typedef int int64_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ quickSortFile(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 struct IndexEntry *, int);
int sortFile(FILE *file, struct IndexEntry *sortBuffer, int64_t bufcount) {
  fseek(file, 0L, SEEK_END);
  int64_t size = ftell(file);
  if (size % (8 + 6) != 0)
    return 0;
  int64_t numEntries = size / (8 + 6);
  quickSortFile(file, 0, numEntries - 1, sortBuffer, bufcount);
  return 1;
}


x86 assembly (clang, -O0):
<sortFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ftell@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0xe,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1185 <sortFile+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <sortFile+0x83>
mov    -0x20(%rbp),%eax
mov    $0xe,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
xor    %esi,%esi
call   1050 <quickSortFile@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sortFile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rbp,%rdi
call   1030 <ftell@plt>
imul   $0xb6db6db7,%eax,%ecx
add    $0x12492492,%ecx
ror    %ecx
cmp    $0x12492492,%ecx
ja     11a2 <sortFile+0x72>
movslq %eax,%rcx
imul   $0xffffffff92492493,%rcx,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x3,%edx
add    %eax,%edx
add    $0xffffffff,%edx
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r15,%rcx
mov    %r14d,%r8d
call   1050 <quickSortFile@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.IndexEntry = type { i32 }
@SEEK_END = global i32 0
define i32 @sortFile(i32* %0, %struct.IndexEntry* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.IndexEntry*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store %struct.IndexEntry* %1, %struct.IndexEntry** %6
store i32 %2, i32* %7
%10 = load i32*, i32** %5
%11 = load i32, i32* @SEEK_END
%12 = call i32 @fseek(i32* %10, i64 0, i32 %11)
%13 = load i32*, i32** %5
%14 = call i32 @ftell(i32* %13)
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = srem i32 %15, 14
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 0, i32* %4
br label %28
19: ; preds = %3
%20 = load i32, i32* %8
%21 = sdiv i32 %20, 14
store i32 %21, i32* %9
%22 = load i32*, i32** %5
%23 = load i32, i32* %9
%24 = sub nsw i32 %23, 1
%25 = load %struct.IndexEntry*, %struct.IndexEntry** %6
%26 = load i32, i32* %7
%27 = call i32 @quickSortFile(i32* %22, i32 0, i32 %24, %struct.IndexEntry* %25, i32 %26)
store i32 1, i32* %4
br label %28
28: ; preds = %19, %18
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
%struct.IndexEntry = type { i32 }
@SEEK_END = global i32 0
define i32 @sortFile(i32* %0, %struct.IndexEntry* %1, i32 %2) {
%4 = load i32, i32* @SEEK_END
%5 = tail call i32 @fseek(i32* %0, i64 0, i32 %4)
%6 = tail call i32 @ftell(i32* %0)
%7 = srem i32 %6, 14
%8 = sdiv i32 %6, 14
%9 = icmp eq i32 %7, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = add nsw i32 %8, -1
%12 = tail call i32 @quickSortFile(i32* %0, i32 0, i32 %11, %struct.IndexEntry* %1, i32 %2)
br label %13
13: ; preds = %3, %10
%14 = phi i32 [ 1, %10 ], [ 0, %3 ]
ret i32 %14
}