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 ('$');
  case ((unsigned short)02000):
    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     11ec <get_mask_char+0xec>
jmp    1120 <get_mask_char+0x20>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     11f5 <get_mask_char+0xf5>
jmp    1131 <get_mask_char+0x31>
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
je     11bf <get_mask_char+0xbf>
jmp    1142 <get_mask_char+0x42>
mov    -0x8(%rbp),%eax
sub    $0x8,%eax
je     11c8 <get_mask_char+0xc8>
jmp    1153 <get_mask_char+0x53>
mov    -0x8(%rbp),%eax
sub    $0x10,%eax
je     11d1 <get_mask_char+0xd1>
jmp    1164 <get_mask_char+0x64>
mov    -0x8(%rbp),%eax
sub    $0x20,%eax
je     11da <get_mask_char+0xda>
jmp    1175 <get_mask_char+0x75>
mov    -0x8(%rbp),%eax
sub    $0x40,%eax
je     11e3 <get_mask_char+0xe3>
jmp    1186 <get_mask_char+0x86>
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
je     11fe <get_mask_char+0xfe>
jmp    1199 <get_mask_char+0x99>
mov    -0x8(%rbp),%eax
sub    $0x100,%eax
je     1207 <get_mask_char+0x107>
jmp    11ac <get_mask_char+0xac>
mov    -0x8(%rbp),%eax
sub    $0x400,%eax
je     1210 <get_mask_char+0x110>
jmp    1219 <get_mask_char+0x119>
movb   $0x3f,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x21,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x2a,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x3a,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x2f,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x5d,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x29,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x3d,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x24,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x26,-0x1(%rbp)
jmp    121d <get_mask_char+0x11d>
movb   $0x7e,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mask_char>:
cmp    $0x7f,%di
jg     1127 <get_mask_char+0x27>
add    $0xffffffff,%edi
cmp    $0x3f,%di
ja     1157 <get_mask_char+0x57>
mov    $0x3f,%al
movzwl %di,%ecx
lea    0xee5(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x5d,%al
ret
movzwl %di,%eax
cmp    $0x80,%eax
je     1151 <get_mask_char+0x51>
cmp    $0x100,%eax
je     1154 <get_mask_char+0x54>
cmp    $0x400,%eax
jne    1157 <get_mask_char+0x57>
mov    $0x26,%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
mov    $0x24,%al
ret
mov    $0x7e,%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 %16 [
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
i32 1024, label %15
]
6: ; preds = %1
store i8 63, i8* %2
br label %17
7: ; preds = %1
store i8 33, i8* %2
br label %17
8: ; preds = %1
store i8 42, i8* %2
br label %17
9: ; preds = %1
store i8 58, i8* %2
br label %17
10: ; preds = %1
store i8 47, i8* %2
br label %17
11: ; preds = %1
store i8 93, i8* %2
br label %17
12: ; preds = %1
store i8 41, i8* %2
br label %17
13: ; preds = %1
store i8 61, i8* %2
br label %17
14: ; preds = %1
store i8 36, i8* %2
br label %17
15: ; preds = %1
store i8 38, i8* %2
br label %17
16: ; preds = %1
store i8 126, i8* %2
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = load i8, i8* %2
ret i8 %18
}

LLVM IR (-O2):
define signext i8 @get_mask_char(i16 zeroext %0) {
switch i16 %0, label %11 [
i16 4, label %12
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
i16 1024, label %10
]
2: ; preds = %1
br label %12
3: ; preds = %1
br label %12
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
br label %12
11: ; preds = %1
br label %12
12: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%13 = phi i8 [ 126, %11 ], [ 38, %10 ], [ 36, %9 ], [ 61, %8 ], [ 41, %7 ], [ 93, %6 ], [ 47, %5 ], [ 58, %4 ], [ 42, %3 ], [ 33, %2 ], [ 63, %1 ]
ret i8 %13
}