#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 */
typedef int u_int8_t;

/* Variables and functions */
char *type(u_int8_t type) {
  char *str;
  switch (type) {
  case 1:
    str = "DESTINATION UNREACHABLE";
    break;
  case 2:
    str = "PACKET TOO BIG";
    break;
  case 3:
    str = "TIME EXCEEDED";
    break;
  case 4:
    str = "PARAMETER PROBLEM";
    break;
  case 128:
    str = "ECHO REQUEST";
    break;
  case 129:
    str = "ECHO REPLY";
    break;
  case 133:
    str = "ROUTER SOLICIT";
    break;
  case 134:
    str = "ROUTER ADVERTISEMENT";
    break;
  case 135:
    str = "NEIGHBOR SOLICIT";
    break;
  case 136:
    str = "NEIGHBOR ADVERTISEMENT";
    break;
  case 137:
    str = "REDIRECT";
    break;
  default:
    str = "UNKNOWN";
    break;
  }
  return str;
}


x86 assembly (clang, -O0):
<type>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     11d3 <type+0xd3>
jmp    111b <type+0x1b>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11e3 <type+0xe3>
jmp    112c <type+0x2c>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     11f3 <type+0xf3>
jmp    113d <type+0x3d>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     1203 <type+0x103>
jmp    114e <type+0x4e>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
je     1213 <type+0x113>
jmp    1161 <type+0x61>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
je     1223 <type+0x123>
jmp    1174 <type+0x74>
mov    -0x14(%rbp),%eax
sub    $0x85,%eax
je     1233 <type+0x133>
jmp    1187 <type+0x87>
mov    -0x14(%rbp),%eax
sub    $0x86,%eax
je     1243 <type+0x143>
jmp    119a <type+0x9a>
mov    -0x14(%rbp),%eax
sub    $0x87,%eax
je     1253 <type+0x153>
jmp    11ad <type+0xad>
mov    -0x14(%rbp),%eax
sub    $0x88,%eax
je     1263 <type+0x163>
jmp    11c0 <type+0xc0>
mov    -0x14(%rbp),%eax
sub    $0x89,%eax
je     1273 <type+0x173>
jmp    1283 <type+0x183>
lea    0xe26(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2e(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2b(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe25(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe24(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe29(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe31(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    128e <type+0x18e>
lea    0xe2a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<type>:
lea    -0x80(%rdi),%eax
cmp    $0x9,%eax
ja     1120 <type+0x20>
lea    0xf01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf60(%rip),%rax
ret
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     1147 <type+0x47>
lea    0xf09(%rip),%rax
lea    0xeca(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf0a(%rip),%rax
ret
lea    0xf9e(%rip),%rax
ret
lea    0xf36(%rip),%rax
ret
lea    0xf39(%rip),%rax
ret
lea    0xf40(%rip),%rax
ret
lea    0xf4d(%rip),%rax
ret
lea    0xf56(%rip),%rax
ret
lea    0xf65(%rip),%rax
ret
lea    0xed9(%rip),%rax
ret
lea    0xedf(%rip),%rax
ret

LLVM IR (-O0):
@.str = [24 x i8] c"DESTINATION UNREACHABLE\00"
@.str.1 = [15 x i8] c"PACKET TOO BIG\00"
@.str.2 = [14 x i8] c"TIME EXCEEDED\00"
@.str.3 = [18 x i8] c"PARAMETER PROBLEM\00"
@.str.4 = [13 x i8] c"ECHO REQUEST\00"
@.str.5 = [11 x i8] c"ECHO REPLY\00"
@.str.6 = [15 x i8] c"ROUTER SOLICIT\00"
@.str.7 = [21 x i8] c"ROUTER ADVERTISEMENT\00"
@.str.8 = [17 x i8] c"NEIGHBOR SOLICIT\00"
@.str.9 = [23 x i8] c"NEIGHBOR ADVERTISEMENT\00"
@.str.10 = [9 x i8] c"REDIRECT\00"
@.str.11 = [8 x i8] c"UNKNOWN\00"
define i8* @type(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %16 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 128, label %9
i32 129, label %10
i32 133, label %11
i32 134, label %12
i32 135, label %13
i32 136, label %14
i32 137, label %15
]
5: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %3
br label %17
6: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %17
7: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %17
8: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %17
9: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %17
10: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %17
11: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %17
12: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %17
13: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %17
14: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %17
15: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %17
16: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [24 x i8] c"DESTINATION UNREACHABLE\00"
@.str.1 = [15 x i8] c"PACKET TOO BIG\00"
@.str.2 = [14 x i8] c"TIME EXCEEDED\00"
@.str.3 = [18 x i8] c"PARAMETER PROBLEM\00"
@.str.4 = [13 x i8] c"ECHO REQUEST\00"
@.str.5 = [11 x i8] c"ECHO REPLY\00"
@.str.6 = [15 x i8] c"ROUTER SOLICIT\00"
@.str.7 = [21 x i8] c"ROUTER ADVERTISEMENT\00"
@.str.8 = [17 x i8] c"NEIGHBOR SOLICIT\00"
@.str.9 = [23 x i8] c"NEIGHBOR ADVERTISEMENT\00"
@.str.10 = [9 x i8] c"REDIRECT\00"
@.str.11 = [8 x i8] c"UNKNOWN\00"
define i8* @type(i32 %0) {
switch i32 %0, label %12 [
i32 1, label %13
i32 2, label %2
i32 3, label %3
i32 4, label %4
i32 128, label %5
i32 129, label %6
i32 133, label %7
i32 134, label %8
i32 135, label %9
i32 136, label %10
i32 137, label %11
]
2: ; preds = %1
br label %13
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
br label %13
10: ; preds = %1
br label %13
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%14 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %14
}