#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 /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ SIGTTIN;
int /*<<< orphan*/ SIGTTOU;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ sync();
int main(int argc, char **argv) {
  signal(SIGQUIT, SIG_IGN);
  signal(SIGCHLD, SIG_IGN);
  signal(SIGHUP, SIG_IGN);
  signal(SIGTSTP, SIG_IGN);
  signal(SIGTTIN, SIG_IGN);
  signal(SIGTTOU, SIG_IGN);
  signal(SIGINT, SIG_IGN);
  if (kill(1, SIGTSTP) < 0) {
    fprintf(stderr, "shutdown: can't idle init.\r\n");
    exit(1);
  }
  kill(-1, SIGTERM);
  sleep(1);
  kill(-1, SIGKILL);
  sleep(1);
  sync();
  reboot(LINUX_REBOOT_CMD_RESTART);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    0x2de4(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x2d9f(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1050 <kill@plt>
cmp    $0x0,%rax
jge    1263 <main+0xf3>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xdac(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1050 <kill@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1050 <kill@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    $0x0,%al
call   1060 <sync@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   1080 <reboot@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e24(%rip),%rbx
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e06(%rip),%r14
mov    (%r14),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    (%r14),%esi
mov    $0x1,%edi
call   1050 <kill@plt>
test   %rax,%rax
js     1257 <main+0xe7>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1050 <kill@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1050 <kill@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1060 <sync@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   1080 <reboot@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@SIGQUIT = global i32 0
@SIG_IGN = global i32 0
@SIGCHLD = global i32 0
@SIGHUP = global i32 0
@SIGTSTP = global i32 0
@SIGTTIN = global i32 0
@SIGTTOU = global i32 0
@SIGINT = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"shutdown: can't idle init.\0D\0A\00"
@SIGTERM = global i32 0
@SIGKILL = global i32 0
@LINUX_REBOOT_CMD_RESTART = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @SIGQUIT
%7 = load i32, i32* @SIG_IGN
%8 = call i32 @signal(i32 %6, i32 %7)
%9 = load i32, i32* @SIGCHLD
%10 = load i32, i32* @SIG_IGN
%11 = call i32 @signal(i32 %9, i32 %10)
%12 = load i32, i32* @SIGHUP
%13 = load i32, i32* @SIG_IGN
%14 = call i32 @signal(i32 %12, i32 %13)
%15 = load i32, i32* @SIGTSTP
%16 = load i32, i32* @SIG_IGN
%17 = call i32 @signal(i32 %15, i32 %16)
%18 = load i32, i32* @SIGTTIN
%19 = load i32, i32* @SIG_IGN
%20 = call i32 @signal(i32 %18, i32 %19)
%21 = load i32, i32* @SIGTTOU
%22 = load i32, i32* @SIG_IGN
%23 = call i32 @signal(i32 %21, i32 %22)
%24 = load i32, i32* @SIGINT
%25 = load i32, i32* @SIG_IGN
%26 = call i32 @signal(i32 %24, i32 %25)
%27 = load i32, i32* @SIGTSTP
%28 = call i64 @kill(i32 1, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %2
%35 = load i32, i32* @SIGTERM
%36 = call i64 @kill(i32 -1, i32 %35)
%37 = call i32 @sleep(i32 1)
%38 = load i32, i32* @SIGKILL
%39 = call i64 @kill(i32 -1, i32 %38)
%40 = call i32 @sleep(i32 1)
%41 = call i32 (...) @sync()
%42 = load i32, i32* @LINUX_REBOOT_CMD_RESTART
%43 = call i32 @reboot(i32 %42)
ret i32 0
}

LLVM IR (-O2):
@SIGQUIT = global i32 0
@SIG_IGN = global i32 0
@SIGCHLD = global i32 0
@SIGHUP = global i32 0
@SIGTSTP = global i32 0
@SIGTTIN = global i32 0
@SIGTTOU = global i32 0
@SIGINT = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"shutdown: can't idle init.\0D\0A\00"
@SIGTERM = global i32 0
@SIGKILL = global i32 0
@LINUX_REBOOT_CMD_RESTART = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @SIGQUIT
%4 = load i32, i32* @SIG_IGN
%5 = tail call i32 @signal(i32 %3, i32 %4)
%6 = load i32, i32* @SIGCHLD
%7 = load i32, i32* @SIG_IGN
%8 = tail call i32 @signal(i32 %6, i32 %7)
%9 = load i32, i32* @SIGHUP
%10 = load i32, i32* @SIG_IGN
%11 = tail call i32 @signal(i32 %9, i32 %10)
%12 = load i32, i32* @SIGTSTP
%13 = load i32, i32* @SIG_IGN
%14 = tail call i32 @signal(i32 %12, i32 %13)
%15 = load i32, i32* @SIGTTIN
%16 = load i32, i32* @SIG_IGN
%17 = tail call i32 @signal(i32 %15, i32 %16)
%18 = load i32, i32* @SIGTTOU
%19 = load i32, i32* @SIG_IGN
%20 = tail call i32 @signal(i32 %18, i32 %19)
%21 = load i32, i32* @SIGINT
%22 = load i32, i32* @SIG_IGN
%23 = tail call i32 @signal(i32 %21, i32 %22)
%24 = load i32, i32* @SIGTSTP
%25 = tail call i64 @kill(i32 1, i32 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %2
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %2
%32 = load i32, i32* @SIGTERM
%33 = tail call i64 @kill(i32 -1, i32 %32)
%34 = tail call i32 @sleep(i32 1)
%35 = load i32, i32* @SIGKILL
%36 = tail call i64 @kill(i32 -1, i32 %35)
%37 = tail call i32 @sleep(i32 1)
%38 = tail call i32 (...) @sync()
%39 = load i32, i32* @LINUX_REBOOT_CMD_RESTART
%40 = tail call i32 @reboot(i32 %39)
ret i32 0
}