int rank(c)
char c;
{
  switch (c) {
  case 'A':
    return 0;
    break;
  case '1':
    return 1;
    break;
  case '2':
    return 2;
    break;
  case '3':
    return 3;
    break;
  case '4':
    return 4;
    break;
  case '5':
    return 5;
    break;
  case '6':
    return 6;
    break;
  case '7':
    return 7;
    break;
  case '8':
    return 8;
    break;
  case '9':
    return 9;
    break;
  case 'J':
    return 10;
    break;
  case 'Q':
    return 11;
    break;
  case 'K':
    return 12;
    break;
  default:
    return -1;
    break;
  }
}


x86 assembly (clang, -O0):
<rank>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x20,%eax
ja     11d0 <rank+0xd0>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x2,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x3,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x4,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x5,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x6,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x7,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x8,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0x9,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0xa,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0xb,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0xc,-0x4(%rbp)
jmp    11d7 <rank+0xd7>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rank>:
movsbl %dil,%ecx
add    $0xffffffcf,%ecx
cmp    $0x20,%ecx
ja     1154 <rank+0x54>
xor    %eax,%eax
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1,%eax
ret
mov    $0x2,%eax
ret
mov    $0x3,%eax
ret
mov    $0x4,%eax
ret
mov    $0x5,%eax
ret
mov    $0x6,%eax
ret
mov    $0x7,%eax
ret
mov    $0x8,%eax
ret
mov    $0x9,%eax
ret
mov    $0xffffffff,%eax
ret
mov    $0xa,%eax
ret
mov    $0xc,%eax
ret
mov    $0xb,%eax
ret

LLVM IR (-O0):
define i32 @rank(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = trunc i32 %0 to i8
store i8 %4, i8* %3
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
switch i32 %6, label %20 [
i32 65, label %7
i32 49, label %8
i32 50, label %9
i32 51, label %10
i32 52, label %11
i32 53, label %12
i32 54, label %13
i32 55, label %14
i32 56, label %15
i32 57, label %16
i32 74, label %17
i32 81, label %18
i32 75, label %19
]
7: ; preds = %1
store i32 0, i32* %2
br label %21
8: ; preds = %1
store i32 1, i32* %2
br label %21
9: ; preds = %1
store i32 2, i32* %2
br label %21
10: ; preds = %1
store i32 3, i32* %2
br label %21
11: ; preds = %1
store i32 4, i32* %2
br label %21
12: ; preds = %1
store i32 5, i32* %2
br label %21
13: ; preds = %1
store i32 6, i32* %2
br label %21
14: ; preds = %1
store i32 7, i32* %2
br label %21
15: ; preds = %1
store i32 8, i32* %2
br label %21
16: ; preds = %1
store i32 9, i32* %2
br label %21
17: ; preds = %1
store i32 10, i32* %2
br label %21
18: ; preds = %1
store i32 11, i32* %2
br label %21
19: ; preds = %1
store i32 12, i32* %2
br label %21
20: ; preds = %1
store i32 -1, i32* %2
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
define i32 @rank(i32 %0) {
%2 = shl i32 %0, 24
%3 = ashr exact i32 %2, 24
switch i32 %3, label %16 [
i32 65, label %17
i32 49, label %4
i32 50, label %5
i32 51, label %6
i32 52, label %7
i32 53, label %8
i32 54, label %9
i32 55, label %10
i32 56, label %11
i32 57, label %12
i32 74, label %13
i32 81, label %14
i32 75, label %15
]
4: ; preds = %1
br label %17
5: ; preds = %1
br label %17
6: ; preds = %1
br label %17
7: ; preds = %1
br label %17
8: ; preds = %1
br label %17
9: ; preds = %1
br label %17
10: ; preds = %1
br label %17
11: ; preds = %1
br label %17
12: ; preds = %1
br label %17
13: ; preds = %1
br label %17
14: ; preds = %1
br label %17
15: ; preds = %1
br label %17
16: ; preds = %1
br label %17
17: ; preds = %1, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
%18 = phi i32 [ -1, %16 ], [ 12, %15 ], [ 11, %14 ], [ 10, %13 ], [ 9, %12 ], [ 8, %11 ], [ 7, %10 ], [ 6, %9 ], [ 5, %8 ], [ 4, %7 ], [ 3, %6 ], [ 2, %5 ], [ 1, %4 ], [ 0, %1 ]
ret i32 %18
}