char getCard(char card) {
  switch (card) {
  case 'A':
    return ('9' + 5);
  case 'K':
    return ('9' + 4);
  case 'Q':
    return ('9' + 3);
  case 'J':
    return ('9' + 2);
  case 'T':
    return ('9' + 1);
  case ('9' + 1):
    return 'T';
  case ('9' + 2):
    return 'J';
  case ('9' + 3):
    return 'Q';
  case ('9' + 4):
    return 'K';
  case ('9' + 5):
    return 'A';
  default:
    return card;
  }
}


x86 assembly (clang, -O0):
<getCard>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
add    $0xffffffc6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x1a,%eax
ja     118e <getCard+0x8e>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x3e,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x3d,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x3c,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x3b,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x3a,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x54,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x4a,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x51,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x4b,-0x1(%rbp)
jmp    1194 <getCard+0x94>
movb   $0x41,-0x1(%rbp)
jmp    1194 <getCard+0x94>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCard>:
lea    -0x3a(%rdi),%ecx
cmp    $0x1a,%ecx
ja     1129 <getCard+0x29>
mov    $0x3e,%al
lea    0xeef(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x54,%al
ret
mov    $0x4a,%al
ret
mov    $0x51,%al
ret
mov    $0x4b,%al
ret
mov    $0x41,%al
ret
mov    %edi,%eax
ret
mov    $0x3b,%al
ret
mov    $0x3d,%al
ret
mov    $0x3c,%al
ret
mov    $0x3a,%al
ret

LLVM IR (-O0):
define signext i8 @getCard(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 %16 [
i32 65, label %6
i32 75, label %7
i32 81, label %8
i32 74, label %9
i32 84, label %10
i32 58, label %11
i32 59, label %12
i32 60, label %13
i32 61, label %14
i32 62, label %15
]
6: ; preds = %1
store i8 62, i8* %2
br label %18
7: ; preds = %1
store i8 61, i8* %2
br label %18
8: ; preds = %1
store i8 60, i8* %2
br label %18
9: ; preds = %1
store i8 59, i8* %2
br label %18
10: ; preds = %1
store i8 58, i8* %2
br label %18
11: ; preds = %1
store i8 84, i8* %2
br label %18
12: ; preds = %1
store i8 74, i8* %2
br label %18
13: ; preds = %1
store i8 81, i8* %2
br label %18
14: ; preds = %1
store i8 75, i8* %2
br label %18
15: ; preds = %1
store i8 65, i8* %2
br label %18
16: ; preds = %1
%17 = load i8, i8* %3
store i8 %17, i8* %2
br label %18
18: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%19 = load i8, i8* %2
ret i8 %19
}

LLVM IR (-O2):
define signext i8 @getCard(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %12 [
i32 65, label %13
i32 75, label %3
i32 81, label %4
i32 74, label %5
i32 84, label %6
i32 58, label %7
i32 59, label %8
i32 60, label %9
i32 61, label %10
i32 62, label %11
]
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
br label %13
10: ; preds = %1
br label %13
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%14 = phi i8 [ %0, %12 ], [ 65, %11 ], [ 75, %10 ], [ 81, %9 ], [ 74, %8 ], [ 84, %7 ], [ 58, %6 ], [ 59, %5 ], [ 60, %4 ], [ 61, %3 ], [ 62, %1 ]
ret i8 %14
}