#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_ENABLE_CAD;
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ initlog(char *);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sync();
void kill_all_processes(void) {
  initlog("The system is going down NOW!");
  reboot(RB_ENABLE_CAD);
  initlog("Sending SIGTERM to all processes");
  kill(-1, SIGTERM);
  sync();
  sleep(1);
  initlog("Sending SIGKILL to all processes");
  kill(-1, SIGKILL);
  sync();
  sleep(1);
  kill(1, SIGTERM);
}


x86 assembly (clang, -O0):
<kill_all_processes>:
push   %rbp
mov    %rsp,%rbp
lea    0xea5(%rip),%rdi
call   1030 <initlog@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
lea    0xea9(%rip),%rdi
call   1030 <initlog@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1040 <kill@plt>
mov    $0x0,%al
call   1050 <sync@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
lea    0xe9a(%rip),%rdi
call   1030 <initlog@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1040 <kill@plt>
mov    $0x0,%al
call   1050 <sync@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1040 <kill@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kill_all_processes>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <initlog@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
lea    0xeac(%rip),%rdi
call   1030 <initlog@plt>
mov    0x2e6a(%rip),%rbx
mov    (%rbx),%esi
mov    $0xffffffff,%edi
call   1040 <kill@plt>
xor    %eax,%eax
call   1050 <sync@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
lea    0xe9d(%rip),%rdi
call   1030 <initlog@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1040 <kill@plt>
xor    %eax,%eax
call   1050 <sync@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    (%rbx),%esi
mov    $0x1,%edi
pop    %rbx
jmp    1040 <kill@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"The system is going down NOW!\00"
@RB_ENABLE_CAD = global i32 0
@.str.1 = [33 x i8] c"Sending SIGTERM to all processes\00"
@SIGTERM = global i32 0
@.str.2 = [33 x i8] c"Sending SIGKILL to all processes\00"
@SIGKILL = global i32 0
define void @kill_all_processes() {
%1 = call i32 @initlog(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @RB_ENABLE_CAD
%3 = call i32 @reboot(i32 %2)
%4 = call i32 @initlog(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @SIGTERM
%6 = call i32 @kill(i32 -1, i32 %5)
%7 = call i32 (...) @sync()
%8 = call i32 @sleep(i32 1)
%9 = call i32 @initlog(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @SIGKILL
%11 = call i32 @kill(i32 -1, i32 %10)
%12 = call i32 (...) @sync()
%13 = call i32 @sleep(i32 1)
%14 = load i32, i32* @SIGTERM
%15 = call i32 @kill(i32 1, i32 %14)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"The system is going down NOW!\00"
@RB_ENABLE_CAD = global i32 0
@.str.1 = [33 x i8] c"Sending SIGTERM to all processes\00"
@SIGTERM = global i32 0
@.str.2 = [33 x i8] c"Sending SIGKILL to all processes\00"
@SIGKILL = global i32 0
define void @kill_all_processes() {
%1 = tail call i32 @initlog(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @RB_ENABLE_CAD
%3 = tail call i32 @reboot(i32 %2)
%4 = tail call i32 @initlog(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @SIGTERM
%6 = tail call i32 @kill(i32 -1, i32 %5)
%7 = tail call i32 (...) @sync()
%8 = tail call i32 @sleep(i32 1)
%9 = tail call i32 @initlog(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @SIGKILL
%11 = tail call i32 @kill(i32 -1, i32 %10)
%12 = tail call i32 (...) @sync()
%13 = tail call i32 @sleep(i32 1)
%14 = load i32, i32* @SIGTERM
%15 = tail call i32 @kill(i32 1, i32 %14)
ret void
}