#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 /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
const char *get_cmd(unsigned char cmd) {
  static char buffer[4];
  switch (cmd) {
  case 255:
    return "IAC";
  case 254:
    return "DONT";
  case 253:
    return "DO";
  case 252:
    return "WONT";
  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 "BREAK";
  case 242:
    return "DM";
  case 241:
    return "NOP";
  case 240:
    return "SE";
  case 239:
    return "EOR";
  case 238:
    return "ABORT";
  case 237:
    return "SUSP";
  case 236:
    return "xEOF";
  default:
    snprintf(buffer, sizeof(buffer), "%d", (int)cmd);
    return buffer;
  }
}


x86 assembly (clang, -O0):
<get_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
add    $0xffffff14,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x13,%eax
ja     128a <get_cmd+0x17a>
mov    -0x18(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeff(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xef3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xed0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe85(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe78(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe48(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe3b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe2f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe25(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
lea    0xe1a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b1 <get_cmd+0x1a1>
movzbl -0x9(%rbp),%ecx
lea    0x2d94(%rip),%rdi
mov    $0x4,%esi
lea    0xdff(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2d7c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cmd>:
push   %rbx
cmp    $0xeb,%dil
jbe    112f <get_cmd+0x1f>
add    $0x14,%dil
movsbq %dil,%rax
lea    0xf2e(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    114e <get_cmd+0x3e>
movzbl %dil,%ecx
lea    0x2eef(%rip),%rbx
lea    0xf0f(%rip),%rdx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_cmd.buffer = internal global [4 x i8] zeroinitializer
@.str = [4 x i8] c"IAC\00"
@.str.1 = [5 x i8] c"DONT\00"
@.str.2 = [3 x i8] c"DO\00"
@.str.3 = [5 x i8] c"WONT\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 = [6 x i8] c"BREAK\00"
@.str.13 = [3 x i8] c"DM\00"
@.str.14 = [4 x i8] c"NOP\00"
@.str.15 = [3 x i8] c"SE\00"
@.str.16 = [4 x i8] c"EOR\00"
@.str.17 = [6 x i8] c"ABORT\00"
@.str.18 = [5 x i8] c"SUSP\00"
@.str.19 = [5 x i8] c"xEOF\00"
@.str.20 = [3 x i8] c"%d\00"
define i8* @get_cmd(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 %26 [
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
i32 240, label %21
i32 239, label %22
i32 238, label %23
i32 237, label %24
i32 236, label %25
]
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %30
7: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %30
8: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %30
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %30
10: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %30
11: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %30
12: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %30
13: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %30
14: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %30
15: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %30
16: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %30
17: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %30
18: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %30
19: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %30
20: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %30
21: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %30
22: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i8** %2
br label %30
23: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i8** %2
br label %30
24: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i8** %2
br label %30
25: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8** %2
br label %30
26: ; preds = %1
%27 = load i8, i8* %3
%28 = zext i8 %27 to i32
%29 = call i32 @snprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @get_cmd.buffer, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i32 %28)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @get_cmd.buffer, i64 0, i64 0), i8** %2
br label %30
30: ; preds = %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
@get_cmd.buffer = internal global [4 x i8] zeroinitializer
@.str = [4 x i8] c"IAC\00"
@.str.1 = [5 x i8] c"DONT\00"
@.str.2 = [3 x i8] c"DO\00"
@.str.3 = [5 x i8] c"WONT\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 = [6 x i8] c"BREAK\00"
@.str.13 = [3 x i8] c"DM\00"
@.str.14 = [4 x i8] c"NOP\00"
@.str.15 = [3 x i8] c"SE\00"
@.str.16 = [4 x i8] c"EOR\00"
@.str.17 = [6 x i8] c"ABORT\00"
@.str.18 = [5 x i8] c"SUSP\00"
@.str.19 = [5 x i8] c"xEOF\00"
@.str.20 = [3 x i8] c"%d\00"
@reltable.get_cmd = [20 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.19 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.18 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.17 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.16 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.15 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.14 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.13 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.12 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.11 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.10 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([20 x i32]* @reltable.get_cmd to i64)) to i32)]
define i8* @get_cmd(i8 zeroext %0) {
%2 = icmp ugt i8 %0, -21
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = zext i8 %0 to i32
%5 = tail call i32 @snprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @get_cmd.buffer, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i32 %4)
br label %11
6: ; preds = %1
%7 = add i8 %0, 20
%8 = sext i8 %7 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([20 x i32]* @reltable.get_cmd to i8*), i64 %9)
br label %11
11: ; preds = %6, %3
%12 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @get_cmd.buffer, i64 0, i64 0), %3 ], [ %10, %6 ]
ret i8* %12
}