#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ poweroff();
int /*<<< orphan*/ reboot();
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  switch (argv[0][0]) {
  case 'h':
    poweroff();
    break;
  case 'p':
    poweroff();
    break;
  case 'r':
    reboot();
    break;
  default:
    fprintf(stderr, "unrecognized command\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x68,%eax
je     1193 <main+0x53>
jmp    1171 <main+0x31>
mov    -0x14(%rbp),%eax
sub    $0x70,%eax
je     119f <main+0x5f>
jmp    1182 <main+0x42>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
je     11ab <main+0x6b>
jmp    11b7 <main+0x77>
mov    $0x0,%al
call   1050 <poweroff@plt>
jmp    11d6 <main+0x96>
mov    $0x0,%al
call   1050 <poweroff@plt>
jmp    11d6 <main+0x96>
mov    $0x0,%al
call   1060 <reboot@plt>
jmp    11d6 <main+0x96>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    (%rsi),%rax
movsbl (%rax),%eax
cmp    $0x72,%eax
je     115f <main+0x1f>
cmp    $0x70,%eax
je     1156 <main+0x16>
cmp    $0x68,%eax
jne    116a <main+0x2a>
xor    %eax,%eax
call   1050 <poweroff@plt>
jmp    1166 <main+0x26>
xor    %eax,%eax
call   1060 <reboot@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"unrecognized command\0A\00"
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 i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %18 [
i32 104, label %12
i32 112, label %14
i32 114, label %16
]
12: ; preds = %2
%13 = call i32 (...) @poweroff()
br label %22
14: ; preds = %2
%15 = call i32 (...) @poweroff()
br label %22
16: ; preds = %2
%17 = call i32 (...) @reboot()
br label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %16, %14, %12
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"unrecognized command\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %12 [
i32 104, label %6
i32 112, label %8
i32 114, label %10
]
6: ; preds = %2
%7 = tail call i32 (...) @poweroff()
br label %16
8: ; preds = %2
%9 = tail call i32 (...) @poweroff()
br label %16
10: ; preds = %2
%11 = tail call i32 (...) @reboot()
br label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10, %8, %6
ret i32 0
}