#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*/ dump(unsigned char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fp;
  unsigned char buf[4096 * 3];
  if (fp = fopen(argv[1], "r")) {
    fread(buf, 1, 512, fp);
    dump(buf, 512 / 16);
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11af <main+0x6f>
lea    -0x3020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x200,%edx
call   1030 <fread@plt>
lea    -0x3020(%rbp),%rdi
mov    $0x20,%esi
call   1050 <dump@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x3020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3008,%rsp
mov    0x8(%rsi),%rdi
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     118f <main+0x4f>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x200,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <dump@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x3008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [12288 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = getelementptr inbounds [12288 x i8], [12288 x i8]* %7, i64 0, i64 0
%15 = load i32*, i32** %6
%16 = call i32 @fread(i8* %14, i32 1, i32 512, i32* %15)
%17 = getelementptr inbounds [12288 x i8], [12288 x i8]* %7, i64 0, i64 0
%18 = call i32 @dump(i8* %17, i32 32)
%19 = load i32*, i32** %6
%20 = call i32 @fclose(i32* %19)
br label %21
21: ; preds = %13, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12288 x i8]
%4 = getelementptr inbounds [12288 x i8], [12288 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = call i32 @fread(i8* %4, i32 1, i32 512, i32* %7)
%11 = call i32 @dump(i8* %4, i32 32)
%12 = call i32 @fclose(i32* %7)
br label %13
13: ; preds = %9, %2
ret i32 0
}