int freecell_solver_u2p_card_number(const char *string) {
  char rest;
  while (1) {
    rest = ((((*string) >= 'a') && ((*string) <= 'z')) ? ((*string) + 'A' - 'a')
                                                       : (*string));
    if ((rest == '\0') || (rest == ' ') || (rest == '\t')) {
      return 0;
    }
    if (rest == 'A') {
      return 1;
    } else if (rest == 'J') {
      return 11;
    } else if (rest == 'Q') {
      return 12;
    } else if (rest == 'K') {
      return 13;
    } else if (rest == '1') {
      return (*(string + 1) == '0') ? 10 : 1;
    } else if ((rest == '0') || (rest == 'T')) {
      return 10;
    } else if ((rest >= '2') && (rest <= '9')) {
      return (rest - '0');
    } else {
      string++;
    }
  }
}


x86 assembly (clang, -O0):
<freecell_solver_u2p_card_number>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     113d <freecell_solver_u2p_card_number+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     113d <freecell_solver_u2p_card_number+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0x41,%eax
sub    $0x61,%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <freecell_solver_u2p_card_number+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1174 <freecell_solver_u2p_card_number+0x74>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
je     1174 <freecell_solver_u2p_card_number+0x74>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
jne    1180 <freecell_solver_u2p_card_number+0x80>
movl   $0x0,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jne    1199 <freecell_solver_u2p_card_number+0x99>
movl   $0x1,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x4a,%eax
jne    11b2 <freecell_solver_u2p_card_number+0xb2>
movl   $0xb,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x51,%eax
jne    11cb <freecell_solver_u2p_card_number+0xcb>
movl   $0xc,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x4b,%eax
jne    11e4 <freecell_solver_u2p_card_number+0xe4>
movl   $0xd,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x31,%eax
jne    1211 <freecell_solver_u2p_card_number+0x111>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edx
mov    $0x1,%eax
mov    $0xa,%ecx
cmp    $0x30,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x30,%eax
je     122b <freecell_solver_u2p_card_number+0x12b>
movsbl -0x11(%rbp),%eax
cmp    $0x54,%eax
jne    1237 <freecell_solver_u2p_card_number+0x137>
movl   $0xa,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
movsbl -0x11(%rbp),%eax
cmp    $0x32,%eax
jl     1260 <freecell_solver_u2p_card_number+0x160>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
jg     1260 <freecell_solver_u2p_card_number+0x160>
movsbl -0x11(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    128f <freecell_solver_u2p_card_number+0x18f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1271 <freecell_solver_u2p_card_number+0x171>
jmp    1276 <freecell_solver_u2p_card_number+0x176>
jmp    127b <freecell_solver_u2p_card_number+0x17b>
jmp    1280 <freecell_solver_u2p_card_number+0x180>
jmp    1285 <freecell_solver_u2p_card_number+0x185>
jmp    128a <freecell_solver_u2p_card_number+0x18a>
jmp    1108 <freecell_solver_u2p_card_number+0x8>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<freecell_solver_u2p_card_number>:
add    $0x1,%rdi
lea    0xef5(%rip),%rax
movzbl -0x1(%rdi),%edx
lea    -0x61(%rdx),%ecx
lea    -0x20(%rdx),%esi
cmp    $0x1a,%cl
movzbl %sil,%ecx
cmovae %edx,%ecx
cmp    $0x54,%cl
ja     1130 <freecell_solver_u2p_card_number+0x30>
movzbl %cl,%edx
movslq (%rax,%rdx,4),%rdx
add    %rax,%rdx
jmp    *%rdx
lea    -0x32(%rcx),%edx
cmp    $0x7,%dl
jbe    116e <freecell_solver_u2p_card_number+0x6e>
add    $0x1,%rdi
jmp    110b <freecell_solver_u2p_card_number+0xb>
xor    %eax,%eax
ret
mov    $0xa,%eax
ret
xor    %eax,%eax
cmpb   $0x30,(%rdi)
sete   %al
lea    (%rax,%rax,8),%eax
add    $0x1,%eax
ret
mov    $0x1,%eax
ret
mov    $0xb,%eax
ret
mov    $0xd,%eax
ret
mov    $0xc,%eax
ret
movzbl %cl,%eax
add    $0xffffffd0,%eax
ret

LLVM IR (-O0):
define i32 @freecell_solver_u2p_card_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
br label %5
5: ; preds = %1, %102
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp sge i32 %8, 97
br i1 %9, label %10, label %21
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp sle i32 %13, 122
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = add nsw i32 %18, 65
%20 = sub nsw i32 %19, 97
br label %25
21: ; preds = %10, %5
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
br label %25
25: ; preds = %21, %15
%26 = phi i32 [ %20, %15 ], [ %24, %21 ]
%27 = trunc i32 %26 to i8
store i8 %27, i8* %4
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %39, label %31
31: ; preds = %25
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 32
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i8, i8* %4
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 9
br i1 %38, label %39, label %40
39: ; preds = %35, %31, %25
store i32 0, i32* %2
br label %103
40: ; preds = %35
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 65
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 1, i32* %2
br label %103
45: ; preds = %40
%46 = load i8, i8* %4
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 74
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 11, i32* %2
br label %103
50: ; preds = %45
%51 = load i8, i8* %4
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 81
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 12, i32* %2
br label %103
55: ; preds = %50
%56 = load i8, i8* %4
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 75
br i1 %58, label %59, label %60
59: ; preds = %55
store i32 13, i32* %2
br label %103
60: ; preds = %55
%61 = load i8, i8* %4
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 49
br i1 %63, label %64, label %72
64: ; preds = %60
%65 = load i8*, i8** %3
%66 = getelementptr inbounds i8, i8* %65, i64 1
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 48
%70 = zext i1 %69 to i64
%71 = select i1 %69, i32 10, i32 1
store i32 %71, i32* %2
br label %103
72: ; preds = %60
%73 = load i8, i8* %4
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 48
br i1 %75, label %80, label %76
76: ; preds = %72
%77 = load i8, i8* %4
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 84
br i1 %79, label %80, label %81
80: ; preds = %76, %72
store i32 10, i32* %2
br label %103
81: ; preds = %76
%82 = load i8, i8* %4
%83 = sext i8 %82 to i32
%84 = icmp sge i32 %83, 50
br i1 %84, label %85, label %93
85: ; preds = %81
%86 = load i8, i8* %4
%87 = sext i8 %86 to i32
%88 = icmp sle i32 %87, 57
br i1 %88, label %89, label %93
89: ; preds = %85
%90 = load i8, i8* %4
%91 = sext i8 %90 to i32
%92 = sub nsw i32 %91, 48
store i32 %92, i32* %2
br label %103
93: ; preds = %85, %81
%94 = load i8*, i8** %3
%95 = getelementptr inbounds i8, i8* %94, i32 1
store i8* %95, i8** %3
br label %96
96: ; preds = %93
br label %97
97: ; preds = %96
br label %98
98: ; preds = %97
br label %99
99: ; preds = %98
br label %100
100: ; preds = %99
br label %101
101: ; preds = %100
br label %102
102: ; preds = %101
br label %5
103: ; preds = %89, %80, %64, %59, %54, %49, %44, %39
%104 = load i32, i32* %2
ret i32 %104
}

LLVM IR (-O2):
define i32 @freecell_solver_u2p_card_number(i8* nocapture %0) {
br label %2
2: ; preds = %20, %1
%3 = phi i8* [ %0, %1 ], [ %21, %20 ]
%4 = load i8, i8* %3
%5 = add i8 %4, -97
%6 = icmp ult i8 %5, 26
%7 = add nsw i8 %4, -32
%8 = select i1 %6, i8 %7, i8 %4
switch i8 %8, label %14 [
i8 32, label %22
i8 9, label %22
i8 0, label %22
i8 65, label %23
i8 74, label %24
i8 81, label %25
i8 75, label %26
i8 49, label %9
i8 84, label %27
i8 48, label %27
]
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 48
%13 = select i1 %12, i32 10, i32 1
br label %27
14: ; preds = %2
%15 = add i8 %8, -50
%16 = icmp ult i8 %15, 8
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = zext i8 %8 to i32
%19 = add nsw i32 %18, -48
br label %27
20: ; preds = %14
%21 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
22: ; preds = %2, %2, %2
br label %27
23: ; preds = %2
br label %27
24: ; preds = %2
br label %27
25: ; preds = %2
br label %27
26: ; preds = %2
br label %27
27: ; preds = %2, %2, %26, %25, %24, %23, %22, %17, %9
%28 = phi i32 [ %13, %9 ], [ %19, %17 ], [ 0, %22 ], [ 1, %23 ], [ 11, %24 ], [ 12, %25 ], [ 13, %26 ], [ 10, %2 ], [ 10, %2 ]
ret i32 %28
}