#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned char);
int print_file(char *filename) {
  FILE *fp;
  fp = fopen(filename, "r");
  if (fp == NULL)
    return -1;
  int i;
  unsigned char tmp;
  for (i = 0; i < (48 * 64 / 8); i++) {
    tmp = 0;
    fread(&tmp, 1, 1, fp);
    printf("0x%X, ", tmp);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<print_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1177 <print_file+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d1 <print_file+0x91>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x180,-0x1c(%rbp)
jge    11c1 <print_file+0x81>
movb   $0x0,-0x1d(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x1d(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
lea    0xe58(%rip),%rdi
movzbl -0x1d(%rbp),%esi
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <print_file+0x3e>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a8 <print_file+0x68>
mov    %rax,%rbx
mov    $0x180,%ebp
lea    0x7(%rsp),%r14
lea    0xe96(%rip),%r15
nopl   0x0(%rax)
movb   $0x0,0x7(%rsp)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movzbl 0x7(%rsp),%esi
mov    %r15,%rdi
call   1050 <printf@plt>
add    $0xffffffff,%ebp
jne    1170 <print_file+0x30>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11ad <print_file+0x6d>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"0x%X, \00"
define i32 @print_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %27
12: ; preds = %1
store i32 0, i32* %5
br label %13
13: ; preds = %21, %12
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 384
br i1 %15, label %16, label %24
16: ; preds = %13
store i8 0, i8* %6
%17 = load i32*, i32** %4
%18 = call i32 @fread(i8* %6, i32 1, i32 1, i32* %17)
%19 = load i8, i8* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %13
24: ; preds = %13
%25 = load i32*, i32** %4
%26 = call i32 @fclose(i32* %25)
store i32 0, i32* %2
br label %27
27: ; preds = %24, %11
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"0x%X, \00"
define i32 @print_file(i8* nocapture %0) {
%2 = alloca i8
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %15, label %5
5: ; preds = %1
br label %6
6: ; preds = %5, %6
%7 = phi i32 [ 0, %5 ], [ %11, %6 ]
store i8 0, i8* %2
%8 = call i32 @fread(i8* %2, i32 1, i32 1, i32* %3)
%9 = load i8, i8* %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %9)
%11 = add nuw nsw i32 %7, 1
%12 = icmp eq i32 %11, 384
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = tail call i32 @fclose(i32* %3)
br label %15
15: ; preds = %1, %13
%16 = phi i32 [ 0, %13 ], [ -1, %1 ]
ret i32 %16
}