#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*/ decode(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void doFile(char *inName) {
  FILE *in;
  if (!(in = fopen(inName, "rb")))
    fprintf(stderr, "ERROR: Can't open %s - %s", inName, strerror(errno));
  decode(in);
  fclose(in);
}


x86 assembly (clang, -O0):
<doFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11b2 <doFile+0x62>
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    %rax,%rcx
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <decode@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1196 <doFile+0x46>
mov    0x2e6e(%rip),%rax
mov    (%rax),%ebp
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe7a(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <decode@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"ERROR: Can't open %s - %s\00"
@errno = global i32 0
define void @doFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %2
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %11)
br label %13
13: ; preds = %7, %1
%14 = load i32*, i32** %3
%15 = call i32 @decode(i32* %14)
%16 = load i32*, i32** %3
%17 = call i32 @fclose(i32* %16)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"ERROR: Can't open %s - %s\00"
@errno = global i32 0
define void @doFile(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = load i32, i32* @errno
%7 = tail call i8* @strerror(i32 %6)
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %7)
br label %9
9: ; preds = %4, %1
%10 = tail call i32 @decode(i32* %2)
%11 = tail call i32 @fclose(i32* %2)
ret void
}