#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ format(char *, char *, int, int);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
void dump(const char *filename) {
  FILE *infile;
  char inbuf[16] = {0};
  char outbuf[75];
  int bytes = 0;
  int totalBytes = 0;
  infile = fopen(filename, "rb");
  if (infile == NULL) {
    return;
  }
  printf("%s:\n", filename);
  while (!feof(infile)) {
    bytes = fread(inbuf, 1, 16, infile);
    format(inbuf, outbuf, bytes, totalBytes);
    printf("%s\n", outbuf);
    totalBytes += bytes;
  }
  fclose(infile);
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c1 <dump+0x51>
jmp    1243 <dump+0xd3>
mov    -0x8(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ef <dump+0x7f>
jmp    123a <dump+0xca>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
mov    %eax,-0x74(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
mov    -0x78(%rbp),%ecx
call   1080 <format@plt>
lea    -0x70(%rbp),%rsi
lea    0xde1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x74(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x78(%rbp)
jmp    11d1 <dump+0x61>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1207 <dump+0xa7>
mov    %rax,%r13
lea    0xe70(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11ff <dump+0x9f>
xor    %ebp,%ebp
mov    %rsp,%r14
lea    0x10(%rsp),%r15
lea    0xe50(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
call   1070 <format@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
add    %ebx,%ebp
mov    %r13,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11c0 <dump+0x60>
mov    %r13,%rdi
call   1040 <fclose@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [5 x i8] c"%s:\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @dump(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [16 x i8]
%5 = alloca [75 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = bitcast [16 x i8]* %4 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
%9 = load i8*, i8** %2
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
br label %39
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %22, %14
%18 = load i32*, i32** %3
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %36
22: ; preds = %17
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%24 = load i32*, i32** %3
%25 = call i32 @fread(i8* %23, i32 1, i32 16, i32* %24)
store i32 %25, i32* %6
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%27 = getelementptr inbounds [75 x i8], [75 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @format(i8* %26, i8* %27, i32 %28, i32 %29)
%31 = getelementptr inbounds [75 x i8], [75 x i8]* %5, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = add nsw i32 %34, %33
store i32 %35, i32* %7
br label %17
36: ; preds = %17
%37 = load i32*, i32** %3
%38 = call i32 @fclose(i32* %37)
br label %39
39: ; preds = %36, %13
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [5 x i8] c"%s:\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @dump(i8* %0) {
%2 = alloca [16 x i8]
%3 = alloca [75 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [75 x i8], [75 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %22, label %8
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = call i32 @feof(i32* %6)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %8, %12
%13 = phi i32 [ %17, %12 ], [ 0, %8 ]
%14 = call i32 @fread(i8* %4, i32 1, i32 16, i32* %6)
%15 = call i32 @format(i8* %4, i8* %5, i32 %14, i32 %13)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%17 = add nsw i32 %14, %13
%18 = call i32 @feof(i32* %6)
%19 = icmp eq i32 %18, 0
br i1 %19, label %12, label %20
20: ; preds = %12, %8
%21 = call i32 @fclose(i32* %6)
br label %22
22: ; preds = %1, %20
ret void
}