char get_mask_char(unsigned short mask) {
  switch (mask) {
  case ((unsigned short)04):
    return ('?');
  case ((unsigned short)010):
    return ('!');
  case ((unsigned short)020):
    return ('*');
  case ((unsigned short)040):
    return (':');
  case ((unsigned short)0100):
    return ('/');
  case ((unsigned short)01):
    return (']');
  case ((unsigned short)02):
    return (')');
  case ((unsigned short)0200):
    return ('=');
  case ((unsigned short)0400):
    return (',');
  default:
    return ('~');
  }
}


x86 assembly (clang, -O0):
<get_mask_char>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x4(%rbp)
movzwl -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     11d9 <get_mask_char+0xd9>
jmp    1120 <get_mask_char+0x20>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     11e2 <get_mask_char+0xe2>
jmp    1131 <get_mask_char+0x31>
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
je     11ac <get_mask_char+0xac>
jmp    1142 <get_mask_char+0x42>
mov    -0x8(%rbp),%eax
sub    $0x8,%eax
je     11b5 <get_mask_char+0xb5>
jmp    1153 <get_mask_char+0x53>
mov    -0x8(%rbp),%eax
sub    $0x10,%eax
je     11be <get_mask_char+0xbe>
jmp    1164 <get_mask_char+0x64>
mov    -0x8(%rbp),%eax
sub    $0x20,%eax
je     11c7 <get_mask_char+0xc7>
jmp    1175 <get_mask_char+0x75>
mov    -0x8(%rbp),%eax
sub    $0x40,%eax
je     11d0 <get_mask_char+0xd0>
jmp    1186 <get_mask_char+0x86>
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
je     11eb <get_mask_char+0xeb>
jmp    1199 <get_mask_char+0x99>
mov    -0x8(%rbp),%eax
sub    $0x100,%eax
je     11f4 <get_mask_char+0xf4>
jmp    11fd <get_mask_char+0xfd>
movb   $0x3f,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x21,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x2a,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x3a,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x2f,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x5d,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x29,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x3d,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x2c,-0x1(%rbp)
jmp    1201 <get_mask_char+0x101>
movb   $0x7e,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mask_char>:
lea    -0x1(%rdi),%ecx
cmp    $0x3f,%cx
ja     1121 <get_mask_char+0x21>
mov    $0x3f,%al
movzwl %cx,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x5d,%al
ret
movzwl %di,%eax
cmp    $0x80,%eax
je     1147 <get_mask_char+0x47>
cmp    $0x100,%eax
jne    1135 <get_mask_char+0x35>
mov    $0x2c,%al
ret
mov    $0x7e,%al
ret
mov    $0x29,%al
ret
mov    $0x21,%al
ret
mov    $0x2a,%al
ret
mov    $0x3a,%al
ret
mov    $0x2f,%al
ret
mov    $0x3d,%al
ret

LLVM IR (-O0):
define signext i8 @get_mask_char(i16 zeroext %0) {
%2 = alloca i8
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
switch i32 %5, label %15 [
i32 4, label %6
i32 8, label %7
i32 16, label %8
i32 32, label %9
i32 64, label %10
i32 1, label %11
i32 2, label %12
i32 128, label %13
i32 256, label %14
]
6: ; preds = %1
store i8 63, i8* %2
br label %16
7: ; preds = %1
store i8 33, i8* %2
br label %16
8: ; preds = %1
store i8 42, i8* %2
br label %16
9: ; preds = %1
store i8 58, i8* %2
br label %16
10: ; preds = %1
store i8 47, i8* %2
br label %16
11: ; preds = %1
store i8 93, i8* %2
br label %16
12: ; preds = %1
store i8 41, i8* %2
br label %16
13: ; preds = %1
store i8 61, i8* %2
br label %16
14: ; preds = %1
store i8 44, i8* %2
br label %16
15: ; preds = %1
store i8 126, i8* %2
br label %16
16: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%17 = load i8, i8* %2
ret i8 %17
}

LLVM IR (-O2):
define signext i8 @get_mask_char(i16 zeroext %0) {
switch i16 %0, label %10 [
i16 4, label %11
i16 8, label %2
i16 16, label %3
i16 32, label %4
i16 64, label %5
i16 1, label %6
i16 2, label %7
i16 128, label %8
i16 256, label %9
]
2: ; preds = %1
br label %11
3: ; preds = %1
br label %11
4: ; preds = %1
br label %11
5: ; preds = %1
br label %11
6: ; preds = %1
br label %11
7: ; preds = %1
br label %11
8: ; preds = %1
br label %11
9: ; preds = %1
br label %11
10: ; preds = %1
br label %11
11: ; preds = %1, %10, %9, %8, %7, %6, %5, %4, %3, %2
%12 = phi i8 [ 126, %10 ], [ 44, %9 ], [ 61, %8 ], [ 41, %7 ], [ 93, %6 ], [ 47, %5 ], [ 58, %4 ], [ 42, %3 ], [ 33, %2 ], [ 63, %1 ]
ret i8 %12
}