char *pwr_string(unsigned char pstate) {
  char *pstr;
  switch (pstate) {
  case 0x00:
    pstr = "S0: working";
    break;
  case 0x01:
    pstr = "S1: clock stopped, context ok";
    break;
  case 0x02:
    pstr = "S2: clock stopped, context lost";
    break;
  case 0x03:
    pstr = "S3: suspend-to-RAM";
    break;
  case 0x04:
    pstr = "S4: suspend-to-Disk";
    break;
  case 0x05:
    pstr = "S5: soft off";
    break;
  case 0x06:
    pstr = "S4/S5: soft off, either S4 or S5";
    break;
  case 0x07:
    pstr = "G3: mechanical off";
    break;
  case 0x08:
    pstr = "S1-S3: sleeping";
    break;
  case 0x09:
    pstr = "S1-S4: sleeping";
    break;
  case 0x0A:
    pstr = "S5/o: soft off by override";
    break;
  case 0x20:
    pstr = "legacy on";
    break;
  case 0x21:
    pstr = "legacy soft-off";
    break;
  case 0x2a:
  default:
    pstr = "unknown";
    break;
  }
  return (pstr);
}


x86 assembly (clang, -O0):
<pwr_string>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x2a,%rax
ja     1205 <pwr_string+0x105>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf75(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xf71(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xf7f(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xf8f(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xf92(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xf96(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xf93(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xfa4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xfa7(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xfa7(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xfa7(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xfb2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
lea    0xfac(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <pwr_string+0x110>
jmp    1205 <pwr_string+0x105>
lea    0xfa7(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwr_string>:
cmp    $0x21,%dil
ja     116f <pwr_string+0x6f>
lea    0xf7b(%rip),%rax
mov    %edi,%ecx
lea    0xeea(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf6e(%rip),%rax
ret
lea    0xf84(%rip),%rax
ret
lea    0xf9c(%rip),%rax
ret
lea    0xfa7(%rip),%rax
ret
lea    0xfb3(%rip),%rax
ret
lea    0xfb8(%rip),%rax
ret
lea    0xfd1(%rip),%rax
ret
lea    0xfdc(%rip),%rax
ret
lea    0xfe4(%rip),%rax
ret
lea    0xfec(%rip),%rax
ret
lea    0x1019(%rip),%rax
ret
lea    0xff7(%rip),%rax
ret
lea    0xff9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [12 x i8] c"S0: working\00"
@.str.1 = [30 x i8] c"S1: clock stopped, context ok\00"
@.str.2 = [32 x i8] c"S2: clock stopped, context lost\00"
@.str.3 = [19 x i8] c"S3: suspend-to-RAM\00"
@.str.4 = [20 x i8] c"S4: suspend-to-Disk\00"
@.str.5 = [13 x i8] c"S5: soft off\00"
@.str.6 = [33 x i8] c"S4/S5: soft off, either S4 or S5\00"
@.str.7 = [19 x i8] c"G3: mechanical off\00"
@.str.8 = [16 x i8] c"S1-S3: sleeping\00"
@.str.9 = [16 x i8] c"S1-S4: sleeping\00"
@.str.10 = [27 x i8] c"S5/o: soft off by override\00"
@.str.11 = [10 x i8] c"legacy on\00"
@.str.12 = [16 x i8] c"legacy soft-off\00"
@.str.13 = [8 x i8] c"unknown\00"
define i8* @pwr_string(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8*
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
switch i32 %5, label %20 [
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %13
i32 8, label %14
i32 9, label %15
i32 10, label %16
i32 32, label %17
i32 33, label %18
i32 42, label %19
]
6: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %3
br label %21
7: ; preds = %1
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %21
8: ; preds = %1
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %21
9: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %21
10: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %21
11: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %21
12: ; preds = %1
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %21
13: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %21
14: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %21
15: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %21
16: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %21
17: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %21
18: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %21
19: ; preds = %1
br label %20
20: ; preds = %1, %19
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %21
21: ; preds = %20, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [12 x i8] c"S0: working\00"
@.str.1 = [30 x i8] c"S1: clock stopped, context ok\00"
@.str.2 = [32 x i8] c"S2: clock stopped, context lost\00"
@.str.3 = [19 x i8] c"S3: suspend-to-RAM\00"
@.str.4 = [20 x i8] c"S4: suspend-to-Disk\00"
@.str.5 = [13 x i8] c"S5: soft off\00"
@.str.6 = [33 x i8] c"S4/S5: soft off, either S4 or S5\00"
@.str.7 = [19 x i8] c"G3: mechanical off\00"
@.str.8 = [16 x i8] c"S1-S3: sleeping\00"
@.str.9 = [16 x i8] c"S1-S4: sleeping\00"
@.str.10 = [27 x i8] c"S5/o: soft off by override\00"
@.str.11 = [10 x i8] c"legacy on\00"
@.str.12 = [16 x i8] c"legacy soft-off\00"
@.str.13 = [8 x i8] c"unknown\00"
define i8* @pwr_string(i8 zeroext %0) {
switch i8 %0, label %14 [
i8 0, label %15
i8 1, label %2
i8 2, label %3
i8 3, label %4
i8 4, label %5
i8 5, label %6
i8 6, label %7
i8 7, label %8
i8 8, label %9
i8 9, label %10
i8 10, label %11
i8 32, label %12
i8 33, label %13
]
2: ; preds = %1
br label %15
3: ; preds = %1
br label %15
4: ; preds = %1
br label %15
5: ; preds = %1
br label %15
6: ; preds = %1
br label %15
7: ; preds = %1
br label %15
8: ; preds = %1
br label %15
9: ; preds = %1
br label %15
10: ; preds = %1
br label %15
11: ; preds = %1
br label %15
12: ; preds = %1
br label %15
13: ; preds = %1
br label %15
14: ; preds = %1
br label %15
15: ; preds = %1, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%16 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), %14 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), %13 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %16
}