#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*/ LINUX_REBOOT_CMD_RESTART;
int errno;
int /*<<< orphan*/ printf(char *, ...);
int reboot(int /*<<< orphan*/);
char *strerror(int);
int /*<<< orphan*/ sync();
int main() {
  sync();
  if (reboot(LINUX_REBOOT_CMD_RESTART) == -1) {
    printf("WARNING! REBOOT FAILED\n");
    printf("errno=%d: %s\n", errno, strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <sync@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1050 <reboot@plt>
cmp    $0xffffffff,%eax
jne    11b5 <main+0x75>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x8(%rbp),%esi
mov    %rax,%rdx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <main+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <sync@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
cmp    $0xffffffff,%eax
jne    11a1 <main+0x51>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1070 <strerror@plt>
lea    0xe70(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LINUX_REBOOT_CMD_RESTART = global i32 0
@.str = [24 x i8] c"WARNING! REBOOT FAILED\0A\00"
@.str.1 = [14 x i8] c"errno=%d: %s\0A\00"
@errno = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @sync()
%3 = load i32, i32* @LINUX_REBOOT_CMD_RESTART
%4 = call i32 @reboot(i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @errno
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* %10)
store i32 -1, i32* %1
br label %13
12: ; preds = %0
store i32 0, i32* %1
br label %13
13: ; preds = %12, %6
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@LINUX_REBOOT_CMD_RESTART = global i32 0
@.str.1 = [14 x i8] c"errno=%d: %s\0A\00"
@errno = global i32 0
@str = [23 x i8] c"WARNING! REBOOT FAILED\00"
define i32 @main() {
%1 = tail call i32 (...) @sync()
%2 = load i32, i32* @LINUX_REBOOT_CMD_RESTART
%3 = tail call i32 @reboot(i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7, i8* %8)
br label %10
10: ; preds = %0, %5
%11 = phi i32 [ -1, %5 ], [ 0, %0 ]
ret i32 %11
}