const char *wlan_mode_string(int mode) {
  if (mode & (1 << (0)))
    return "AP";
  else if (mode & (1 << (0)))
    return "IBSS";
  else if (mode & (1 << (2)))
    return "STA";
  else if (mode & (1 << (3)))
    return "PRB";
  return "UNK";
}


x86 assembly (clang, -O0):
<wlan_mode_string>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1126 <wlan_mode_string+0x26>
lea    0xee3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <wlan_mode_string+0x9d>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1145 <wlan_mode_string+0x45>
lea    0xec7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <wlan_mode_string+0x9d>
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1164 <wlan_mode_string+0x64>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <wlan_mode_string+0x9d>
mov    -0xc(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1183 <wlan_mode_string+0x83>
lea    0xe92(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <wlan_mode_string+0x9d>
jmp    1188 <wlan_mode_string+0x88>
jmp    118d <wlan_mode_string+0x8d>
jmp    1192 <wlan_mode_string+0x92>
lea    0xe77(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<wlan_mode_string>:
test   $0x1,%dil
jne    1123 <wlan_mode_string+0x23>
test   $0x4,%dil
jne    112b <wlan_mode_string+0x2b>
test   $0x8,%dil
lea    0xef4(%rip),%rcx
lea    0xee9(%rip),%rax
cmove  %rcx,%rax
ret
lea    0xed6(%rip),%rax
ret
lea    0xed1(%rip),%rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"AP\00"
@.str.1 = [5 x i8] c"IBSS\00"
@.str.2 = [4 x i8] c"STA\00"
@.str.3 = [4 x i8] c"PRB\00"
@.str.4 = [4 x i8] c"UNK\00"
define i8* @wlan_mode_string(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %27
8: ; preds = %1
%9 = load i32, i32* %3
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %27
13: ; preds = %8
%14 = load i32, i32* %3
%15 = and i32 %14, 4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %27
18: ; preds = %13
%19 = load i32, i32* %3
%20 = and i32 %19, 8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %27
23: ; preds = %18
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %27
27: ; preds = %26, %22, %17, %12, %7
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"AP\00"
@.str.2 = [4 x i8] c"STA\00"
@.str.3 = [4 x i8] c"PRB\00"
@.str.4 = [4 x i8] c"UNK\00"
define i8* @wlan_mode_string(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = and i32 %0, 4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = and i32 %0, 8
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
br label %11
11: ; preds = %7, %4, %1
%12 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %4 ], [ %10, %7 ]
ret i8* %12
}