#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*/ printf(char *);
int FileOpen(FILE **message, FILE **output, char *messageFileName) {
  *message = NULL;
  *output = NULL;
  *message = fopen(messageFileName, "rb");
  *output = fopen("output", "wb");
  if (*message == NULL || output == NULL) {
    printf("Error: Can't read input file or create optput file.\n");
    fclose((*message));
    fclose(*output);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<FileOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    0xe88(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11aa <FileOpen+0x7a>
cmpq   $0x0,-0x18(%rbp)
jne    11da <FileOpen+0xaa>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e1 <FileOpen+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileOpen>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,(%rdi)
movq   $0x0,(%rsi)
lea    0xeb1(%rip),%rsi
mov    %rdx,%rdi
call   1050 <fopen@plt>
mov    %rax,(%rbx)
lea    0xea2(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,(%r14)
xor    %eax,%eax
cmpq   $0x0,(%rbx)
jne    1199 <FileOpen+0x69>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rdi
call   1040 <fclose@plt>
mov    (%r14),%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [7 x i8] c"output\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [53 x i8] c"Error: Can't read input file or create optput file.\0A\00"
define i32 @FileOpen(i32** %0, i32** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32**
%7 = alloca i8*
store i32** %0, i32*** %5
store i32** %1, i32*** %6
store i8* %2, i8** %7
%8 = load i32**, i32*** %5
store i32* null, i32** %8
%9 = load i32**, i32*** %6
store i32* null, i32** %9
%10 = load i8*, i8** %7
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = load i32**, i32*** %5
store i32* %11, i32** %12
%13 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32**, i32*** %6
store i32* %13, i32** %14
%15 = load i32**, i32*** %5
%16 = load i32*, i32** %15
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %3
%19 = load i32**, i32*** %6
%20 = icmp eq i32** %19, null
br i1 %20, label %21, label %29
21: ; preds = %18, %3
%22 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32**, i32*** %5
%24 = load i32*, i32** %23
%25 = call i32 @fclose(i32* %24)
%26 = load i32**, i32*** %6
%27 = load i32*, i32** %26
%28 = call i32 @fclose(i32* %27)
store i32 -1, i32* %4
br label %30
29: ; preds = %18
store i32 0, i32* %4
br label %30
30: ; preds = %29, %21
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [7 x i8] c"output\00"
@.str.2 = [3 x i8] c"wb\00"
@str = [52 x i8] c"Error: Can't read input file or create optput file.\00"
define i32 @FileOpen(i32** nocapture %0, i32** nocapture %1, i8* nocapture %2) {
store i32* null, i32** %0
store i32* null, i32** %1
%4 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %4, i32** %0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %0
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%10 = load i32*, i32** %0
%11 = tail call i32 @fclose(i32* %10)
%12 = load i32*, i32** %1
%13 = tail call i32 @fclose(i32* %12)
br label %14
14: ; preds = %3, %8
%15 = phi i32 [ -1, %8 ], [ 0, %3 ]
ret i32 %15
}