const char *wpa_key_mgmt_txt(int key_mgmt, int proto) {
  switch (key_mgmt) {
  case (1 << (0)):
    return proto == (1 << (1)) ? "WPA2/IEEE 802.1X/EAP" : "WPA/IEEE 802.1X/EAP";
  case (1 << (1)):
    return proto == (1 << (1)) ? "WPA2-PSK" : "WPA-PSK";
  case (1 << (2)):
    return "NONE";
  case (1 << (3)):
    return "IEEE 802.1X (no WPA)";
  default:
    return "UNKNOWN";
  }
}


x86 assembly (clang, -O0):
<wpa_key_mgmt_txt>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     1195 <wpa_key_mgmt_txt+0x95>
mov    -0x18(%rbp),%rax
lea    0xed6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%edx
lea    0xef8(%rip),%rax
lea    0xedc(%rip),%rcx
cmp    $0x2,%edx
cmove  %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <wpa_key_mgmt_txt+0xa0>
mov    -0x10(%rbp),%edx
lea    0xef4(%rip),%rax
lea    0xee4(%rip),%rcx
cmp    $0x2,%edx
cmove  %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <wpa_key_mgmt_txt+0xa0>
lea    0xede(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <wpa_key_mgmt_txt+0xa0>
lea    0xed3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <wpa_key_mgmt_txt+0xa0>
lea    0xed8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<wpa_key_mgmt_txt>:
add    $0xffffffff,%edi
cmp    $0x7,%edi
ja     114b <wpa_key_mgmt_txt+0x4b>
lea    0xf4b(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
cmp    $0x2,%esi
lea    0xef7(%rip),%rcx
lea    0xf05(%rip),%rax
cmove  %rcx,%rax
ret
cmp    $0x2,%esi
lea    0xf0a(%rip),%rcx
lea    0xf0c(%rip),%rax
cmove  %rcx,%rax
ret
lea    0xf22(%rip),%rax
ret
lea    0xf05(%rip),%rax
ret

LLVM IR (-O0):
@.str = [21 x i8] c"WPA2/IEEE 802.1X/EAP\00"
@.str.1 = [20 x i8] c"WPA/IEEE 802.1X/EAP\00"
@.str.2 = [9 x i8] c"WPA2-PSK\00"
@.str.3 = [8 x i8] c"WPA-PSK\00"
@.str.4 = [5 x i8] c"NONE\00"
@.str.5 = [21 x i8] c"IEEE 802.1X (no WPA)\00"
@.str.6 = [8 x i8] c"UNKNOWN\00"
define i8* @wpa_key_mgmt_txt(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %19 [
i32 1, label %7
i32 2, label %12
i32 4, label %17
i32 8, label %18
]
7: ; preds = %2
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 2
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0)
store i8* %11, i8** %3
br label %20
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 2
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
store i8* %16, i8** %3
br label %20
17: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %20
18: ; preds = %2
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %20
19: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %20
20: ; preds = %19, %18, %17, %12, %7
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@.str = [21 x i8] c"WPA2/IEEE 802.1X/EAP\00"
@.str.1 = [20 x i8] c"WPA/IEEE 802.1X/EAP\00"
@.str.2 = [9 x i8] c"WPA2-PSK\00"
@.str.3 = [8 x i8] c"WPA-PSK\00"
@.str.4 = [5 x i8] c"NONE\00"
@.str.5 = [21 x i8] c"IEEE 802.1X (no WPA)\00"
@.str.6 = [8 x i8] c"UNKNOWN\00"
define i8* @wpa_key_mgmt_txt(i32 %0, i32 %1) {
switch i32 %0, label %10 [
i32 1, label %3
i32 2, label %6
i32 4, label %11
i32 8, label %9
]
3: ; preds = %2
%4 = icmp eq i32 %1, 2
%5 = select i1 %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0)
br label %11
6: ; preds = %2
%7 = icmp eq i32 %1, 2
%8 = select i1 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
br label %11
9: ; preds = %2
br label %11
10: ; preds = %2
br label %11
11: ; preds = %2, %10, %9, %6, %3
%12 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %9 ], [ %8, %6 ], [ %5, %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %2 ]
ret i8* %12
}