#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_AUTOBOOT;
int /*<<< orphan*/ RB_HALT_SYSTEM;
int /*<<< orphan*/ RB_POWER_OFF;
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ sync();
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc != 2)
    usage();
  sync();
  sync();
  sync();
  if (strcmp(argv[1], "RESTART") == 0) {
    reboot(RB_AUTOBOOT);
  } else if (strcmp(argv[1], "HALT") == 0) {
    reboot(RB_HALT_SYSTEM);
  } else if (strcmp(argv[1], "POWER_OFF") == 0) {
    reboot(RB_POWER_OFF);
  } else {
    usage();
  }
  while (1)
    sleep(10);
}


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)
cmpl   $0x2,-0x8(%rbp)
je     1177 <main+0x27>
mov    $0x0,%al
call   1050 <usage@plt>
mov    $0x0,%al
call   1040 <sync@plt>
mov    $0x0,%al
call   1040 <sync@plt>
mov    $0x0,%al
call   1040 <sync@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <main+0x6d>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
jmp    1230 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ee <main+0x9e>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
jmp    122b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe10(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <main+0xcf>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
jmp    1226 <main+0xd6>
mov    $0x0,%al
call   1050 <usage@plt>
jmp    122b <main+0xdb>
jmp    1230 <main+0xe0>
jmp    1235 <main+0xe5>
mov    $0xa,%edi
call   1070 <sleep@plt>
jmp    1235 <main+0xe5>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1160 <main+0x10>
xor    %eax,%eax
call   1050 <usage@plt>
xor    %eax,%eax
call   1040 <sync@plt>
xor    %eax,%eax
call   1040 <sync@plt>
xor    %eax,%eax
call   1040 <sync@plt>
mov    0x8(%rbx),%rdi
lea    0xe80(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11bd <main+0x6d>
mov    0x8(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c6 <main+0x76>
mov    0x8(%rbx),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11cf <main+0x7f>
xor    %eax,%eax
call   1050 <usage@plt>
jmp    11e0 <main+0x90>
mov    0x2e0c(%rip),%rax
jmp    11d6 <main+0x86>
mov    0x2e0b(%rip),%rax
jmp    11d6 <main+0x86>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
nopl   (%rax)
mov    $0xa,%edi
call   1070 <sleep@plt>
jmp    11e0 <main+0x90>

LLVM IR (-O0):
@.str = [8 x i8] c"RESTART\00"
@RB_AUTOBOOT = global i32 0
@.str.1 = [5 x i8] c"HALT\00"
@RB_HALT_SYSTEM = global i32 0
@.str.2 = [10 x i8] c"POWER_OFF\00"
@RB_POWER_OFF = 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* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @usage()
br label %10
10: ; preds = %8, %2
%11 = call i32 (...) @sync()
%12 = call i32 (...) @sync()
%13 = call i32 (...) @sync()
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = load i32, i32* @RB_AUTOBOOT
%21 = call i32 @reboot(i32 %20)
br label %44
22: ; preds = %10
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* @RB_HALT_SYSTEM
%30 = call i32 @reboot(i32 %29)
br label %43
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load i32, i32* @RB_POWER_OFF
%39 = call i32 @reboot(i32 %38)
br label %42
40: ; preds = %31
%41 = call i32 (...) @usage()
br label %42
42: ; preds = %40, %37
br label %43
43: ; preds = %42, %28
br label %44
44: ; preds = %43, %19
br label %45
45: ; preds = %44, %45
%46 = call i32 @sleep(i32 10)
br label %45
}

LLVM IR (-O2):
@.str = [8 x i8] c"RESTART\00"
@RB_AUTOBOOT = global i32 0
@.str.1 = [5 x i8] c"HALT\00"
@RB_HALT_SYSTEM = global i32 0
@.str.2 = [10 x i8] c"POWER_OFF\00"
@RB_POWER_OFF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = tail call i32 (...) @sync()
%8 = tail call i32 (...) @sync()
%9 = tail call i32 (...) @sync()
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load i32, i32* @RB_AUTOBOOT
%16 = tail call i32 @reboot(i32 %15)
br label %33
17: ; preds = %6
%18 = load i8*, i8** %10
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* @RB_HALT_SYSTEM
%23 = tail call i32 @reboot(i32 %22)
br label %33
24: ; preds = %17
%25 = load i8*, i8** %10
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* @RB_POWER_OFF
%30 = tail call i32 @reboot(i32 %29)
br label %33
31: ; preds = %24
%32 = tail call i32 (...) @usage()
br label %33
33: ; preds = %21, %31, %28, %14
br label %34
34: ; preds = %33, %34
%35 = tail call i32 @sleep(i32 10)
br label %34
}