#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*/ dhvani_error(char *, int, char *, char const *,
                                int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char const *, char const *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
FILE *dhvani_fopen(const char *filename, const char *mode) {
  char *errorstring = NULL;
  FILE *file = NULL;
  if ((file = fopen(filename, mode)) == NULL) {
    dhvani_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/dhvani-tts/dhvani-tts/refs/"
                 "heads/master/src/dhvani_utils.c",
                 15, "%s - %s\n", filename, strerror(errno));
    exit(1);
  }
  return file;
}


x86 assembly (clang, -O0):
<dhvani_fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11ba <dhvani_fopen+0x7a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,%r8d
lea    0xe61(%rip),%rdi
mov    $0xf,%esi
lea    0xeea(%rip),%rdx
call   1060 <dhvani_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhvani_fopen>:
push   %rbx
mov    %rdi,%rbx
call   1030 <fopen@plt>
test   %rax,%rax
je     1150 <dhvani_fopen+0x10>
pop    %rbx
ret
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe9b(%rip),%rdi
lea    0xf29(%rip),%rdx
mov    $0xf,%esi
mov    %rbx,%rcx
mov    %eax,%r8d
call   1060 <dhvani_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dhvani-tts/dhvani-tts/refs/heads/master/src/dhvani_utils.c\00"
@.str.1 = [9 x i8] c"%s - %s\0A\00"
@errno = global i32 0
define i32* @dhvani_fopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* null, i8** %5
store i32* null, i32** %6
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %7, i8* %8)
store i32* %9, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i32, i32* @errno
%14 = call i32 @strerror(i32 %13)
%15 = call i32 @dhvani_error(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32*, i32** %6
ret i32* %18
}

LLVM IR (-O2):
@.str = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dhvani-tts/dhvani-tts/refs/heads/master/src/dhvani_utils.c\00"
@.str.1 = [9 x i8] c"%s - %s\0A\00"
@errno = global i32 0
define noalias i32* @dhvani_fopen(i8* %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @dhvani_error(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
ret i32* %3
}