char *pr_type(unsigned char t) {
  switch (t) {
  case 0:
    return "Error";
  case 1:
    return "Destination Unreachable";
  case 2:
    return "Packet Too Big";
  case 3:
    return "Time Exceeded in Transit";
  case 4:
    return "Parameter Problem";
  case 128:
    return "Echo Request";
  case 129:
    return "Echo Reply";
  case 130:
    return "Membership Query";
  case 131:
    return "Membership Report";
  case 132:
    return "Membership Reduction";
  case 133:
    return "Router Solicitation";
  case 134:
    return "Router Advertisement";
  case 135:
    return "Neighbor Solicitation";
  case 136:
    return "Neighbor Advertisement";
  case 137:
    return "Redirect";
  }
  return ("OUT-OF-RANGE");
}


x86 assembly (clang, -O0):
<pr_type>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x89,%rax
ja     1222 <pr_type+0x122>
mov    -0x18(%rbp),%rax
lea    0xed7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x10ef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10e5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10ed(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10ec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10f5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10f7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10f4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10ef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10f0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10f2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10f7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x10fb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x1100(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x1106(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x110d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <pr_type+0x12d>
lea    0x1106(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_type>:
add    $0x80,%dil
cmp    $0x84,%dil
ja     116d <pr_type+0x6d>
lea    0x1103(%rip),%rax
movzbl %dil,%ecx
lea    0xee4(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0x1140(%rip),%rax
ret
lea    0x1145(%rip),%rax
ret
lea    0x1148(%rip),%rax
ret
lea    0x1151(%rip),%rax
ret
lea    0x115b(%rip),%rax
ret
lea    0x1168(%rip),%rax
ret
lea    0x1174(%rip),%rax
ret
lea    0x1197(%rip),%rax
ret
lea    0x11a6(%rip),%rax
ret
lea    0x11a7(%rip),%rax
ret
lea    0x109e(%rip),%rax
ret
lea    0x10ae(%rip),%rax
ret
lea    0x10b5(%rip),%rax
ret
lea    0x10c6(%rip),%rax
ret
lea    0x1149(%rip),%rax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Error\00"
@.str.1 = [24 x i8] c"Destination Unreachable\00"
@.str.2 = [15 x i8] c"Packet Too Big\00"
@.str.3 = [25 x i8] c"Time Exceeded in Transit\00"
@.str.4 = [18 x i8] c"Parameter Problem\00"
@.str.5 = [13 x i8] c"Echo Request\00"
@.str.6 = [11 x i8] c"Echo Reply\00"
@.str.7 = [17 x i8] c"Membership Query\00"
@.str.8 = [18 x i8] c"Membership Report\00"
@.str.9 = [21 x i8] c"Membership Reduction\00"
@.str.10 = [20 x i8] c"Router Solicitation\00"
@.str.11 = [21 x i8] c"Router Advertisement\00"
@.str.12 = [22 x i8] c"Neighbor Solicitation\00"
@.str.13 = [23 x i8] c"Neighbor Advertisement\00"
@.str.14 = [9 x i8] c"Redirect\00"
@.str.15 = [13 x i8] c"OUT-OF-RANGE\00"
define i8* @pr_type(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
switch i32 %5, label %21 [
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 128, label %11
i32 129, label %12
i32 130, label %13
i32 131, label %14
i32 132, label %15
i32 133, label %16
i32 134, label %17
i32 135, label %18
i32 136, label %19
i32 137, label %20
]
6: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
7: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %22
8: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %22
9: ; preds = %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %22
10: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %22
11: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %22
12: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %22
13: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %22
14: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %22
15: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %22
16: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %22
17: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %22
18: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %22
19: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %22
20: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %22
21: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %22
22: ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.str = [6 x i8] c"Error\00"
@.str.1 = [24 x i8] c"Destination Unreachable\00"
@.str.2 = [15 x i8] c"Packet Too Big\00"
@.str.3 = [25 x i8] c"Time Exceeded in Transit\00"
@.str.4 = [18 x i8] c"Parameter Problem\00"
@.str.5 = [13 x i8] c"Echo Request\00"
@.str.6 = [11 x i8] c"Echo Reply\00"
@.str.7 = [17 x i8] c"Membership Query\00"
@.str.8 = [18 x i8] c"Membership Report\00"
@.str.9 = [21 x i8] c"Membership Reduction\00"
@.str.10 = [20 x i8] c"Router Solicitation\00"
@.str.11 = [21 x i8] c"Router Advertisement\00"
@.str.12 = [22 x i8] c"Neighbor Solicitation\00"
@.str.13 = [23 x i8] c"Neighbor Advertisement\00"
@.str.14 = [9 x i8] c"Redirect\00"
@.str.15 = [13 x i8] c"OUT-OF-RANGE\00"
define i8* @pr_type(i8 zeroext %0) {
switch i8 %0, label %16 [
i8 0, label %17
i8 1, label %2
i8 2, label %3
i8 3, label %4
i8 4, label %5
i8 -128, label %6
i8 -127, label %7
i8 -126, label %8
i8 -125, label %9
i8 -124, label %10
i8 -123, label %11
i8 -122, label %12
i8 -121, label %13
i8 -120, label %14
i8 -119, label %15
]
2: ; preds = %1
br label %17
3: ; preds = %1
br label %17
4: ; preds = %1
br label %17
5: ; preds = %1
br label %17
6: ; preds = %1
br label %17
7: ; preds = %1
br label %17
8: ; preds = %1
br label %17
9: ; preds = %1
br label %17
10: ; preds = %1
br label %17
11: ; preds = %1
br label %17
12: ; preds = %1
br label %17
13: ; preds = %1
br label %17
14: ; preds = %1
br label %17
15: ; preds = %1
br label %17
16: ; preds = %1
br label %17
17: ; preds = %1, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%18 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0), %16 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), %15 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), %14 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), %13 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([11 x i8], [11 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 ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %18
}