#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*/ RB_HALT_SYSTEM;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ kmsg(char *, char const *, ...);
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
int /*<<< orphan*/ strerror(scalar_t__);
int /*<<< orphan*/ sync();
__attribute__((noreturn)) void die(const char *msg) {
  if (errno == 0) {
    kmsg("*** %s", msg);
  } else {
    kmsg("*** %s: %s", msg, strerror(errno));
  }
  sync();
  reboot(RB_HALT_SYSTEM);
  exit(1);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
cmpq   $0x0,(%rax)
jne    1184 <die+0x34>
mov    -0x8(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1050 <kmsg@plt>
jmp    11af <die+0x5f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <kmsg@plt>
mov    $0x0,%al
call   1030 <sync@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rbx
mov    %rdi,%rbx
mov    0x2e85(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    1176 <die+0x26>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <kmsg@plt>
jmp    118e <die+0x3e>
call   1070 <strerror@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <kmsg@plt>
xor    %eax,%eax
call   1030 <sync@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [7 x i8] c"*** %s\00"
@.str.1 = [11 x i8] c"*** %s: %s\00"
@RB_HALT_SYSTEM = global i32 0
define void @die(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i64, i64* @errno
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = call i32 (i8*, i8*, ...) @kmsg(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %13
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = load i64, i64* @errno
%11 = call i32 @strerror(i64 %10)
%12 = call i32 (i8*, i8*, ...) @kmsg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %11)
br label %13
13: ; preds = %8, %5
%14 = call i32 (...) @sync()
%15 = load i32, i32* @RB_HALT_SYSTEM
%16 = call i32 @reboot(i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
}

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