#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*/ errno;
int /*<<< orphan*/ *fopen(char const *, char const *);
int /*<<< orphan*/ gu_quit(char *, char const *, char const *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
FILE *gu_fopen(const char *path, const char *mode) {
  FILE *f = NULL;
  f = fopen(path, mode);
  if (f == NULL)
    gu_quit("%s: could not open for \"%s\" : %s\n", path, mode,
            strerror(errno));
  return f;
}


x86 assembly (clang, -O0):
<gu_fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1198 <gu_fopen+0x68>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe6d(%rip),%rdi
call   1030 <gu_quit@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gu_fopen>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116a <gu_fopen+0x3a>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xea3(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1030 <gu_quit@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"%s: could not open for \22%s\22 : %s\0A\00"
@errno = global i32 0
define i32* @gu_fopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32* null, i32** %5
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %6, i8* %7)
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 @gu_quit(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i32 %15)
br label %17
17: ; preds = %11, %2
%18 = load i32*, i32** %5
ret i32* %18
}

LLVM IR (-O2):
@.str = [34 x i8] c"%s: could not open for \22%s\22 : %s\0A\00"
@errno = global i32 0
define noalias i32* @gu_fopen(i8* %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @gu_quit(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i32 %7)
br label %9
9: ; preds = %5, %2
ret i32* %3
}