#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*/ Failure();
int /*<<< orphan*/ Success();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
FILE *open_input_file() {
  FILE *input_file;
  printf("Opening input file");
  if ((input_file = fopen("./input.conf", "r")) == NULL) {
    Failure();
    printf("\tError opening input file %s\n", "./input.conf");
    return NULL;
  }
  Success();
  return input_file;
}


x86 assembly (clang, -O0):
<open_input_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a0 <open_input_file+0x60>
mov    $0x0,%al
call   1040 <Failure@plt>
lea    0xe9d(%rip),%rdi
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11af <open_input_file+0x6f>
mov    $0x0,%al
call   1060 <Success@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_input_file>:
push   %rbx
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1173 <open_input_file+0x33>
xor    %eax,%eax
call   1060 <Success@plt>
jmp    118f <open_input_file+0x4f>
xor    %eax,%eax
call   1040 <Failure@plt>
lea    0xea1(%rip),%rdi
lea    0xe8b(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Opening input file\00"
@.str.1 = [13 x i8] c"./input.conf\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [30 x i8] c"\09Error opening input file %s\0A\00"
define i32* @open_input_file() {
%1 = alloca i32*
%2 = alloca i32*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %4, i32** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 (...) @Failure()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32* null, i32** %1
br label %12
9: ; preds = %0
%10 = call i32 (...) @Success()
%11 = load i32*, i32** %2
store i32* %11, i32** %1
br label %12
12: ; preds = %9, %6
%13 = load i32*, i32** %1
ret i32* %13
}

LLVM IR (-O2):
@.str = [19 x i8] c"Opening input file\00"
@.str.1 = [13 x i8] c"./input.conf\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [30 x i8] c"\09Error opening input file %s\0A\00"
define noalias i32* @open_input_file() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 (...) @Failure()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = tail call i32 (...) @Success()
br label %9
9: ; preds = %7, %4
ret i32* %2
}