#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 */
scalar_t__ errno;
int /*<<< orphan*/ *fopen(char const *, char const *);
int /*<<< orphan*/ my_err(char *, char *, int, char const *, char const *,
                          int /*<<< orphan*/);
int /*<<< orphan*/ strerror(scalar_t__);
FILE *util_must_fopen(const char *path, const char *mode) {
  FILE *f;
  errno = 0;
  f = fopen(path, mode);
  if (f == NULL) {
    my_err("%s:%d: error opening file '%s' in mode '%s': %s",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/"
           "util.c",
           1042, path, mode, strerror(errno));
  }
  return f;
}


x86 assembly (clang, -O0):
<util_must_fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e99(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ac <util_must_fopen+0x7c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%rdi
call   1040 <strerror@plt>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    %eax,%r9d
lea    0xe65(%rip),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x412,%edx
call   1050 <my_err@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_must_fopen>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e9b(%rip),%r12
movq   $0x0,(%r12)
call   1030 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1184 <util_must_fopen+0x54>
mov    (%r12),%rdi
call   1040 <strerror@plt>
lea    0xe96(%rip),%rdi
lea    0xebf(%rip),%rsi
mov    $0x412,%edx
mov    %r15,%rcx
mov    %r14,%r8
mov    %eax,%r9d
call   1050 <my_err@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [48 x i8] c"%s:%d: error opening file '%s' in mode '%s': %s\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
define i32* @util_must_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 i64 0, i64* @errno
%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 i64, i64* @errno
%15 = call i32 @strerror(i64 %14)
%16 = call i32 @my_err(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 1042, i8* %12, i8* %13, i32 %15)
br label %17
17: ; preds = %11, %2
%18 = load i32*, i32** %5
ret i32* %18
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [48 x i8] c"%s:%d: error opening file '%s' in mode '%s': %s\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
define noalias i32* @util_must_fopen(i8* %0, i8* %1) {
store i64 0, i64* @errno
%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 i64, i64* @errno
%7 = tail call i32 @strerror(i64 %6)
%8 = tail call i32 @my_err(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 1042, i8* %0, i8* %1, i32 %7)
br label %9
9: ; preds = %5, %2
ret i32* %3
}