char translate(char character) {
  switch (character) {
  case 'H':
    return 0;
  case 'C':
    return 1;
  case 'S':
    return 2;
  case 'D':
    return 3;
  case 'T':
    return 10;
  case 'J':
    return 11;
  case 'Q':
    return 12;
  case 'K':
    return 13;
  case 'A':
    return 14;
  default:
    return (int)(character - '0');
  }
}


x86 assembly (clang, -O0):
<translate>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     1185 <translate+0x85>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0x1,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0x2,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0x3,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0xa,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0xb,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0xc,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0xd,-0x1(%rbp)
jmp    118f <translate+0x8f>
movb   $0xe,-0x1(%rbp)
jmp    118f <translate+0x8f>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate>:
mov    %edi,%eax
movslq %edi,%rcx
add    $0xffffffffffffffbf,%rcx
cmp    $0x14,%ecx
jae    1118 <translate+0x18>
mov    $0xd068d,%edx
bt     %ecx,%edx
jb     111b <translate+0x1b>
add    $0xd0,%al
ret
lea    0xede(%rip),%rax
mov    (%rcx,%rax,1),%al
ret

LLVM IR (-O0):
define signext i8 @translate(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 %15 [
i32 72, label %6
i32 67, label %7
i32 83, label %8
i32 68, label %9
i32 84, label %10
i32 74, label %11
i32 81, label %12
i32 75, label %13
i32 65, label %14
]
6: ; preds = %1
store i8 0, i8* %2
br label %20
7: ; preds = %1
store i8 1, i8* %2
br label %20
8: ; preds = %1
store i8 2, i8* %2
br label %20
9: ; preds = %1
store i8 3, i8* %2
br label %20
10: ; preds = %1
store i8 10, i8* %2
br label %20
11: ; preds = %1
store i8 11, i8* %2
br label %20
12: ; preds = %1
store i8 12, i8* %2
br label %20
13: ; preds = %1
store i8 13, i8* %2
br label %20
14: ; preds = %1
store i8 14, i8* %2
br label %20
15: ; preds = %1
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 48
%19 = trunc i32 %18 to i8
store i8 %19, i8* %2
br label %20
20: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%21 = load i8, i8* %2
ret i8 %21
}

LLVM IR (-O2):
@switch.table.translate = [20 x i8] c"\0E\00\01\03\00\00\00\00\00\0B\0D\00\00\00\00\00\0C\00\02\0A"
define signext i8 @translate(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -65
%4 = icmp ult i32 %3, 20
br i1 %4, label %7, label %5
5: ; preds = %7, %1
%6 = add i8 %0, -48
br label %15
7: ; preds = %1
%8 = lshr i32 853645, %3
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %7
%12 = sext i32 %3 to i64
%13 = getelementptr inbounds [20 x i8], [20 x i8]* @switch.table.translate, i64 0, i64 %12
%14 = load i8, i8* %13
br label %15
15: ; preds = %11, %5
%16 = phi i8 [ %6, %5 ], [ %14, %11 ]
ret i8 %16
}