const char *socks5_getauthname(int auth) {
  switch (auth) {
  case 0xFF:
    return "REJECTED";
  case 0x00:
    return "NO-AUTH";
  case 0x01:
    return "GSSAPI";
  case 0x02:
    return "USERPASS";
  case 0x03:
    return "CHAP";
  case 0x05:
    return "EAP";
  case 0x08:
    return "MAF";
  default:
    return "(unknown)";
  }
}


x86 assembly (clang, -O0):
<socks5_getauthname>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1192 <socks5_getauthname+0x92>
jmp    111a <socks5_getauthname+0x1a>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11a2 <socks5_getauthname+0xa2>
jmp    112b <socks5_getauthname+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11b2 <socks5_getauthname+0xb2>
jmp    113c <socks5_getauthname+0x3c>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11c2 <socks5_getauthname+0xc2>
jmp    114d <socks5_getauthname+0x4d>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     11d2 <socks5_getauthname+0xd2>
jmp    115e <socks5_getauthname+0x5e>
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
je     11e2 <socks5_getauthname+0xe2>
jmp    116f <socks5_getauthname+0x6f>
mov    -0x10(%rbp),%eax
sub    $0xff,%eax
jne    11f2 <socks5_getauthname+0xf2>
jmp    1182 <socks5_getauthname+0x82>
lea    0xe77(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe5f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe58(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <socks5_getauthname+0xfd>
lea    0xe35(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<socks5_getauthname>:
cmp    $0x8,%edi
ja     111f <socks5_getauthname+0x1f>
mov    %edi,%eax
lea    0xef2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0f(%rip),%rax
ret
cmp    $0xff,%edi
jne    112f <socks5_getauthname+0x2f>
lea    0xef6(%rip),%rax
ret
lea    0xf1c(%rip),%rax
ret
lea    0xef7(%rip),%rax
ret
lea    0xef6(%rip),%rax
ret
lea    0xef7(%rip),%rax
ret
lea    0xef4(%rip),%rax
ret
lea    0xef0(%rip),%rax
ret

LLVM IR (-O0):
@.str = [9 x i8] c"REJECTED\00"
@.str.1 = [8 x i8] c"NO-AUTH\00"
@.str.2 = [7 x i8] c"GSSAPI\00"
@.str.3 = [9 x i8] c"USERPASS\00"
@.str.4 = [5 x i8] c"CHAP\00"
@.str.5 = [4 x i8] c"EAP\00"
@.str.6 = [4 x i8] c"MAF\00"
@.str.7 = [10 x i8] c"(unknown)\00"
define i8* @socks5_getauthname(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %12 [
i32 255, label %5
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 5, label %10
i32 8, label %11
]
5: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
br label %13
6: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %13
7: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %13
8: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %13
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %13
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %13
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %13
12: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %13
13: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@.str = [9 x i8] c"REJECTED\00"
@.str.1 = [8 x i8] c"NO-AUTH\00"
@.str.2 = [7 x i8] c"GSSAPI\00"
@.str.3 = [9 x i8] c"USERPASS\00"
@.str.4 = [5 x i8] c"CHAP\00"
@.str.5 = [4 x i8] c"EAP\00"
@.str.6 = [4 x i8] c"MAF\00"
@.str.7 = [10 x i8] c"(unknown)\00"
define i8* @socks5_getauthname(i32 %0) {
switch i32 %0, label %8 [
i32 255, label %9
i32 0, label %2
i32 1, label %3
i32 2, label %4
i32 3, label %5
i32 5, label %6
i32 8, label %7
]
2: ; preds = %1
br label %9
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %8, %7, %6, %5, %4, %3, %2
%10 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([7 x i8], [7 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 ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %10
}