char *IpProtToString(unsigned char prot) {
  switch (prot) {
  case 0x11:
    return "UDP";
  case 0x6:
    return "TCP";
  case 0x2f:
    return "GRE";
  case 0x1:
    return "ICMP";
  default:
    return "???";
  }
}


x86 assembly (clang, -O0):
<IpProtToString>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1182 <IpProtToString+0x82>
jmp    111f <IpProtToString+0x1f>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     1162 <IpProtToString+0x62>
jmp    1130 <IpProtToString+0x30>
mov    -0x10(%rbp),%eax
sub    $0x11,%eax
je     1152 <IpProtToString+0x52>
jmp    1141 <IpProtToString+0x41>
mov    -0x10(%rbp),%eax
sub    $0x2f,%eax
je     1172 <IpProtToString+0x72>
jmp    1192 <IpProtToString+0x92>
lea    0xea7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <IpProtToString+0x9d>
lea    0xe9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <IpProtToString+0x9d>
lea    0xe8f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <IpProtToString+0x9d>
lea    0xe83(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <IpProtToString+0x9d>
lea    0xe78(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<IpProtToString>:
cmp    $0x10,%dil
jg     111a <IpProtToString+0x1a>
cmp    $0x1,%dil
je     1136 <IpProtToString+0x36>
cmp    $0x6,%dil
jne    112e <IpProtToString+0x2e>
lea    0xeeb(%rip),%rax
ret
cmp    $0x11,%dil
je     113e <IpProtToString+0x3e>
cmp    $0x2f,%dil
jne    112e <IpProtToString+0x2e>
lea    0xedb(%rip),%rax
ret
lea    0xedc(%rip),%rax
ret
lea    0xecf(%rip),%rax
ret
lea    0xebb(%rip),%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"UDP\00"
@.str.1 = [4 x i8] c"TCP\00"
@.str.2 = [4 x i8] c"GRE\00"
@.str.3 = [5 x i8] c"ICMP\00"
@.str.4 = [4 x i8] c"???\00"
define i8* @IpProtToString(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 %10 [
i32 17, label %6
i32 6, label %7
i32 47, label %8
i32 1, label %9
]
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %11
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %11
8: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %11
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %11
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %11
11: ; preds = %10, %9, %8, %7, %6
%12 = load i8*, i8** %2
ret i8* %12
}

LLVM IR (-O2):
@.str = [4 x i8] c"UDP\00"
@.str.1 = [4 x i8] c"TCP\00"
@.str.2 = [4 x i8] c"GRE\00"
@.str.3 = [5 x i8] c"ICMP\00"
@.str.4 = [4 x i8] c"???\00"
define i8* @IpProtToString(i8 zeroext %0) {
switch i8 %0, label %5 [
i8 17, label %6
i8 6, label %2
i8 47, label %3
i8 1, 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 ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %7
}