#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 *, ...);
void thermostat_mode_dump(void *data, void *payload, int len) {
  unsigned char *pp = (unsigned char *)payload;
  if (pp[0] != 0x03) {
    printf("Impossible command %x\n", pp[0]);
    return;
  }
  switch (pp[1]) {
  case 0:
    printf("Mode is idle\n");
    break;
  case 1:
    printf("Mode is heat\n");
    break;
  case 2:
    printf("Mode is cool\n");
    break;
  case 3:
    printf("Mode is auto\n");
    break;
  case 4:
    printf("Mode is aux\n");
    break;
  case 5:
    printf("Mode is resume\n");
    break;
  case 6:
    printf("Mode is fan\n");
    break;
  case 7:
    printf("Mode is furance\n");
    break;
  case 8:
    printf("Mode is dryair\n");
    break;
  case 9:
    printf("Mode is moistair\n");
    break;
  case 10:
    printf("Mode is autochangeover\n");
    break;
  default:
    printf("Mode is unknown(%d)\n", pp[1]);
  }
}


x86 assembly (clang, -O0):
<thermostat_mode_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x3,%eax
je     1155 <thermostat_mode_dump+0x45>
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    %rax,-0x28(%rbp)
sub    $0xa,%rax
ja     1250 <thermostat_mode_dump+0x140>
mov    -0x28(%rbp),%rax
lea    0xe8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <thermostat_mode_dump+0x156>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thermostat_mode_dump>:
mov    %rsi,%rax
movzbl (%rsi),%esi
cmp    $0x3,%esi
jne    1151 <thermostat_mode_dump+0x31>
movzbl 0x1(%rax),%esi
cmp    $0xa,%rsi
ja     115f <thermostat_mode_dump+0x3f>
lea    0xec4(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xfa1(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xedd(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xf6c(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf53(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf3a(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf22(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf07(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xeef(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xed3(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xeb8(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xe9b(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xe78(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Impossible command %x\0A\00"
@.str.1 = [14 x i8] c"Mode is idle\0A\00"
@.str.2 = [14 x i8] c"Mode is heat\0A\00"
@.str.3 = [14 x i8] c"Mode is cool\0A\00"
@.str.4 = [14 x i8] c"Mode is auto\0A\00"
@.str.5 = [13 x i8] c"Mode is aux\0A\00"
@.str.6 = [16 x i8] c"Mode is resume\0A\00"
@.str.7 = [13 x i8] c"Mode is fan\0A\00"
@.str.8 = [17 x i8] c"Mode is furance\0A\00"
@.str.9 = [16 x i8] c"Mode is dryair\0A\00"
@.str.10 = [18 x i8] c"Mode is moistair\0A\00"
@.str.11 = [24 x i8] c"Mode is autochangeover\0A\00"
@.str.12 = [21 x i8] c"Mode is unknown(%d)\0A\00"
define void @thermostat_mode_dump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %53
20: ; preds = %3
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
switch i32 %24, label %47 [
i32 0, label %25
i32 1, label %27
i32 2, label %29
i32 3, label %31
i32 4, label %33
i32 5, label %35
i32 6, label %37
i32 7, label %39
i32 8, label %41
i32 9, label %43
i32 10, label %45
]
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %53
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %53
29: ; preds = %20
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %53
31: ; preds = %20
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %53
33: ; preds = %20
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %53
35: ; preds = %20
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %53
37: ; preds = %20
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %53
39: ; preds = %20
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %53
41: ; preds = %20
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %53
43: ; preds = %20
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %53
45: ; preds = %20
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %53
47: ; preds = %20
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %14, %47, %45, %43, %41, %39, %37, %35, %33, %31, %29, %27, %25
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Impossible command %x\0A\00"
@.str.12 = [21 x i8] c"Mode is unknown(%d)\0A\00"
@str = [23 x i8] c"Mode is autochangeover\00"
@str.13 = [17 x i8] c"Mode is moistair\00"
@str.14 = [15 x i8] c"Mode is dryair\00"
@str.15 = [16 x i8] c"Mode is furance\00"
@str.16 = [12 x i8] c"Mode is fan\00"
@str.17 = [15 x i8] c"Mode is resume\00"
@str.18 = [12 x i8] c"Mode is aux\00"
@str.19 = [13 x i8] c"Mode is auto\00"
@str.20 = [13 x i8] c"Mode is cool\00"
@str.21 = [13 x i8] c"Mode is heat\00"
@str.22 = [13 x i8] c"Mode is idle\00"
define void @thermostat_mode_dump(i8* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 3
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = zext i8 %4 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %37
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %1, i64 1
%11 = load i8, i8* %10
switch i8 %11, label %34 [
i8 0, label %12
i8 1, label %14
i8 2, label %16
i8 3, label %18
i8 4, label %20
i8 5, label %22
i8 6, label %24
i8 7, label %26
i8 8, label %28
i8 9, label %30
i8 10, label %32
]
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.22, i64 0, i64 0))
br label %37
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.21, i64 0, i64 0))
br label %37
16: ; preds = %9
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.20, i64 0, i64 0))
br label %37
18: ; preds = %9
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.19, i64 0, i64 0))
br label %37
20: ; preds = %9
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
br label %37
22: ; preds = %9
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.17, i64 0, i64 0))
br label %37
24: ; preds = %9
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.16, i64 0, i64 0))
br label %37
26: ; preds = %9
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.15, i64 0, i64 0))
br label %37
28: ; preds = %9
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
br label %37
30: ; preds = %9
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
br label %37
32: ; preds = %9
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %37
34: ; preds = %9
%35 = zext i8 %11 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %12, %14, %16, %18, %20, %22, %24, %26, %28, %30, %32, %34, %6
ret void
}