#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int getNumEntries(FILE *in_file) {
  char bin_cache[4];
  int *offset_cache, num_entries;
  fseek(in_file, 0, SEEK_SET);
  fread(bin_cache, 1, 4, in_file);
  offset_cache = (int *)&bin_cache;
  num_entries = (*offset_cache) / 4;
  printf("Offset list ends at: 0x%x\n", (*offset_cache));
  printf("Number of entries: %d\n", num_entries - 1);
  return num_entries;
}


x86 assembly (clang, -O0):
<getNumEntries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
lea    -0xc(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumEntries>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    0xc(%rsp),%esi
lea    0x3(%rsi),%ebx
test   %esi,%esi
cmovns %esi,%ebx
sar    $0x2,%ebx
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1(%rbx),%esi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [27 x i8] c"Offset list ends at: 0x%x\0A\00"
@.str.1 = [23 x i8] c"Number of entries: %d\0A\00"
define i32 @getNumEntries(i32* %0) {
%2 = alloca i32*
%3 = alloca [4 x i8]
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = load i32, i32* @SEEK_SET
%8 = call i32 @fseek(i32* %6, i32 0, i32 %7)
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32 @fread(i8* %9, i32 1, i32 4, i32* %10)
%12 = bitcast [4 x i8]* %3 to i32*
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = sdiv i32 %14, 4
store i32 %15, i32* %5
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [27 x i8] c"Offset list ends at: 0x%x\0A\00"
@.str.1 = [23 x i8] c"Number of entries: %d\0A\00"
define i32 @getNumEntries(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 0, i32 %4)
%6 = call i32 @fread(i8* %3, i32 1, i32 4, i32* %0)
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = add nsw i32 %8, -1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %10)
ret i32 %8
}