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


x86 assembly (clang, -O0):
<error_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeb0(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e7c(%rip),%rax
cmpq   $0x0,(%rax)
je     1193 <error_exit+0x63>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
lea    0xe7b(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<error_exit>:
push   %rbx
mov    %rdi,%rdx
mov    0x2ea5(%rip),%rbx
mov    (%rbx),%edi
lea    0xebc(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1170 <error_exit+0x40>
mov    (%rbx),%ebx
call   1050 <strerror@plt>
lea    0xea3(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%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"nonroot: %s\0A\00"
@errno = global i64 0
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_FAILURE = global i32 0
define void @error_exit(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i64, i64* @errno
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i64, i64* @errno
%11 = call i8* @strerror(i64 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %8, %1
%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"nonroot: %s\0A\00"
@errno = global i64 0
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_FAILURE = global i32 0
define void @error_exit(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = load i64, i64* @errno
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i8* @strerror(i64 %4)
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %6, %1
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
}