#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 */
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
const char *telnet_cmd_desc(unsigned char cmd) {
  static char unknown[32];
  switch (cmd) {
  case 255:
    return ("IAC");
  case 254:
    return ("DON'T");
  case 253:
    return ("DO");
  case 252:
    return ("WON'T");
  case 251:
    return ("WILL");
  case 250:
    return ("SB");
  case 249:
    return ("GA");
  case 248:
    return ("EL");
  case 247:
    return ("EC");
  case 246:
    return ("AYT");
  case 245:
    return ("AO");
  case 244:
    return ("IP");
  case 243:
    return ("BRK");
  case 242:
    return ("SYNC");
  case 241:
    return ("NOP");
  default:
    sprintf(unknown, "%d", cmd);
    return (unknown);
  }
}


x86 assembly (clang, -O0):
<telnet_cmd_desc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
add    $0xffffff0f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xe,%eax
ja     123a <telnet_cmd_desc+0x12a>
mov    -0x18(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xedf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xed5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xec8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xea6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe8c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe73(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe66(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe59(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0xe42(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <telnet_cmd_desc+0x14c>
lea    0x2dff(%rip),%rdi
lea    0xe2f(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
lea    0x2de8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<telnet_cmd_desc>:
push   %rbx
cmp    $0xf0,%dil
jbe    112f <telnet_cmd_desc+0x1f>
add    $0xf,%dil
movsbq %dil,%rax
lea    0xf1a(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1149 <telnet_cmd_desc+0x39>
movzbl %dil,%edx
lea    0x2f06(%rip),%rbx
lea    0xefa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@telnet_cmd_desc.unknown = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"IAC\00"
@.str.1 = [6 x i8] c"DON'T\00"
@.str.2 = [3 x i8] c"DO\00"
@.str.3 = [6 x i8] c"WON'T\00"
@.str.4 = [5 x i8] c"WILL\00"
@.str.5 = [3 x i8] c"SB\00"
@.str.6 = [3 x i8] c"GA\00"
@.str.7 = [3 x i8] c"EL\00"
@.str.8 = [3 x i8] c"EC\00"
@.str.9 = [4 x i8] c"AYT\00"
@.str.10 = [3 x i8] c"AO\00"
@.str.11 = [3 x i8] c"IP\00"
@.str.12 = [4 x i8] c"BRK\00"
@.str.13 = [5 x i8] c"SYNC\00"
@.str.14 = [4 x i8] c"NOP\00"
@.str.15 = [3 x i8] c"%d\00"
define i8* @telnet_cmd_desc(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 %21 [
i32 255, label %6
i32 254, label %7
i32 253, label %8
i32 252, label %9
i32 251, label %10
i32 250, label %11
i32 249, label %12
i32 248, label %13
i32 247, label %14
i32 246, label %15
i32 245, label %16
i32 244, label %17
i32 243, label %18
i32 242, label %19
i32 241, label %20
]
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %24
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %24
8: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %24
9: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %24
10: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %24
11: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %24
12: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %24
13: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %24
14: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %24
15: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %24
16: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %24
17: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %24
18: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %24
19: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %24
20: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %24
21: ; preds = %1
%22 = load i8, i8* %3
%23 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @telnet_cmd_desc.unknown, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8 zeroext %22)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @telnet_cmd_desc.unknown, i64 0, i64 0), i8** %2
br label %24
24: ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@telnet_cmd_desc.unknown = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"IAC\00"
@.str.1 = [6 x i8] c"DON'T\00"
@.str.2 = [3 x i8] c"DO\00"
@.str.3 = [6 x i8] c"WON'T\00"
@.str.4 = [5 x i8] c"WILL\00"
@.str.5 = [3 x i8] c"SB\00"
@.str.6 = [3 x i8] c"GA\00"
@.str.7 = [3 x i8] c"EL\00"
@.str.8 = [3 x i8] c"EC\00"
@.str.9 = [4 x i8] c"AYT\00"
@.str.10 = [3 x i8] c"AO\00"
@.str.11 = [3 x i8] c"IP\00"
@.str.12 = [4 x i8] c"BRK\00"
@.str.13 = [5 x i8] c"SYNC\00"
@.str.14 = [4 x i8] c"NOP\00"
@.str.15 = [3 x i8] c"%d\00"
@reltable.telnet_cmd_desc = [15 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.14 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.13 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.10 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.telnet_cmd_desc to i64)) to i32)]
define i8* @telnet_cmd_desc(i8 zeroext %0) {
%2 = icmp ugt i8 %0, -16
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @telnet_cmd_desc.unknown, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8 zeroext %0)
br label %10
5: ; preds = %1
%6 = add i8 %0, 15
%7 = sext i8 %6 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([15 x i32]* @reltable.telnet_cmd_desc to i8*), i64 %8)
br label %10
10: ; preds = %5, %3
%11 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @telnet_cmd_desc.unknown, i64 0, i64 0), %3 ], [ %9, %5 ]
ret i8* %11
}