#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*/ error(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
FILE *open_explicit_file(char *file_name) {
  FILE *file_handle;
  if (*file_name == '\0') {
    error("Bad output file [%s]", file_name);
    return NULL;
  }
  if ((file_handle = fopen(file_name, "w")) == NULL) {
    error("Cannot open output file [%s]", file_name);
    return NULL;
  }
  return file_handle;
}


x86 assembly (clang, -O0):
<open_explicit_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1159 <open_explicit_file+0x39>
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <error@plt>
movq   $0x0,-0x8(%rbp)
jmp    119c <open_explicit_file+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1194 <open_explicit_file+0x74>
mov    -0x10(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1030 <error@plt>
movq   $0x0,-0x8(%rbp)
jmp    119c <open_explicit_file+0x7c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_explicit_file>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     113f <open_explicit_file+0x1f>
lea    0xee5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     1148 <open_explicit_file+0x28>
pop    %rbx
ret
lea    0xeba(%rip),%rdi
jmp    114f <open_explicit_file+0x2f>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <error@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Bad output file [%s]\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [29 x i8] c"Cannot open output file [%s]\00"
define i32* @open_explicit_file(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32* null, i32** %2
br label %21
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %17)
store i32* null, i32** %2
br label %21
19: ; preds = %12
%20 = load i32*, i32** %4
store i32* %20, i32** %2
br label %21
21: ; preds = %19, %16, %9
%22 = load i32*, i32** %2
ret i32* %22
}

LLVM IR (-O2):
@.str = [21 x i8] c"Bad output file [%s]\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [29 x i8] c"Cannot open output file [%s]\00"
define noalias i32* @open_explicit_file(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4, %1
%8 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), %4 ]
%9 = tail call i32 @error(i8* %8, i8* %0)
br label %10
10: ; preds = %7, %4
%11 = phi i32* [ %5, %4 ], [ null, %7 ]
ret i32* %11
}