#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 uint8_t;

/* Variables and functions */
char *tlv_typetoname(uint8_t tlv_type) {
  switch (tlv_type) {
  case 1:
    return "Chassis ID";
    break;
  case 2:
    return "Port ID";
    break;
  case 3:
    return "Time To Live";
    break;
  case 4:
    return "Port Description";
    break;
  case 5:
    return "System Name";
    break;
  case 6:
    return "System Description";
    break;
  case 7:
    return "System Capabiltiies";
    break;
  case 8:
    return "Management Address";
    break;
  case 127:
    return "Organizationally Specific";
    break;
  case 0:
    return "End Of LLDPDU";
    break;
  default:
    return "Unknown";
  };
}


x86 assembly (clang, -O0):
<tlv_typetoname>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1243 <tlv_typetoname+0x143>
jmp    111a <tlv_typetoname+0x1a>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11b3 <tlv_typetoname+0xb3>
jmp    112b <tlv_typetoname+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11c3 <tlv_typetoname+0xc3>
jmp    113c <tlv_typetoname+0x3c>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11d3 <tlv_typetoname+0xd3>
jmp    114d <tlv_typetoname+0x4d>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     11e3 <tlv_typetoname+0xe3>
jmp    115e <tlv_typetoname+0x5e>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     11f3 <tlv_typetoname+0xf3>
jmp    116f <tlv_typetoname+0x6f>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     1203 <tlv_typetoname+0x103>
jmp    1180 <tlv_typetoname+0x80>
mov    -0x10(%rbp),%eax
sub    $0x7,%eax
je     1213 <tlv_typetoname+0x113>
jmp    1191 <tlv_typetoname+0x91>
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
je     1223 <tlv_typetoname+0x123>
jmp    11a2 <tlv_typetoname+0xa2>
mov    -0x10(%rbp),%eax
sub    $0x7f,%eax
je     1233 <tlv_typetoname+0x133>
jmp    1253 <tlv_typetoname+0x153>
lea    0xe46(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe39(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe36(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe37(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe33(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe36(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe3a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe3d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe47(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125e <tlv_typetoname+0x15e>
lea    0xe45(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tlv_typetoname>:
cmp    $0x8,%edi
ja     1126 <tlv_typetoname+0x26>
lea    0xf18(%rip),%rax
mov    %edi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf90(%rip),%rax
ret
cmp    $0x7f,%edi
jne    116b <tlv_typetoname+0x6b>
lea    0xf69(%rip),%rax
ret
lea    0xef5(%rip),%rax
ret
lea    0xef5(%rip),%rax
ret
lea    0xefa(%rip),%rax
ret
lea    0xf03(%rip),%rax
ret
lea    0xf07(%rip),%rax
ret
lea    0xf12(%rip),%rax
ret
lea    0xf1e(%rip),%rax
ret
lea    0xf51(%rip),%rax
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Chassis ID\00"
@.str.1 = [8 x i8] c"Port ID\00"
@.str.2 = [13 x i8] c"Time To Live\00"
@.str.3 = [17 x i8] c"Port Description\00"
@.str.4 = [12 x i8] c"System Name\00"
@.str.5 = [19 x i8] c"System Description\00"
@.str.6 = [20 x i8] c"System Capabiltiies\00"
@.str.7 = [19 x i8] c"Management Address\00"
@.str.8 = [26 x i8] c"Organizationally Specific\00"
@.str.9 = [14 x i8] c"End Of LLDPDU\00"
@.str.10 = [8 x i8] c"Unknown\00"
define i8* @tlv_typetoname(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
i32 127, label %13
i32 0, label %14
]
5: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %16
6: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %16
7: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %16
8: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %16
9: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %16
10: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %16
11: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %16
12: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %16
13: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %16
14: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %16
15: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %16
16: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@.str = [11 x i8] c"Chassis ID\00"
@.str.1 = [8 x i8] c"Port ID\00"
@.str.2 = [13 x i8] c"Time To Live\00"
@.str.3 = [17 x i8] c"Port Description\00"
@.str.4 = [12 x i8] c"System Name\00"
@.str.5 = [19 x i8] c"System Description\00"
@.str.6 = [20 x i8] c"System Capabiltiies\00"
@.str.7 = [19 x i8] c"Management Address\00"
@.str.8 = [26 x i8] c"Organizationally Specific\00"
@.str.9 = [14 x i8] c"End Of LLDPDU\00"
@.str.10 = [8 x i8] c"Unknown\00"
define i8* @tlv_typetoname(i32 %0) {
switch i32 %0, label %11 [
i32 1, label %12
i32 2, label %2
i32 3, label %3
i32 4, label %4
i32 5, label %5
i32 6, label %6
i32 7, label %7
i32 8, label %8
i32 127, label %9
i32 0, label %10
]
2: ; preds = %1
br label %12
3: ; preds = %1
br label %12
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
br label %12
11: ; preds = %1
br label %12
12: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%13 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %13
}