int extract_rank(char c) {
  int rank;
  if (c == 't' || c == 'T')
    rank = 10;
  else if (c == 'j' || c == 'J')
    rank = 11;
  else if (c == 'q' || c == 'Q')
    rank = 12;
  else if (c == 'k' || c == 'K')
    rank = 13;
  else if (c == 'a' || c == 'A')
    rank = 14;
  else if (c >= '2' && c <= '9')
    rank = c - '0';
  else
    rank = 101;
  rank -= 2;
  return rank;
}


x86 assembly (clang, -O0):
<extract_rank>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x74,%eax
je     1124 <extract_rank+0x24>
movsbl -0x1(%rbp),%eax
cmp    $0x54,%eax
jne    1130 <extract_rank+0x30>
movl   $0xa,-0x8(%rbp)
jmp    1211 <extract_rank+0x111>
movsbl -0x1(%rbp),%eax
cmp    $0x6a,%eax
je     114a <extract_rank+0x4a>
movsbl -0x1(%rbp),%eax
cmp    $0x4a,%eax
jne    1156 <extract_rank+0x56>
movl   $0xb,-0x8(%rbp)
jmp    120c <extract_rank+0x10c>
movsbl -0x1(%rbp),%eax
cmp    $0x71,%eax
je     1170 <extract_rank+0x70>
movsbl -0x1(%rbp),%eax
cmp    $0x51,%eax
jne    117c <extract_rank+0x7c>
movl   $0xc,-0x8(%rbp)
jmp    1207 <extract_rank+0x107>
movsbl -0x1(%rbp),%eax
cmp    $0x6b,%eax
je     1196 <extract_rank+0x96>
movsbl -0x1(%rbp),%eax
cmp    $0x4b,%eax
jne    11a2 <extract_rank+0xa2>
movl   $0xd,-0x8(%rbp)
jmp    1202 <extract_rank+0x102>
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
je     11bc <extract_rank+0xbc>
movsbl -0x1(%rbp),%eax
cmp    $0x41,%eax
jne    11c8 <extract_rank+0xc8>
movl   $0xe,-0x8(%rbp)
jmp    11fd <extract_rank+0xfd>
movsbl -0x1(%rbp),%eax
cmp    $0x32,%eax
jl     11f1 <extract_rank+0xf1>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     11f1 <extract_rank+0xf1>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
jmp    11f8 <extract_rank+0xf8>
movl   $0x65,-0x8(%rbp)
jmp    11fd <extract_rank+0xfd>
jmp    1202 <extract_rank+0x102>
jmp    1207 <extract_rank+0x107>
jmp    120c <extract_rank+0x10c>
jmp    1211 <extract_rank+0x111>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_rank>:
mov    %edi,%ecx
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x13,%cl
ja     112b <extract_rank+0x2b>
mov    $0x8,%eax
movzbl %cl,%ecx
lea    0xee4(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0xc,%eax
ret
movsbl %dil,%ecx
add    $0xce,%dil
add    $0xffffffce,%ecx
cmp    $0x8,%dil
mov    $0x63,%eax
cmovb  %ecx,%eax
ret
mov    $0x9,%eax
ret
mov    $0xb,%eax
ret
mov    $0xa,%eax
ret

LLVM IR (-O0):
define i32 @extract_rank(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 116
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 84
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 10, i32* %3
br label %66
12: ; preds = %7
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 106
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 74
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i32 11, i32* %3
br label %65
21: ; preds = %16
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 113
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 81
br i1 %28, label %29, label %30
29: ; preds = %25, %21
store i32 12, i32* %3
br label %64
30: ; preds = %25
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 107
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 75
br i1 %37, label %38, label %39
38: ; preds = %34, %30
store i32 13, i32* %3
br label %63
39: ; preds = %34
%40 = load i8, i8* %2
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 97
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i8, i8* %2
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 65
br i1 %46, label %47, label %48
47: ; preds = %43, %39
store i32 14, i32* %3
br label %62
48: ; preds = %43
%49 = load i8, i8* %2
%50 = sext i8 %49 to i32
%51 = icmp sge i32 %50, 50
br i1 %51, label %52, label %60
52: ; preds = %48
%53 = load i8, i8* %2
%54 = sext i8 %53 to i32
%55 = icmp sle i32 %54, 57
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = load i8, i8* %2
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 48
store i32 %59, i32* %3
br label %61
60: ; preds = %52, %48
store i32 101, i32* %3
br label %61
61: ; preds = %60, %56
br label %62
62: ; preds = %61, %47
br label %63
63: ; preds = %62, %38
br label %64
64: ; preds = %63, %29
br label %65
65: ; preds = %64, %20
br label %66
66: ; preds = %65, %11
%67 = load i32, i32* %3
%68 = sub nsw i32 %67, 2
store i32 %68, i32* %3
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
define i32 @extract_rank(i8 signext %0) {
%2 = and i8 %0, -33
switch i8 %2, label %3 [
i8 84, label %13
i8 74, label %9
i8 81, label %10
i8 75, label %11
i8 65, label %12
]
3: ; preds = %1
%4 = sext i8 %0 to i32
%5 = add i8 %0, -50
%6 = icmp ult i8 %5, 8
%7 = add nsw i32 %4, -50
%8 = select i1 %6, i32 %7, i32 99
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, %3
%14 = phi i32 [ 8, %1 ], [ %8, %3 ], [ 9, %9 ], [ 10, %10 ], [ 11, %11 ], [ 12, %12 ]
ret i32 %14
}