int freecell_solver_char_to_test_num(char c) {
  if ((c >= '0') && (c <= '9')) {
    return c - '0';
  } else if ((c >= 'a') && (c <= 'h')) {
    return c - 'a' + 10;
  } else if ((c >= 'A') && (c <= 'Z')) {
    return c - 'A' + 18;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<freecell_solver_char_to_test_num>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     1133 <freecell_solver_char_to_test_num+0x33>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     1133 <freecell_solver_char_to_test_num+0x33>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <freecell_solver_char_to_test_num+0x92>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     115f <freecell_solver_char_to_test_num+0x5f>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jg     115f <freecell_solver_char_to_test_num+0x5f>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <freecell_solver_char_to_test_num+0x92>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     118b <freecell_solver_char_to_test_num+0x8b>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     118b <freecell_solver_char_to_test_num+0x8b>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0x12,%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <freecell_solver_char_to_test_num+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<freecell_solver_char_to_test_num>:
mov    %edi,%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     110e <freecell_solver_char_to_test_num+0xe>
add    $0xffffffd0,%eax
ret
lea    -0x61(%rax),%ecx
cmp    $0x7,%cl
ja     111a <freecell_solver_char_to_test_num+0x1a>
add    $0xffffffa9,%eax
ret
lea    -0x41(%rax),%ecx
add    $0xffffffd1,%eax
xor    %edx,%edx
cmp    $0x1a,%cl
cmovb  %eax,%edx
mov    %edx,%eax
ret

LLVM IR (-O0):
define i32 @freecell_solver_char_to_test_num(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 48
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 57
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 48
store i32 %14, i32* %2
br label %42
15: ; preds = %7, %1
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 97
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 104
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = sub nsw i32 %25, 97
%27 = add nsw i32 %26, 10
store i32 %27, i32* %2
br label %42
28: ; preds = %19, %15
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp sge i32 %30, 65
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i8, i8* %3
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 90
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 65
%40 = add nsw i32 %39, 18
store i32 %40, i32* %2
br label %42
41: ; preds = %32, %28
store i32 0, i32* %2
br label %42
42: ; preds = %41, %36, %23, %11
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
define i32 @freecell_solver_char_to_test_num(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add i8 %0, -48
%4 = icmp ult i8 %3, 10
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i32 %2, -48
br label %17
7: ; preds = %1
%8 = add i8 %0, -97
%9 = icmp ult i8 %8, 8
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %2, -87
br label %17
12: ; preds = %7
%13 = add i8 %0, -65
%14 = icmp ult i8 %13, 26
%15 = add nsw i32 %2, -47
%16 = select i1 %14, i32 %15, i32 0
br label %17
17: ; preds = %12, %10, %5
%18 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %12 ]
ret i32 %18
}