#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 */
#define ICMP_ADDRESS 140
#define ICMP_ADDRESSREPLY 139
#define ICMP_DEST_UNREACH 138
#define ICMP_ECHO 137
#define ICMP_ECHOREPLY 136
#define ICMP_INFO_REPLY 135
#define ICMP_INFO_REQUEST 134
#define ICMP_PARAMETERPROB 133
#define ICMP_REDIRECT 132
#define ICMP_SOURCE_QUENCH 131
#define ICMP_TIMESTAMP 130
#define ICMP_TIMESTAMPREPLY 129
#define ICMP_TIME_EXCEEDED 128
char *icmp_type_name(int id) {
  switch (id) {
  case ICMP_ECHOREPLY:
    return "Echo Reply";
  case ICMP_DEST_UNREACH:
    return "Destination Unreachable";
  case ICMP_SOURCE_QUENCH:
    return "Source Quench";
  case ICMP_REDIRECT:
    return "Redirect (change route)";
  case ICMP_ECHO:
    return "Echo Request";
  case ICMP_TIME_EXCEEDED:
    return "Time Exceeded";
  case ICMP_PARAMETERPROB:
    return "Parameter Problem";
  case ICMP_TIMESTAMP:
    return "Timestamp Request";
  case ICMP_TIMESTAMPREPLY:
    return "Timestamp Reply";
  case ICMP_INFO_REQUEST:
    return "Information Request";
  case ICMP_INFO_REPLY:
    return "Information Reply";
  case ICMP_ADDRESS:
    return "Address Mask Request";
  case ICMP_ADDRESSREPLY:
    return "Address Mask Reply";
  default:
    return "unknown ICMP type";
  }
}


x86 assembly (clang, -O0):
<icmp_type_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xc,%eax
ja     1200 <icmp_type_name+0x100>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xefd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xef8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf00(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xefe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf06(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf03(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf01(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf03(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf05(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf05(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf09(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf0b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf10(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120b <icmp_type_name+0x10b>
lea    0xf13(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<icmp_type_name>:
add    $0xffffff80,%edi
cmp    $0xc,%edi
ja     111a <icmp_type_name+0x1a>
movslq %edi,%rax
lea    0xfe6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xfc5(%rip),%rax
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Echo Reply\00"
@.str.1 = [24 x i8] c"Destination Unreachable\00"
@.str.2 = [14 x i8] c"Source Quench\00"
@.str.3 = [24 x i8] c"Redirect (change route)\00"
@.str.4 = [13 x i8] c"Echo Request\00"
@.str.5 = [14 x i8] c"Time Exceeded\00"
@.str.6 = [18 x i8] c"Parameter Problem\00"
@.str.7 = [18 x i8] c"Timestamp Request\00"
@.str.8 = [16 x i8] c"Timestamp Reply\00"
@.str.9 = [20 x i8] c"Information Request\00"
@.str.10 = [18 x i8] c"Information Reply\00"
@.str.11 = [21 x i8] c"Address Mask Request\00"
@.str.12 = [19 x i8] c"Address Mask Reply\00"
@.str.13 = [18 x i8] c"unknown ICMP type\00"
define i8* @icmp_type_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %18 [
i32 136, label %5
i32 138, label %6
i32 131, label %7
i32 132, label %8
i32 137, label %9
i32 128, label %10
i32 133, label %11
i32 130, label %12
i32 129, label %13
i32 134, label %14
i32 135, label %15
i32 140, label %16
i32 139, label %17
]
5: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
6: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %19
7: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %19
8: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %19
9: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %19
10: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %19
11: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %19
12: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %19
13: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %19
14: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %19
15: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %19
16: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %19
17: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %19
18: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [11 x i8] c"Echo Reply\00"
@.str.1 = [24 x i8] c"Destination Unreachable\00"
@.str.2 = [14 x i8] c"Source Quench\00"
@.str.3 = [24 x i8] c"Redirect (change route)\00"
@.str.4 = [13 x i8] c"Echo Request\00"
@.str.5 = [14 x i8] c"Time Exceeded\00"
@.str.6 = [18 x i8] c"Parameter Problem\00"
@.str.7 = [18 x i8] c"Timestamp Request\00"
@.str.8 = [16 x i8] c"Timestamp Reply\00"
@.str.9 = [20 x i8] c"Information Request\00"
@.str.10 = [18 x i8] c"Information Reply\00"
@.str.11 = [21 x i8] c"Address Mask Request\00"
@.str.12 = [19 x i8] c"Address Mask Reply\00"
@.str.13 = [18 x i8] c"unknown ICMP type\00"
@reltable.icmp_type_name = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.icmp_type_name to i64)) to i32)]
define i8* @icmp_type_name(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 13
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.icmp_type_name to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), %1 ]
ret i8* %9
}