unsigned int letter_to_flag(int c) {
  switch (c) {
  case 'a':
    return 1;
  case 'e':
    return 2;
  case 'q':
    return 4;
  case 'c':
    return 32;
  case 'x':
    return 64;
  case 'f':
    return 8;
  case 'l':
    return 16;
  case 'p':
    return 128;
  case 'i':
    return 256;
  case 't':
    return 512;
  case 'V':
    return ~0;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<letter_to_flag>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffaa,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x22,%eax
ja     11b4 <letter_to_flag+0xb4>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x2,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x4,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x20,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x40,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x8,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x10,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x80,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x100,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x200,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <letter_to_flag+0xbb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<letter_to_flag>:
add    $0xffffffaa,%edi
cmp    $0x22,%edi
ja     1123 <letter_to_flag+0x23>
mov    $0x1,%eax
lea    0xeec(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    $0xffffffff,%eax
ret
xor    %eax,%eax
ret
mov    $0x20,%eax
ret
mov    $0x2,%eax
ret
mov    $0x8,%eax
ret
mov    $0x100,%eax
ret
mov    $0x10,%eax
ret
mov    $0x80,%eax
ret
mov    $0x4,%eax
ret
mov    $0x200,%eax
ret
mov    $0x40,%eax
ret

LLVM IR (-O0):
define i32 @letter_to_flag(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %16 [
i32 97, label %5
i32 101, label %6
i32 113, label %7
i32 99, label %8
i32 120, label %9
i32 102, label %10
i32 108, label %11
i32 112, label %12
i32 105, label %13
i32 116, label %14
i32 86, label %15
]
5: ; preds = %1
store i32 1, i32* %2
br label %17
6: ; preds = %1
store i32 2, i32* %2
br label %17
7: ; preds = %1
store i32 4, i32* %2
br label %17
8: ; preds = %1
store i32 32, i32* %2
br label %17
9: ; preds = %1
store i32 64, i32* %2
br label %17
10: ; preds = %1
store i32 8, i32* %2
br label %17
11: ; preds = %1
store i32 16, i32* %2
br label %17
12: ; preds = %1
store i32 128, i32* %2
br label %17
13: ; preds = %1
store i32 256, i32* %2
br label %17
14: ; preds = %1
store i32 512, i32* %2
br label %17
15: ; preds = %1
store i32 -1, i32* %2
br label %17
16: ; preds = %1
store i32 0, i32* %2
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @letter_to_flag(i32 %0) {
switch i32 %0, label %12 [
i32 97, label %13
i32 101, label %2
i32 113, label %3
i32 99, label %4
i32 120, label %5
i32 102, label %6
i32 108, label %7
i32 112, label %8
i32 105, label %9
i32 116, label %10
i32 86, label %11
]
2: ; preds = %1
br label %13
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
br label %13
10: ; preds = %1
br label %13
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%14 = phi i32 [ 0, %12 ], [ -1, %11 ], [ 512, %10 ], [ 256, %9 ], [ 128, %8 ], [ 16, %7 ], [ 8, %6 ], [ 64, %5 ], [ 32, %4 ], [ 4, %3 ], [ 2, %2 ], [ 1, %1 ]
ret i32 %14
}