char half_byte_to_char(char h) {
  if (h < 8)
    return '0' + h;
  switch (h) {
  case (char)8:
    return 'A';
  case (char)9:
    return 'C';
  case (char)10:
    return 'G';
  case (char)11:
    return 'T';
  case (char)12:
    return '-';
  case (char)13:
    return 'i';
  case (char)14:
    return 's';
  default:
    return 'N';
  }
}


x86 assembly (clang, -O0):
<half_byte_to_char>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x8,%eax
jge    1126 <half_byte_to_char+0x26>
movsbl -0x2(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movsbl -0x2(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     118f <half_byte_to_char+0x8f>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x41,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x43,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x47,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x54,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x2d,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x69,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x73,-0x1(%rbp)
jmp    1193 <half_byte_to_char+0x93>
movb   $0x4e,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<half_byte_to_char>:
cmp    $0x7,%dil
jg     110d <half_byte_to_char+0xd>
add    $0x30,%dil
mov    %edi,%eax
ret
add    $0xf8,%dil
mov    $0x4e,%al
cmp    $0x6,%dil
ja     112d <half_byte_to_char+0x2d>
movzbl %dil,%ecx
shl    $0x3,%ecx
movabs $0x73692d54474341,%rax
shr    %cl,%rax
ret

LLVM IR (-O0):
define signext i8 @half_byte_to_char(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
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = add nsw i32 48, %9
%11 = trunc i32 %10 to i8
store i8 %11, i8* %2
br label %23
12: ; preds = %1
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
switch i32 %14, label %22 [
i32 8, label %15
i32 9, label %16
i32 10, label %17
i32 11, label %18
i32 12, label %19
i32 13, label %20
i32 14, label %21
]
15: ; preds = %12
store i8 65, i8* %2
br label %23
16: ; preds = %12
store i8 67, i8* %2
br label %23
17: ; preds = %12
store i8 71, i8* %2
br label %23
18: ; preds = %12
store i8 84, i8* %2
br label %23
19: ; preds = %12
store i8 45, i8* %2
br label %23
20: ; preds = %12
store i8 105, i8* %2
br label %23
21: ; preds = %12
store i8 115, i8* %2
br label %23
22: ; preds = %12
store i8 78, i8* %2
br label %23
23: ; preds = %22, %21, %20, %19, %18, %17, %16, %15, %7
%24 = load i8, i8* %2
ret i8 %24
}

LLVM IR (-O2):
define signext i8 @half_byte_to_char(i8 signext %0) {
%2 = icmp slt i8 %0, 8
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = add nsw i8 %0, 48
br label %13
5: ; preds = %1
%6 = add i8 %0, -8
%7 = icmp ult i8 %6, 7
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = zext i8 %6 to i56
%10 = shl nuw nsw i56 %9, 3
%11 = lshr i56 32485265730126657, %10
%12 = trunc i56 %11 to i8
br label %13
13: ; preds = %5, %8, %3
%14 = phi i8 [ %4, %3 ], [ %12, %8 ], [ 78, %5 ]
ret i8 %14
}