#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(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void tryOpen(FILE **file, char *filename, char *mode) {
  if (filename == NULL) {
    printf("Usage: ./a.out <filename> [-keyUp <number> -keyDown <number> -o "
           "<filename>]");
    exit(1);
  }
  *file = fopen(filename, mode);
  if (*file == NULL) {
    printf("%s could not be opened.", filename);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<tryOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1167 <tryOpen+0x37>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11a8 <tryOpen+0x78>
mov    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tryOpen>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     115a <tryOpen+0x2a>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1040 <fopen@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1172 <tryOpen+0x42>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xed3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [76 x i8] c"Usage: ./a.out <filename> [-keyUp <number> -keyDown <number> -o <filename>]\00"
@.str.1 = [24 x i8] c"%s could not be opened.\00"
define void @tryOpen(i32** %0, i8* %1, i8* %2) {
%4 = alloca i32**
%5 = alloca i8*
%6 = alloca i8*
store i32** %0, i32*** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i32* @fopen(i8* %13, i8* %14)
%16 = load i32**, i32*** %4
store i32* %15, i32** %16
%17 = load i32**, i32*** %4
%18 = load i32*, i32** %17
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %12
%21 = load i8*, i8** %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [76 x i8] c"Usage: ./a.out <filename> [-keyUp <number> -keyDown <number> -o <filename>]\00"
@.str.1 = [24 x i8] c"%s could not be opened.\00"
define void @tryOpen(i32** nocapture writeonly %0, i8* %1, i8* nocapture %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %3
%9 = tail call i32* @fopen(i8* %1, i8* %2)
store i32* %9, i32** %0
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8
ret void
}