#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 ProcessCommand(char *, char *);
int atoi(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int ReadPowerStatus(char ret[]) {
  char *status = NULL;
  int err;
  if (!(err = ProcessCommand(ret, "CR0\r"))) {
    switch (atoi((char *)ret)) {
    case 00:
      status = "power on";
      break;
    case 80:
      status = "stand-by";
      break;
    case 40:
      status = "processing countdown";
      break;
    case 20:
      status = "processing cooling down";
      break;
    case 10:
      status = "power failure";
      break;
    case 28:
      status = "processing cooling down due to abnormal temperature";
      break;
    case 88:
      status = "stand-by due to abnormal temperature or door failure";
      break;
    case 24:
      status = "processing power save / cooling down";
      break;
    case 04:
      status = "power save";
      break;
    case 21:
      status = "processing cooling down after lamp failure";
      break;
    case 81:
      status = "stand-by after cooling down due to lamp failure";
      break;
    }
    strcpy(ret, status);
  }
  return (err);
}


x86 assembly (clang, -O0):
<ReadPowerStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x1015(%rip),%rsi
call   1040 <ProcessCommand@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1244 <ReadPowerStatus+0x114>
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x58,%eax
ja     1237 <ReadPowerStatus+0x107>
mov    -0x20(%rbp),%rax
lea    0xe7d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfd6(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0xfcf(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0xfc8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0xfcd(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0xfd5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0xfd3(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0xff7(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0x101c(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0x1031(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0x102c(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <ReadPowerStatus+0x107>
lea    0x1047(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadPowerStatus>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x1027(%rip),%rsi
call   1040 <ProcessCommand@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11d6 <ReadPowerStatus+0xa6>
mov    %rbx,%rdi
call   1050 <atoi@plt>
xor    %esi,%esi
cmp    $0x58,%eax
ja     11ce <ReadPowerStatus+0x9e>
mov    %eax,%eax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xff5(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x10c7(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x1022(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x1001(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x10b7(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x107e(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x100c(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0xfc8(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0xfb6(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x10b5(%rip),%rsi
jmp    11ce <ReadPowerStatus+0x9e>
lea    0x101c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"CR0\0D\00"
@.str.1 = [9 x i8] c"power on\00"
@.str.2 = [9 x i8] c"stand-by\00"
@.str.3 = [21 x i8] c"processing countdown\00"
@.str.4 = [24 x i8] c"processing cooling down\00"
@.str.5 = [14 x i8] c"power failure\00"
@.str.6 = [52 x i8] c"processing cooling down due to abnormal temperature\00"
@.str.7 = [53 x i8] c"stand-by due to abnormal temperature or door failure\00"
@.str.8 = [37 x i8] c"processing power save / cooling down\00"
@.str.9 = [11 x i8] c"power save\00"
@.str.10 = [43 x i8] c"processing cooling down after lamp failure\00"
@.str.11 = [48 x i8] c"stand-by after cooling down due to lamp failure\00"
define i32 @ReadPowerStatus(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = call i32 @ProcessCommand(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @atoi(i8* %9)
switch i32 %10, label %22 [
i32 0, label %11
i32 80, label %12
i32 40, label %13
i32 20, label %14
i32 10, label %15
i32 28, label %16
i32 88, label %17
i32 24, label %18
i32 4, label %19
i32 21, label %20
i32 81, label %21
]
11: ; preds = %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %22
12: ; preds = %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %22
13: ; preds = %8
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %22
14: ; preds = %8
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %22
15: ; preds = %8
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %22
16: ; preds = %8
store i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %22
17: ; preds = %8
store i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %22
18: ; preds = %8
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %22
19: ; preds = %8
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %22
20: ; preds = %8
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %22
21: ; preds = %8
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %22
22: ; preds = %8, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11
%23 = load i8*, i8** %2
%24 = load i8*, i8** %3
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %26
26: ; preds = %22, %1
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [5 x i8] c"CR0\0D\00"
@.str.1 = [9 x i8] c"power on\00"
@.str.2 = [9 x i8] c"stand-by\00"
@.str.3 = [21 x i8] c"processing countdown\00"
@.str.4 = [24 x i8] c"processing cooling down\00"
@.str.5 = [14 x i8] c"power failure\00"
@.str.6 = [52 x i8] c"processing cooling down due to abnormal temperature\00"
@.str.7 = [53 x i8] c"stand-by due to abnormal temperature or door failure\00"
@.str.8 = [37 x i8] c"processing power save / cooling down\00"
@.str.9 = [11 x i8] c"power save\00"
@.str.10 = [43 x i8] c"processing cooling down after lamp failure\00"
@.str.11 = [48 x i8] c"stand-by after cooling down due to lamp failure\00"
define i32 @ReadPowerStatus(i8* %0) {
%2 = tail call i32 @ProcessCommand(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = tail call i32 @atoi(i8* %0)
switch i32 %5, label %17 [
i32 0, label %6
i32 80, label %7
i32 40, label %8
i32 20, label %9
i32 10, label %10
i32 28, label %11
i32 88, label %12
i32 24, label %13
i32 4, label %14
i32 21, label %15
i32 81, label %16
]
6: ; preds = %4
br label %17
7: ; preds = %4
br label %17
8: ; preds = %4
br label %17
9: ; preds = %4
br label %17
10: ; preds = %4
br label %17
11: ; preds = %4
br label %17
12: ; preds = %4
br label %17
13: ; preds = %4
br label %17
14: ; preds = %4
br label %17
15: ; preds = %4
br label %17
16: ; preds = %4
br label %17
17: ; preds = %4, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = phi i8* [ null, %4 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0), %16 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), %15 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), %12 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), %11 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %6 ]
%19 = tail call i32 @strcpy(i8* %0, i8* %18)
br label %20
20: ; preds = %17, %1
ret i32 %2
}