#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
FILE *openFile(int argc, char *argv[]) {
  FILE *out;
  if (argc > 1)
    out = fopen(argv[1], "w+b");
  else
    out = fopen("eeprom.bin", "w+b");
  if (out == NULL)
    exit(EXIT_FAILURE);
  return out;
}


x86 assembly (clang, -O0):
<openFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    1156 <openFile+0x36>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    116d <openFile+0x4d>
lea    0xea7(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1186 <openFile+0x66>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openFile>:
push   %rax
cmp    $0x2,%edi
jl     112c <openFile+0xc>
mov    0x8(%rsi),%rdi
jmp    1133 <openFile+0x13>
lea    0xed1(%rip),%rdi
lea    0xec6(%rip),%rsi
call   1030 <fopen@plt>
test   %rax,%rax
je     1146 <openFile+0x26>
pop    %rcx
ret
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"w+b\00"
@.str.1 = [11 x i8] c"eeprom.bin\00"
@EXIT_FAILURE = global i32 0
define i32* @openFile(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %5
br label %15
13: ; preds = %2
%14 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %5
br label %15
15: ; preds = %13, %8
%16 = load i32*, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %15
%22 = load i32*, i32** %5
ret i32* %22
}

LLVM IR (-O2):
@.str = [4 x i8] c"w+b\00"
@.str.1 = [11 x i8] c"eeprom.bin\00"
@EXIT_FAILURE = global i32 0
define i32* @openFile(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %2 ]
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %7
ret i32* %9
}