#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 *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
void errexit(const char *msg) {
  fprintf(stderr, "ERR: %s: %s\n", msg, errno ? strerror(errno) : "unknown");
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<errexit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e81(%rip),%rax
cmpq   $0x0,(%rax)
je     1179 <errexit+0x49>
mov    0x2e70(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    %rax,-0x20(%rbp)
jmp    1189 <errexit+0x59>
lea    0xe8d(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1189 <errexit+0x59>
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rcx
lea    0xe65(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<errexit>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea3(%rip),%rax
mov    (%rax),%ebp
mov    0x2e92(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    1157 <errexit+0x27>
lea    0xeb8(%rip),%rcx
jmp    115f <errexit+0x2f>
call   1050 <strerror@plt>
mov    %rax,%rcx
lea    0xe9a(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"ERR: %s: %s\0A\00"
@errno = global i64 0
@.str.1 = [8 x i8] c"unknown\00"
@EXIT_FAILURE = global i32 0
define void @errexit(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = load i64, i64* @errno
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i64, i64* @errno
%9 = call i8* @strerror(i64 %8)
br label %11
10: ; preds = %1
br label %11
11: ; preds = %10, %7
%12 = phi i8* [ %9, %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %10 ]
%13 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
}

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