#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_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(unsigned char *, int, unsigned long,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
unsigned long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ hash(unsigned long, unsigned char *, unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void readfile_aeshash(FILE *pFile, unsigned char *key) {
  unsigned long len;
  unsigned char *pBuf;
  fseek(pFile, 0, SEEK_END);
  len = ftell(pFile);
  pBuf = (unsigned char *)malloc(sizeof(unsigned char) * (len + 1));
  rewind(pFile);
  fread(pBuf, 1, len, pFile);
  pBuf[len] = 0;
  hash(len, pBuf, key);
  fclose(pFile);
  return;
}


x86 assembly (clang, -O0):
<readfile_aeshash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <hash@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readfile_aeshash>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r15,%rdi
call   1070 <ftell@plt>
mov    %rax,%rbx
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1060 <rewind@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1030 <fread@plt>
movb   $0x0,(%r12,%rbx,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <hash@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@SEEK_END = global i32 0
define void @readfile_aeshash(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i32*, i32** %3
%8 = load i32, i32* @SEEK_END
%9 = call i32 @fseek(i32* %7, i32 0, i32 %8)
%10 = load i32*, i32** %3
%11 = call i64 @ftell(i32* %10)
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = add i64 %12, 1
%14 = mul i64 1, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %6
%18 = load i32*, i32** %3
%19 = call i32 @rewind(i32* %18)
%20 = load i8*, i8** %6
%21 = load i64, i64* %5
%22 = load i32*, i32** %3
%23 = call i32 @fread(i8* %20, i32 1, i64 %21, i32* %22)
%24 = load i8*, i8** %6
%25 = load i64, i64* %5
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8 0, i8* %26
%27 = load i64, i64* %5
%28 = load i8*, i8** %6
%29 = load i8*, i8** %4
%30 = call i32 @hash(i64 %27, i8* %28, i8* %29)
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
ret void
}

LLVM IR (-O2):
@SEEK_END = global i32 0
define void @readfile_aeshash(i32* nocapture %0, i8* %1) {
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %0, i32 0, i32 %3)
%5 = tail call i64 @ftell(i32* %0)
%6 = trunc i64 %5 to i32
%7 = add i32 %6, 1
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 @rewind(i32* %0)
%11 = tail call i32 @fread(i8* %9, i32 1, i64 %5, i32* %0)
%12 = getelementptr inbounds i8, i8* %9, i64 %5
store i8 0, i8* %12
%13 = tail call i32 @hash(i64 %5, i8* %9, i8* %1)
%14 = tail call i32 @fclose(i32* %0)
ret void
}