#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 */

/* Variables and functions */
char *strdup(char *);
char *getProto(int proto) {
  switch (proto) {
  case 0:
    return (strdup("all"));
    break;
  case 1:
    return (strdup("icmp"));
    break;
  case 6:
    return (strdup("tcp"));
    break;
  case 17:
    return (strdup("udp"));
    break;
  case 43:
    return (strdup("RH"));
    break;
  case 44:
    return (strdup("FH"));
    break;
  case 58:
    return (strdup("icmpv6"));
    break;
  case 59:
    return (strdup("none"));
    break;
  case 60:
    return (strdup("HDT"));
    break;
  case 89:
    return (strdup("OSPF"));
    break;
  default:
    return (strdup(""));
    break;
  }
}


x86 assembly (clang, -O0):
<getProto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x59,%rax
ja     1212 <getProto+0x102>
mov    -0x18(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1021(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0x1010(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0x1000(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xfef(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xfde(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xfcc(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xfba(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xfac(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xf9c(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xf8b(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1222 <getProto+0x112>
lea    0xf6c(%rip),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getProto>:
cmp    $0x59,%edi
ja     113f <getProto+0x2f>
mov    %edi,%eax
lea    0xee2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x103a(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0x1032(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0x103f(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0x101f(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0x1017(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0x100f(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0x1006(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0xffd(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0xff8(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0xff1(%rip),%rdi
jmp    1030 <strdup@plt>
lea    0xfe9(%rip),%rdi
jmp    1030 <strdup@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"all\00"
@.str.1 = [5 x i8] c"icmp\00"
@.str.2 = [4 x i8] c"tcp\00"
@.str.3 = [4 x i8] c"udp\00"
@.str.4 = [3 x i8] c"RH\00"
@.str.5 = [3 x i8] c"FH\00"
@.str.6 = [7 x i8] c"icmpv6\00"
@.str.7 = [5 x i8] c"none\00"
@.str.8 = [4 x i8] c"HDT\00"
@.str.9 = [5 x i8] c"OSPF\00"
@.str.10 = [1 x i8] zeroinitializer
define i8* @getProto(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %25 [
i32 0, label %5
i32 1, label %7
i32 6, label %9
i32 17, label %11
i32 43, label %13
i32 44, label %15
i32 58, label %17
i32 59, label %19
i32 60, label %21
i32 89, label %23
]
5: ; preds = %1
%6 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %2
br label %27
7: ; preds = %1
%8 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %2
br label %27
9: ; preds = %1
%10 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %10, i8** %2
br label %27
11: ; preds = %1
%12 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %12, i8** %2
br label %27
13: ; preds = %1
%14 = call i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i8* %14, i8** %2
br label %27
15: ; preds = %1
%16 = call i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i8* %16, i8** %2
br label %27
17: ; preds = %1
%18 = call i8* @strdup(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i8* %18, i8** %2
br label %27
19: ; preds = %1
%20 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
store i8* %20, i8** %2
br label %27
21: ; preds = %1
%22 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
store i8* %22, i8** %2
br label %27
23: ; preds = %1
%24 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i8* %24, i8** %2
br label %27
25: ; preds = %1
%26 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
store i8* %26, i8** %2
br label %27
27: ; preds = %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@.str = [4 x i8] c"all\00"
@.str.1 = [5 x i8] c"icmp\00"
@.str.2 = [4 x i8] c"tcp\00"
@.str.3 = [4 x i8] c"udp\00"
@.str.4 = [3 x i8] c"RH\00"
@.str.5 = [3 x i8] c"FH\00"
@.str.6 = [7 x i8] c"icmpv6\00"
@.str.7 = [5 x i8] c"none\00"
@.str.8 = [4 x i8] c"HDT\00"
@.str.9 = [5 x i8] c"OSPF\00"
@.str.10 = [1 x i8] zeroinitializer
define noalias i8* @getProto(i32 %0) {
switch i32 %0, label %22 [
i32 0, label %2
i32 1, label %4
i32 6, label %6
i32 17, label %8
i32 43, label %10
i32 44, label %12
i32 58, label %14
i32 59, label %16
i32 60, label %18
i32 89, label %20
]
2: ; preds = %1
%3 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %24
4: ; preds = %1
%5 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %24
6: ; preds = %1
%7 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %24
8: ; preds = %1
%9 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %24
10: ; preds = %1
%11 = tail call dereferenceable_or_null(3) i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %24
12: ; preds = %1
%13 = tail call dereferenceable_or_null(3) i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %24
14: ; preds = %1
%15 = tail call dereferenceable_or_null(7) i8* @strdup(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %24
16: ; preds = %1
%17 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %24
18: ; preds = %1
%19 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %24
20: ; preds = %1
%21 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %24
22: ; preds = %1
%23 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16, %14, %12, %10, %8, %6, %4, %2
%25 = phi i8* [ %23, %22 ], [ %21, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ %3, %2 ]
ret i8* %25
}