#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*/ _fail(int /*<<< orphan*/, char *, char *, int, ...);
int /*<<< orphan*/ *fopen(char const *, char const *);
FILE *open_file(char const *path, char const *mode) {
  do {
    long long e = (long long)(path && mode);
    if (!e) {
      _fail(0,
            "\n[%s:%i] "
            "Assertion failed",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/ggwpez/ecel/refs/heads/master/io.c",
            10);
    }
  } while (0);
  FILE *file = fopen(path, mode);
  if (!file) {
    _fail(0,
          "\n[%s:%i] "
          "File not found: '%s'\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ggwpez/ecel/refs/heads/master/io.c",
          15, path);
    return NULL;
  } else
    return file;
}


x86 assembly (clang, -O0):
<open_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x29(%rbp)
je     114b <open_file+0x2b>
cmpq   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1180 <open_file+0x60>
xor    %edi,%edi
lea    0xe93(%rip),%rsi
lea    0xea6(%rip),%rdx
mov    $0xa,%ecx
mov    $0x0,%al
call   1030 <_fail@plt>
jmp    1185 <open_file+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ce <open_file+0xae>
mov    -0x10(%rbp),%r8
xor    %edi,%edi
lea    0xee9(%rip),%rsi
lea    0xe65(%rip),%rdx
mov    $0xf,%ecx
mov    $0x0,%al
call   1030 <_fail@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d6 <open_file+0xb6>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1134 <open_file+0x14>
test   %rbx,%rbx
jne    1150 <open_file+0x30>
lea    0xec5(%rip),%rsi
lea    0xed8(%rip),%rdx
xor    %edi,%edi
mov    $0xa,%ecx
xor    %eax,%eax
call   1030 <_fail@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1182 <open_file+0x62>
lea    0xf2d(%rip),%rsi
lea    0xea9(%rip),%rdx
xor    %edi,%edi
mov    $0xf,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1030 <_fail@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0A[%s:%i] Assertion failed\00"
@.str.1 = [125 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ggwpez/ecel/refs/heads/master/io.c\00"
@.str.2 = [31 x i8] c"\0A[%s:%i] File not found: '%s'\0A\00"
define i32* @open_file(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %8
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ false, %8 ], [ %13, %11 ]
%16 = zext i1 %15 to i32
%17 = sext i32 %16 to i64
store i64 %17, i64* %6
%18 = load i64, i64* %6
%19 = icmp ne i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = call i32 (i32, i8*, i8*, i32, ...) @_fail(i32 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 10)
br label %22
22: ; preds = %20, %14
br label %23
23: ; preds = %22
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = call i32* @fopen(i8* %24, i8* %25)
store i32* %26, i32** %7
%27 = load i32*, i32** %7
%28 = icmp ne i32* %27, null
br i1 %28, label %32, label %29
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = call i32 (i32, i8*, i8*, i32, ...) @_fail(i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 15, i8* %30)
store i32* null, i32** %3
br label %34
32: ; preds = %23
%33 = load i32*, i32** %7
store i32* %33, i32** %3
br label %34
34: ; preds = %32, %29
%35 = load i32*, i32** %3
ret i32* %35
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0A[%s:%i] Assertion failed\00"
@.str.1 = [125 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ggwpez/ecel/refs/heads/master/io.c\00"
@.str.2 = [31 x i8] c"\0A[%s:%i] File not found: '%s'\0A\00"
define noalias i32* @open_file(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 (i32, i8*, i8*, i32, ...) @_fail(i32 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 10)
br label %8
8: ; preds = %6, %2
%9 = tail call i32* @fopen(i8* %0, i8* %1)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (i32, i8*, i8*, i32, ...) @_fail(i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 15, i8* %0)
br label %13
13: ; preds = %8, %11
ret i32* %9
}