#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 fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdout;
void print_file(char *fileName) {
  FILE *f;
  int bread = 0;
  char buff[1024];
  f = fopen(fileName, "r");
  if (f == NULL) {
    printf("Cannot open file %s\n", fileName);
    return;
  } else
    printf("%s - OK\n", fileName);
  while ((bread = fread(buff, 1, 1024, f)) > 0) {
    fwrite(buff, 1, bread, stdout);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<print_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119a <print_file+0x4a>
mov    -0x8(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
jmp    1200 <print_file+0xb0>
mov    -0x8(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
jmp    11af <print_file+0x5f>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    11f7 <print_file+0xa7>
lea    -0x420(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    0x2dfa(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
jmp    11af <print_file+0x5f>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f0 <print_file+0xa0>
mov    %rax,%r14
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jle    11db <print_file+0x8b>
mov    0x2e3a(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jg     11b0 <print_file+0x60>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe0b(%rip),%rdi
mov    %rbx,%rsi
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.2 = [9 x i8] c"%s - OK\0A\00"
@stdout = global i32 0
define void @print_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [1024 x i8]
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %30
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13
br label %17
17: ; preds = %22, %16
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = load i32*, i32** %3
%20 = call i32 @fread(i8* %18, i32 1, i32 1024, i32* %19)
store i32 %20, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* %4
%25 = load i32, i32* @stdout
%26 = call i32 @fwrite(i8* %23, i32 1, i32 %24, i32 %25)
br label %17
27: ; preds = %17
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
br label %30
30: ; preds = %27, %10
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.2 = [9 x i8] c"%s - OK\0A\00"
@stdout = global i32 0
define void @print_file(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %20
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%10 = call i32 @fread(i8* %3, i32 1, i32 1024, i32* %4)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8, %12
%13 = phi i32 [ %16, %12 ], [ %10, %8 ]
%14 = load i32, i32* @stdout
%15 = call i32 @fwrite(i8* %3, i32 1, i32 %13, i32 %14)
%16 = call i32 @fread(i8* %3, i32 1, i32 1024, i32* %4)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %12, label %18
18: ; preds = %12, %8
%19 = call i32 @fclose(i32* %4)
br label %20
20: ; preds = %18, %6
ret void
}