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

/* Variables and functions */
scalar_t__ EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ exit(scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vfail(char const *format, va_list arguments) {
  vfprintf(stderr, format, arguments);
  fprintf(stderr, "\n");
  if (errno)
    perror(NULL);
  exit(errno ? errno : EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<vfail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <vfprintf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e58(%rip),%rax
cmpq   $0x0,(%rax)
je     1193 <vfail+0x53>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <perror@plt>
mov    0x2e3e(%rip),%rax
cmpq   $0x0,(%rax)
je     11b7 <vfail+0x77>
mov    0x2e2d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11c5 <vfail+0x85>
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<vfail>:
push   %rbx
mov    %esi,%edx
mov    %rdi,%rsi
mov    0x2e93(%rip),%rbx
mov    (%rbx),%edi
call   1050 <vfprintf@plt>
mov    (%rbx),%edi
lea    0xea3(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e6f(%rip),%rbx
cmpq   $0x0,(%rbx)
je     117e <vfail+0x3e>
xor    %edi,%edi
call   1040 <perror@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
jne    1188 <vfail+0x48>
mov    0x2e4b(%rip),%rax
mov    (%rax),%rdi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
@errno = global i64 0
@EXIT_FAILURE = global i64 0
define void @vfail(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i32 @vfprintf(i32 %5, i8* %6, i32 %7)
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = load i64, i64* @errno
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i32* null)
br label %15
15: ; preds = %13, %2
%16 = load i64, i64* @errno
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i64, i64* @errno
br label %22
20: ; preds = %15
%21 = load i64, i64* @EXIT_FAILURE
br label %22
22: ; preds = %20, %18
%23 = phi i64 [ %19, %18 ], [ %21, %20 ]
%24 = call i32 @exit(i64 %23)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
@errno = global i64 0
@EXIT_FAILURE = global i64 0
define void @vfail(i8* %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @vfprintf(i32 %3, i8* %0, i32 %1)
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* @errno
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = tail call i32 @perror(i32* null)
%11 = load i64, i64* @errno
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2, %9
%14 = load i64, i64* @EXIT_FAILURE
br label %15
15: ; preds = %9, %13
%16 = phi i64 [ %14, %13 ], [ %11, %9 ]
%17 = tail call i32 @exit(i64 %16)
unreachable
}