#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 HashGen(unsigned char *, unsigned int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, unsigned int,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
unsigned int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ getchar();
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc < 2)
    return -1;
  FILE *in = fopen(argv[1], "rb");
  fseek(in, 0, 2);
  unsigned int fsz = ftell(in);
  rewind(in);
  unsigned char *buf = (unsigned char *)malloc(fsz);
  fread(buf, 1, fsz, in);
  printf("Hash : %08X\n", HashGen(buf, fsz));
  fclose(in);
  free(buf);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11dc <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe15(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x1c(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10d0 <HashGen@plt>
mov    %eax,%esi
lea    0xdb4(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
cmp    $0x2,%edi
jl     1248 <main+0x98>
mov    0x8(%rsi),%rdi
lea    0xe2f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
xor    %r14d,%r14d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   10b0 <fseek@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <rewind@plt>
mov    %ebp,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10d0 <HashGen@plt>
lea    0xdd9(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [13 x i8] c"Hash : %08X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %39
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = call i32 @fseek(i32* %17, i32 0, i32 2)
%19 = load i32*, i32** %6
%20 = call i32 @ftell(i32* %19)
store i32 %20, i32* %7
%21 = load i32*, i32** %6
%22 = call i32 @rewind(i32* %21)
%23 = load i32, i32* %7
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %8
%26 = load i8*, i8** %8
%27 = load i32, i32* %7
%28 = load i32*, i32** %6
%29 = call i32 @fread(i8* %26, i32 1, i32 %27, i32* %28)
%30 = load i8*, i8** %8
%31 = load i32, i32* %7
%32 = call i32 @HashGen(i8* %30, i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
%36 = load i8*, i8** %8
%37 = call i32 @free(i8* %36)
%38 = call i32 (...) @getchar()
store i32 0, i32* %3
br label %39
39: ; preds = %12, %11
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [13 x i8] c"Hash : %08X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @fseek(i32* %7, i32 0, i32 2)
%9 = tail call i32 @ftell(i32* %7)
%10 = tail call i32 @rewind(i32* %7)
%11 = tail call i64 @malloc(i32 %9)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @fread(i8* %12, i32 1, i32 %9, i32* %7)
%14 = tail call i32 @HashGen(i8* %12, i32 %9)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @fclose(i32* %7)
%17 = tail call i32 @free(i8* %12)
%18 = tail call i32 (...) @getchar()
br label %19
19: ; preds = %2, %4
%20 = phi i32 [ 0, %4 ], [ -1, %2 ]
ret i32 %20
}