char *reset_str(unsigned char breset, unsigned char bopt) {
  char *str;
  switch (breset) {
  case 0:
    str = "powering down";
    break;
  case 1:
    str = "powering up";
    break;
  case 2:
    str = "power cycling";
    break;
  case 3:
    str = "resetting";
    break;
  case 4:
    str = "sending NMI";
    break;
  case 5:
    str = "shutdown/reset";
    break;
  case 6:
    str = "shutdown/power_off";
    break;
  case 7:
    str = "cold reset";
    break;
  default:
    str = "resetting";
    break;
  }
  if (bopt > 0)
    switch (bopt) {
    case 1:
      str = "resetting to Svc partition";
      break;
    case 2:
      str = "resetting to EFI";
      break;
    case 3:
      str = "resetting to PXE";
      break;
    case 4:
      str = "resetting to CDROM";
      break;
    case 5:
      str = "resetting to hard disk";
      break;
    case 6:
      str = "resetting to BIOS Setup";
      break;
    case 7:
      str = "resetting to floppy";
      break;
    default:
      str = "resetting";
      break;
    }
  return (str);
}


x86 assembly (clang, -O0):
<reset_str>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x7,%rax
ja     11b6 <reset_str+0xb6>
mov    -0x18(%rbp),%rax
lea    0xed3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeff(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xefd(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xef9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xef7(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xef1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xeed(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xeec(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xeef(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <reset_str+0xc1>
lea    0xea7(%rip),%rax
mov    %rax,-0x10(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x0,%eax
jle    1278 <reset_str+0x178>
movzbl -0x2(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x6,%eax
ja     1268 <reset_str+0x168>
mov    -0x20(%rbp),%rax
lea    0xe31(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xeb3(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xeb4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xeb5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xeb8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xebf(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xec7(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <reset_str+0x173>
lea    0xdf5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1278 <reset_str+0x178>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_str>:
cmp    $0x7,%dil
ja     113a <reset_str+0x3a>
movsbq %dil,%rax
lea    0xf0f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
cmp    $0x7,%sil
ja     1147 <reset_str+0x47>
movzbl %sil,%ecx
lea    0xed7(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf72(%rip),%rax
ret
lea    0xf27(%rip),%rax
cmp    $0x7,%sil
jbe    111e <reset_str+0x1e>
lea    0xf1a(%rip),%rax
ret
lea    0xf70(%rip),%rax
ret
lea    0xf79(%rip),%rax
ret
lea    0xf82(%rip),%rax
ret
lea    0xf8d(%rip),%rax
ret
lea    0xf9c(%rip),%rax
ret
lea    0xfac(%rip),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"powering down\00"
@.str.1 = [12 x i8] c"powering up\00"
@.str.2 = [14 x i8] c"power cycling\00"
@.str.3 = [10 x i8] c"resetting\00"
@.str.4 = [12 x i8] c"sending NMI\00"
@.str.5 = [15 x i8] c"shutdown/reset\00"
@.str.6 = [19 x i8] c"shutdown/power_off\00"
@.str.7 = [11 x i8] c"cold reset\00"
@.str.8 = [27 x i8] c"resetting to Svc partition\00"
@.str.9 = [17 x i8] c"resetting to EFI\00"
@.str.10 = [17 x i8] c"resetting to PXE\00"
@.str.11 = [19 x i8] c"resetting to CDROM\00"
@.str.12 = [23 x i8] c"resetting to hard disk\00"
@.str.13 = [24 x i8] c"resetting to BIOS Setup\00"
@.str.14 = [20 x i8] c"resetting to floppy\00"
define i8* @reset_str(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %3
store i8 %1, i8* %4
%6 = load i8, i8* %3
%7 = zext i8 %6 to i32
switch i32 %7, label %16 [
i32 0, label %8
i32 1, label %9
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
i32 7, label %15
]
8: ; preds = %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %5
br label %17
9: ; preds = %2
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %17
10: ; preds = %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %17
11: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %17
12: ; preds = %2
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %5
br label %17
13: ; preds = %2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %5
br label %17
14: ; preds = %2
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8** %5
br label %17
15: ; preds = %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8** %5
br label %17
16: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i8, i8* %4
%23 = zext i8 %22 to i32
switch i32 %23, label %31 [
i32 1, label %24
i32 2, label %25
i32 3, label %26
i32 4, label %27
i32 5, label %28
i32 6, label %29
i32 7, label %30
]
24: ; preds = %21
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8** %5
br label %32
25: ; preds = %21
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8** %5
br label %32
26: ; preds = %21
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8** %5
br label %32
27: ; preds = %21
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8** %5
br label %32
28: ; preds = %21
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0), i8** %5
br label %32
29: ; preds = %21
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8** %5
br label %32
30: ; preds = %21
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8** %5
br label %32
31: ; preds = %21
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %32
32: ; preds = %31, %30, %29, %28, %27, %26, %25, %24
br label %33
33: ; preds = %32, %17
%34 = load i8*, i8** %5
ret i8* %34
}

LLVM IR (-O2):
@.str = [14 x i8] c"powering down\00"
@.str.1 = [12 x i8] c"powering up\00"
@.str.2 = [14 x i8] c"power cycling\00"
@.str.3 = [10 x i8] c"resetting\00"
@.str.4 = [12 x i8] c"sending NMI\00"
@.str.5 = [15 x i8] c"shutdown/reset\00"
@.str.6 = [19 x i8] c"shutdown/power_off\00"
@.str.7 = [11 x i8] c"cold reset\00"
@.str.8 = [27 x i8] c"resetting to Svc partition\00"
@.str.9 = [17 x i8] c"resetting to EFI\00"
@.str.10 = [17 x i8] c"resetting to PXE\00"
@.str.11 = [19 x i8] c"resetting to CDROM\00"
@.str.12 = [23 x i8] c"resetting to hard disk\00"
@.str.13 = [24 x i8] c"resetting to BIOS Setup\00"
@.str.14 = [20 x i8] c"resetting to floppy\00"
@reltable.reset_str = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.reset_str to i64)) to i32)]
define i8* @reset_str(i8 zeroext %0, i8 zeroext %1) {
%3 = icmp ult i8 %0, 8
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = sext i8 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.reset_str to i8*), i64 %6)
br label %8
8: ; preds = %2, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %2 ]
switch i8 %1, label %17 [
i8 0, label %18
i8 1, label %10
i8 2, label %11
i8 3, label %12
i8 4, label %13
i8 5, label %14
i8 6, label %15
i8 7, label %16
]
10: ; preds = %8
br label %18
11: ; preds = %8
br label %18
12: ; preds = %8
br label %18
13: ; preds = %8
br label %18
14: ; preds = %8
br label %18
15: ; preds = %8
br label %18
16: ; preds = %8
br label %18
17: ; preds = %8
br label %18
18: ; preds = %8, %10, %11, %12, %13, %14, %15, %16, %17
%19 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %17 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), %16 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), %15 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0), %14 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), %13 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), %10 ], [ %9, %8 ]
ret i8* %19
}