char to_half_byte(char c) {
  switch (c) {
  case '0':
    return (char)0;
  case '1':
    return (char)1;
  case '2':
    return (char)2;
  case '3':
    return (char)3;
  case '4':
    return (char)4;
  case '5':
    return (char)5;
  case '6':
    return (char)6;
  case '7':
    return (char)7;
  case 'A':
    return (char)8;
  case 'C':
    return (char)9;
  case 'G':
    return (char)10;
  case 'T':
    return (char)11;
  case '-':
    return (char)12;
  case 'i':
    return (char)13;
  case 's':
    return (char)14;
  case '0' | (char)0x80:
    return (char)8;
  case '9' | (char)0x80:
    return (char)9;
  default:
    return (char)15;
  }
}


x86 assembly (clang, -O0):
<to_half_byte>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0xffffffb0,%eax
je     12b6 <to_half_byte+0x1b6>
jmp    111f <to_half_byte+0x1f>
mov    -0x8(%rbp),%eax
sub    $0xffffffb9,%eax
je     12bf <to_half_byte+0x1bf>
jmp    1130 <to_half_byte+0x30>
mov    -0x8(%rbp),%eax
sub    $0x2d,%eax
je     129b <to_half_byte+0x19b>
jmp    1141 <to_half_byte+0x41>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
je     122f <to_half_byte+0x12f>
jmp    1152 <to_half_byte+0x52>
mov    -0x8(%rbp),%eax
sub    $0x31,%eax
je     1238 <to_half_byte+0x138>
jmp    1163 <to_half_byte+0x63>
mov    -0x8(%rbp),%eax
sub    $0x32,%eax
je     1241 <to_half_byte+0x141>
jmp    1174 <to_half_byte+0x74>
mov    -0x8(%rbp),%eax
sub    $0x33,%eax
je     124a <to_half_byte+0x14a>
jmp    1185 <to_half_byte+0x85>
mov    -0x8(%rbp),%eax
sub    $0x34,%eax
je     1253 <to_half_byte+0x153>
jmp    1196 <to_half_byte+0x96>
mov    -0x8(%rbp),%eax
sub    $0x35,%eax
je     125c <to_half_byte+0x15c>
jmp    11a7 <to_half_byte+0xa7>
mov    -0x8(%rbp),%eax
sub    $0x36,%eax
je     1265 <to_half_byte+0x165>
jmp    11b8 <to_half_byte+0xb8>
mov    -0x8(%rbp),%eax
sub    $0x37,%eax
je     126e <to_half_byte+0x16e>
jmp    11c9 <to_half_byte+0xc9>
mov    -0x8(%rbp),%eax
sub    $0x41,%eax
je     1277 <to_half_byte+0x177>
jmp    11da <to_half_byte+0xda>
mov    -0x8(%rbp),%eax
sub    $0x43,%eax
je     1280 <to_half_byte+0x180>
jmp    11eb <to_half_byte+0xeb>
mov    -0x8(%rbp),%eax
sub    $0x47,%eax
je     1289 <to_half_byte+0x189>
jmp    11fc <to_half_byte+0xfc>
mov    -0x8(%rbp),%eax
sub    $0x54,%eax
je     1292 <to_half_byte+0x192>
jmp    120d <to_half_byte+0x10d>
mov    -0x8(%rbp),%eax
sub    $0x69,%eax
je     12a4 <to_half_byte+0x1a4>
jmp    121e <to_half_byte+0x11e>
mov    -0x8(%rbp),%eax
sub    $0x73,%eax
je     12ad <to_half_byte+0x1ad>
jmp    12c8 <to_half_byte+0x1c8>
movb   $0x0,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x1,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x2,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x3,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x4,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x5,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x6,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x7,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x8,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x9,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0xa,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0xb,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0xc,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0xd,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0xe,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x8,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0x9,-0x1(%rbp)
jmp    12cc <to_half_byte+0x1cc>
movb   $0xf,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_half_byte>:
lea    -0x2d(%rdi),%ecx
cmp    $0x46,%ecx
ja     111d <to_half_byte+0x1d>
xor    %eax,%eax
lea    0xeef(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0xc,%al
ret
cmp    $0xffffffb0,%edi
je     112a <to_half_byte+0x2a>
cmp    $0xffffffb9,%edi
jne    112d <to_half_byte+0x2d>
mov    $0x9,%al
ret
mov    $0x8,%al
ret
mov    $0xf,%al
ret
mov    $0x1,%al
ret
mov    $0x2,%al
ret
mov    $0x3,%al
ret
mov    $0x4,%al
ret
mov    $0x5,%al
ret
mov    $0x6,%al
ret
mov    $0x7,%al
ret
mov    $0xa,%al
ret
mov    $0xb,%al
ret
mov    $0xd,%al
ret
mov    $0xe,%al
ret

LLVM IR (-O0):
define signext i8 @to_half_byte(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %23 [
i32 48, label %6
i32 49, label %7
i32 50, label %8
i32 51, label %9
i32 52, label %10
i32 53, label %11
i32 54, label %12
i32 55, label %13
i32 65, label %14
i32 67, label %15
i32 71, label %16
i32 84, label %17
i32 45, label %18
i32 105, label %19
i32 115, label %20
i32 -80, label %21
i32 -71, label %22
]
6: ; preds = %1
store i8 0, i8* %2
br label %24
7: ; preds = %1
store i8 1, i8* %2
br label %24
8: ; preds = %1
store i8 2, i8* %2
br label %24
9: ; preds = %1
store i8 3, i8* %2
br label %24
10: ; preds = %1
store i8 4, i8* %2
br label %24
11: ; preds = %1
store i8 5, i8* %2
br label %24
12: ; preds = %1
store i8 6, i8* %2
br label %24
13: ; preds = %1
store i8 7, i8* %2
br label %24
14: ; preds = %1
store i8 8, i8* %2
br label %24
15: ; preds = %1
store i8 9, i8* %2
br label %24
16: ; preds = %1
store i8 10, i8* %2
br label %24
17: ; preds = %1
store i8 11, i8* %2
br label %24
18: ; preds = %1
store i8 12, i8* %2
br label %24
19: ; preds = %1
store i8 13, i8* %2
br label %24
20: ; preds = %1
store i8 14, i8* %2
br label %24
21: ; preds = %1
store i8 8, i8* %2
br label %24
22: ; preds = %1
store i8 9, i8* %2
br label %24
23: ; preds = %1
store i8 15, i8* %2
br label %24
24: ; preds = %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%25 = load i8, i8* %2
ret i8 %25
}

LLVM IR (-O2):
define signext i8 @to_half_byte(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %19 [
i32 48, label %20
i32 49, label %3
i32 50, label %4
i32 51, label %5
i32 52, label %6
i32 53, label %7
i32 54, label %8
i32 55, label %9
i32 65, label %10
i32 67, label %11
i32 71, label %12
i32 84, label %13
i32 45, label %14
i32 105, label %15
i32 115, label %16
i32 -80, label %17
i32 -71, label %18
]
3: ; preds = %1
br label %20
4: ; preds = %1
br label %20
5: ; preds = %1
br label %20
6: ; preds = %1
br label %20
7: ; preds = %1
br label %20
8: ; preds = %1
br label %20
9: ; preds = %1
br label %20
10: ; preds = %1
br label %20
11: ; preds = %1
br label %20
12: ; preds = %1
br label %20
13: ; preds = %1
br label %20
14: ; preds = %1
br label %20
15: ; preds = %1
br label %20
16: ; preds = %1
br label %20
17: ; preds = %1
br label %20
18: ; preds = %1
br label %20
19: ; preds = %1
br label %20
20: ; preds = %1, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%21 = phi i8 [ 15, %19 ], [ 9, %18 ], [ 8, %17 ], [ 14, %16 ], [ 13, %15 ], [ 12, %14 ], [ 11, %13 ], [ 10, %12 ], [ 9, %11 ], [ 8, %10 ], [ 7, %9 ], [ 6, %8 ], [ 5, %7 ], [ 4, %6 ], [ 3, %5 ], [ 2, %4 ], [ 1, %3 ], [ 0, %1 ]
ret i8 %21
}