#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int vmstatus(int);
void power_status() {
  int id;
  scanf("%d", &id);
  int ret = vmstatus(id);
  if (0 == ret) {
    printf("on\n");
  } else if (1 == ret) {
    printf("off\n");
  } else if (2 == ret) {
    printf("stop\n");
  } else {
    printf("unknown\n");
  }
}


x86 assembly (clang, -O0):
<power_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%edi
call   1030 <vmstatus@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    116f <power_status+0x3f>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
jmp    11c3 <power_status+0x93>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    118e <power_status+0x5e>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
jmp    11be <power_status+0x8e>
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jne    11ad <power_status+0x7d>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
jmp    11b9 <power_status+0x89>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
jmp    11be <power_status+0x8e>
jmp    11c3 <power_status+0x93>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power_status>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
call   1040 <vmstatus@plt>
cmp    $0x2,%eax
ja     1162 <power_status+0x32>
cltq
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1169 <power_status+0x39>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"on\0A\00"
@.str.2 = [5 x i8] c"off\0A\00"
@.str.3 = [6 x i8] c"stop\0A\00"
@.str.4 = [9 x i8] c"unknown\0A\00"
define void @power_status() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @vmstatus(i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 0, %6
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %24
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp eq i32 1, %11
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %23
15: ; preds = %10
%16 = load i32, i32* %2
%17 = icmp eq i32 2, %16
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22, %13
br label %24
24: ; preds = %23, %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [8 x i8] c"unknown\00"
@str.5 = [5 x i8] c"stop\00"
@str.6 = [4 x i8] c"off\00"
@str.7 = [3 x i8] c"on\00"
@reltable.power_status = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @str.7 to i64), i64 ptrtoint ([3 x i32]* @reltable.power_status to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.power_status to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.power_status to i64)) to i32)]
define void @power_status() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @vmstatus(i32 %4)
%6 = icmp ult i32 %5, 3
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.power_status to i8*), i64 %9)
br label %11
11: ; preds = %0, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %0 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
ret void
}