#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 */
typedef int uint8_t;

/* Variables and functions */
const char *get_state_str(uint8_t state) {
  switch (state) {
  case 0x11:
    return "on";
  case 0x12:
    return "on (no voltage!)";
  case 0x22:
    return "off";
  case 0x21:
    return "off (VOLTAGE IS PRESENT!)";
  }
  return "unknown";
}


x86 assembly (clang, -O0):
<get_state_str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffef,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x11,%eax
ja     1170 <get_state_str+0x70>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf11(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117b <get_state_str+0x7b>
lea    0xf04(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117b <get_state_str+0x7b>
lea    0xf05(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117b <get_state_str+0x7b>
lea    0xef9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117b <get_state_str+0x7b>
lea    0xf03(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_state_str>:
add    $0xffffffef,%edi
cmp    $0x11,%edi
ja     1127 <get_state_str+0x27>
lea    0xf39(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf25(%rip),%rax
ret
lea    0xf4c(%rip),%rax
ret
lea    0xf2a(%rip),%rax
ret
lea    0xf1e(%rip),%rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [17 x i8] c"on (no voltage!)\00"
@.str.2 = [4 x i8] c"off\00"
@.str.3 = [26 x i8] c"off (VOLTAGE IS PRESENT!)\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @get_state_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %9 [
i32 17, label %5
i32 18, label %6
i32 34, label %7
i32 33, label %8
]
5: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %10
6: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %10
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %10
8: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %10
9: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %10
10: ; preds = %9, %8, %7, %6, %5
%11 = load i8*, i8** %2
ret i8* %11
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [17 x i8] c"on (no voltage!)\00"
@.str.2 = [4 x i8] c"off\00"
@.str.3 = [26 x i8] c"off (VOLTAGE IS PRESENT!)\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @get_state_str(i32 %0) {
switch i32 %0, label %5 [
i32 17, label %6
i32 18, label %2
i32 34, label %3
i32 33, label %4
]
2: ; preds = %1
br label %6
3: ; preds = %1
br label %6
4: ; preds = %1
br label %6
5: ; preds = %1
br label %6
6: ; preds = %1, %5, %4, %3, %2
%7 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %7
}