#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, int const);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void *_failsafe(void *data, const char *file, const int line,
                const char *inst) {
  if (!data) {
    fprintf(stderr,
            "\033[1m\033[31m"
            "failsafe: %s at %s:%d \n"
            "\033[39;49m",
            inst, file, line);
    if (errno != 0)
      perror("failsafe: system");
    exit(EXIT_FAILURE);
  }
  return data;
}


x86 assembly (clang, -O0):
<_failsafe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    119e <_failsafe+0x6e>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe92(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e5e(%rip),%rax
cmpq   $0x0,(%rax)
je     1190 <_failsafe+0x60>
lea    0xe9e(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_failsafe>:
test   %rdi,%rdi
je     1139 <_failsafe+0x9>
mov    %rdi,%rax
ret
push   %rax
mov    %edx,%r8d
mov    %rsi,%rax
mov    0x2e99(%rip),%rdx
mov    (%rdx),%edi
lea    0xeb0(%rip),%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    0x2e76(%rip),%rax
cmpq   $0x0,(%rax)
je     1174 <_failsafe+0x44>
lea    0xeba(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"\1B[1m\1B[31mfailsafe: %s at %s:%d \0A\1B[39;49m\00"
@errno = global i64 0
@.str.1 = [17 x i8] c"failsafe: system\00"
@EXIT_FAILURE = global i32 0
define i8* @_failsafe(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %24, label %11
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %8
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14, i32 %15)
%17 = load i64, i64* @errno
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %11
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %4
%25 = load i8*, i8** %5
ret i8* %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"\1B[1m\1B[31mfailsafe: %s at %s:%d \0A\1B[39;49m\00"
@errno = global i64 0
@.str.1 = [17 x i8] c"failsafe: system\00"
@EXIT_FAILURE = global i32 0
define i8* @_failsafe(i8* readnone returned %0, i8* %1, i32 %2, i8* %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %16
6: ; preds = %4
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %1, i32 %2)
%9 = load i64, i64* @errno
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %4
ret i8* %0
}