const char *stat_string(int strtype, int flag) {
  const char *str;
  switch (strtype) {
  case 1:
    if (flag) {
      str = "Suspected";
    } else {
      str = "Trusted";
    }
    break;
  case 2:
    switch (flag) {
    case 0x0002:
      str = "Forbidden";
      break;
    case 0x0001:
      str = "Registration";
      break;
    case 0x0008:
      str = "NoGuest";
      break;
    case 0:
      str = "Unrestricted";
      break;
    default:
      str = "Strange";
    }
    break;
  default:
    str = "Strange";
  }
  return str;
}


x86 assembly (clang, -O0):
<stat_string>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     112f <stat_string+0x2f>
jmp    111e <stat_string+0x1e>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1159 <stat_string+0x59>
jmp    11ce <stat_string+0xce>
cmpl   $0x0,-0x8(%rbp)
je     1149 <stat_string+0x49>
lea    0xee4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <stat_string+0x54>
lea    0xede(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d9 <stat_string+0xd9>
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x8,%rax
ja     11be <stat_string+0xbe>
mov    -0x20(%rbp),%rax
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c9 <stat_string+0xc9>
lea    0xeab(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c9 <stat_string+0xc9>
lea    0xea8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c9 <stat_string+0xc9>
lea    0xea0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c9 <stat_string+0xc9>
lea    0xe9d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d9 <stat_string+0xd9>
lea    0xe8d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stat_string>:
lea    0xf37(%rip),%rax
cmp    $0x2,%edi
je     1126 <stat_string+0x26>
cmp    $0x1,%edi
jne    113c <stat_string+0x3c>
test   %esi,%esi
lea    0xef0(%rip),%rcx
lea    0xedf(%rip),%rax
cmove  %rcx,%rax
ret
cmp    $0x8,%esi
ja     113c <stat_string+0x3c>
movslq %esi,%rax
lea    0xf13(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Suspected\00"
@.str.1 = [8 x i8] c"Trusted\00"
@.str.2 = [10 x i8] c"Forbidden\00"
@.str.3 = [13 x i8] c"Registration\00"
@.str.4 = [8 x i8] c"NoGuest\00"
@.str.5 = [13 x i8] c"Unrestricted\00"
@.str.6 = [8 x i8] c"Strange\00"
define i8* @stat_string(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
switch i32 %6, label %21 [
i32 1, label %7
i32 2, label %13
]
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %5
br label %12
11: ; preds = %7
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %12
12: ; preds = %11, %10
br label %22
13: ; preds = %2
%14 = load i32, i32* %4
switch i32 %14, label %19 [
i32 2, label %15
i32 1, label %16
i32 8, label %17
i32 0, label %18
]
15: ; preds = %13
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %20
16: ; preds = %13
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %20
17: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %5
br label %20
18: ; preds = %13
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %5
br label %20
19: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %5
br label %20
20: ; preds = %19, %18, %17, %16, %15
br label %22
21: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %5
br label %22
22: ; preds = %21, %20, %12
%23 = load i8*, i8** %5
ret i8* %23
}

LLVM IR (-O2):
@.str = [10 x i8] c"Suspected\00"
@.str.1 = [8 x i8] c"Trusted\00"
@.str.2 = [10 x i8] c"Forbidden\00"
@.str.3 = [13 x i8] c"Registration\00"
@.str.4 = [8 x i8] c"NoGuest\00"
@.str.5 = [13 x i8] c"Unrestricted\00"
@.str.6 = [8 x i8] c"Strange\00"
@reltable.stat_string = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.stat_string to i64)) to i32)]
define i8* @stat_string(i32 %0, i32 %1) {
switch i32 %0, label %12 [
i32 1, label %3
i32 2, label %6
]
3: ; preds = %2
%4 = icmp eq i32 %1, 0
%5 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0)
br label %12
6: ; preds = %2
%7 = icmp ult i32 %1, 9
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = sext i32 %1 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.stat_string to i8*), i64 %10)
br label %12
12: ; preds = %6, %8, %2, %3
%13 = phi i8* [ %5, %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %2 ], [ %11, %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %6 ]
ret i8* %13
}