char *socks5_msgs(int type, unsigned char msg) {
  if (type == 1) {
    if (msg == 0x00)
      return "No authentification required";
    if (msg == 0xFF)
      return "No acceptable methods";
    return "Unknown Socks5 message";
  }
  if (type == 2) {
    if (msg == 0x00)
      return "Succeeded";
    if (msg == 0x01)
      return "General SOCKS server failure";
    if (msg == 0x02)
      return "Connection not allowed by ruleset";
    if (msg == 0x03)
      return "Network unreachable";
    if (msg == 0x04)
      return "Host unreachable";
    if (msg == 0x05)
      return "Connection refused";
    if (msg == 0x06)
      return "TTL expired";
    if (msg == 0x07)
      return "Command not supported";
    if (msg == 0x08)
      return "Address type not supported";
    return "Unknown Socks5 message";
  }
  return "Unknown type";
}


x86 assembly (clang, -O0):
<socks5_msgs>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1163 <socks5_msgs+0x63>
movzbl -0xd(%rbp),%eax
cmp    $0x0,%eax
jne    1134 <socks5_msgs+0x34>
lea    0xed5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0xff,%eax
jne    1153 <socks5_msgs+0x53>
lea    0xed3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
lea    0xed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
cmpl   $0x2,-0xc(%rbp)
jne    1282 <socks5_msgs+0x182>
movzbl -0xd(%rbp),%eax
cmp    $0x0,%eax
jne    118a <socks5_msgs+0x8a>
lea    0xec9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x1,%eax
jne    11a7 <socks5_msgs+0xa7>
lea    0xeb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x2,%eax
jne    11c4 <socks5_msgs+0xc4>
lea    0xeb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x3,%eax
jne    11e1 <socks5_msgs+0xe1>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x4,%eax
jne    11fe <socks5_msgs+0xfe>
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x5,%eax
jne    121b <socks5_msgs+0x11b>
lea    0xea6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x6,%eax
jne    1238 <socks5_msgs+0x138>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x7,%eax
jne    1255 <socks5_msgs+0x155>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
movzbl -0xd(%rbp),%eax
cmp    $0x8,%eax
jne    1272 <socks5_msgs+0x172>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
lea    0xdba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128d <socks5_msgs+0x18d>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<socks5_msgs>:
cmp    $0x2,%edi
je     112f <socks5_msgs+0x2f>
cmp    $0x1,%edi
jne    1148 <socks5_msgs+0x48>
cmp    $0xff,%sil
lea    0xf08(%rip),%rax
lea    0xf17(%rip),%rcx
cmove  %rax,%rcx
test   %sil,%sil
lea    0xed6(%rip),%rax
cmovne %rcx,%rax
ret
cmp    $0x8,%sil
ja     1150 <socks5_msgs+0x50>
movsbq %sil,%rax
lea    0xfd8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xfb9(%rip),%rax
ret
lea    0xedc(%rip),%rax
ret

LLVM IR (-O0):
@.str = [29 x i8] c"No authentification required\00"
@.str.1 = [22 x i8] c"No acceptable methods\00"
@.str.2 = [23 x i8] c"Unknown Socks5 message\00"
@.str.3 = [10 x i8] c"Succeeded\00"
@.str.4 = [29 x i8] c"General SOCKS server failure\00"
@.str.5 = [34 x i8] c"Connection not allowed by ruleset\00"
@.str.6 = [20 x i8] c"Network unreachable\00"
@.str.7 = [17 x i8] c"Host unreachable\00"
@.str.8 = [19 x i8] c"Connection refused\00"
@.str.9 = [12 x i8] c"TTL expired\00"
@.str.10 = [22 x i8] c"Command not supported\00"
@.str.11 = [27 x i8] c"Address type not supported\00"
@.str.12 = [13 x i8] c"Unknown type\00"
define i8* @socks5_msgs(i32 %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8** %3
br label %69
13: ; preds = %8
%14 = load i8, i8* %5
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 255
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %69
18: ; preds = %13
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %69
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %68
22: ; preds = %19
%23 = load i8, i8* %5
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %69
27: ; preds = %22
%28 = load i8, i8* %5
%29 = zext i8 %28 to i32
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %27
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %69
32: ; preds = %27
%33 = load i8, i8* %5
%34 = zext i8 %33 to i32
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %37
36: ; preds = %32
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %69
37: ; preds = %32
%38 = load i8, i8* %5
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 3
br i1 %40, label %41, label %42
41: ; preds = %37
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %69
42: ; preds = %37
%43 = load i8, i8* %5
%44 = zext i8 %43 to i32
%45 = icmp eq i32 %44, 4
br i1 %45, label %46, label %47
46: ; preds = %42
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %69
47: ; preds = %42
%48 = load i8, i8* %5
%49 = zext i8 %48 to i32
%50 = icmp eq i32 %49, 5
br i1 %50, label %51, label %52
51: ; preds = %47
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %69
52: ; preds = %47
%53 = load i8, i8* %5
%54 = zext i8 %53 to i32
%55 = icmp eq i32 %54, 6
br i1 %55, label %56, label %57
56: ; preds = %52
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %69
57: ; preds = %52
%58 = load i8, i8* %5
%59 = zext i8 %58 to i32
%60 = icmp eq i32 %59, 7
br i1 %60, label %61, label %62
61: ; preds = %57
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %69
62: ; preds = %57
%63 = load i8, i8* %5
%64 = zext i8 %63 to i32
%65 = icmp eq i32 %64, 8
br i1 %65, label %66, label %67
66: ; preds = %62
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %69
67: ; preds = %62
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %69
68: ; preds = %19
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %69
69: ; preds = %68, %67, %66, %61, %56, %51, %46, %41, %36, %31, %26, %18, %17, %12
%70 = load i8*, i8** %3
ret i8* %70
}

LLVM IR (-O2):
@.str = [29 x i8] c"No authentification required\00"
@.str.1 = [22 x i8] c"No acceptable methods\00"
@.str.2 = [23 x i8] c"Unknown Socks5 message\00"
@.str.3 = [10 x i8] c"Succeeded\00"
@.str.4 = [29 x i8] c"General SOCKS server failure\00"
@.str.5 = [34 x i8] c"Connection not allowed by ruleset\00"
@.str.6 = [20 x i8] c"Network unreachable\00"
@.str.7 = [17 x i8] c"Host unreachable\00"
@.str.8 = [19 x i8] c"Connection refused\00"
@.str.9 = [12 x i8] c"TTL expired\00"
@.str.10 = [22 x i8] c"Command not supported\00"
@.str.11 = [27 x i8] c"Address type not supported\00"
@.str.12 = [13 x i8] c"Unknown type\00"
@reltable.socks5_msgs = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.9 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.10 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.11 to i64), i64 ptrtoint ([9 x i32]* @reltable.socks5_msgs to i64)) to i32)]
define i8* @socks5_msgs(i32 %0, i8 zeroext %1) {
switch i32 %0, label %14 [
i32 1, label %3
i32 2, label %8
]
3: ; preds = %2
%4 = icmp eq i8 %1, -1
%5 = select i1 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0)
%6 = icmp eq i8 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %5
br label %14
8: ; preds = %2
%9 = icmp ult i8 %1, 9
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = sext i8 %1 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.socks5_msgs to i8*), i64 %12)
br label %14
14: ; preds = %8, %10, %3, %2
%15 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), %2 ], [ %7, %3 ], [ %13, %10 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %8 ]
ret i8* %15
}