int position(char c) {
  if (c >= '0' && c <= '9')
    return c - '0';
  switch (c) {
  case 'A':
    return 14;
  case 'K':
    return 13;
  case 'Q':
    return 12;
  case 'J':
    return 11;
  case 'T':
    return 10;
  }
  return 0;
}


x86 assembly (clang, -O0):
<position>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     1133 <position+0x33>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     1133 <position+0x33>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <position+0xa0>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     1199 <position+0x99>
mov    -0x10(%rbp),%rax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xe,-0x4(%rbp)
jmp    11a0 <position+0xa0>
movl   $0xd,-0x4(%rbp)
jmp    11a0 <position+0xa0>
movl   $0xc,-0x4(%rbp)
jmp    11a0 <position+0xa0>
movl   $0xb,-0x4(%rbp)
jmp    11a0 <position+0xa0>
movl   $0xa,-0x4(%rbp)
jmp    11a0 <position+0xa0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<position>:
lea    -0x30(%rdi),%eax
cmp    $0x9,%al
ja     110d <position+0xd>
add    $0xffffffd0,%edi
mov    %edi,%eax
ret
add    $0xffffffbf,%edi
cmp    $0x13,%edi
ja     1130 <position+0x30>
mov    $0xe,%eax
lea    0xedf(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    $0xb,%eax
ret
xor    %eax,%eax
ret
mov    $0xd,%eax
ret
mov    $0xc,%eax
ret
mov    $0xa,%eax
ret

LLVM IR (-O0):
define i32 @position(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 %24
15: ; preds = %7, %1
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
switch i32 %17, label %23 [
i32 65, label %18
i32 75, label %19
i32 81, label %20
i32 74, label %21
i32 84, label %22
]
18: ; preds = %15
store i32 14, i32* %2
br label %24
19: ; preds = %15
store i32 13, i32* %2
br label %24
20: ; preds = %15
store i32 12, i32* %2
br label %24
21: ; preds = %15
store i32 11, i32* %2
br label %24
22: ; preds = %15
store i32 10, i32* %2
br label %24
23: ; preds = %15
store i32 0, i32* %2
br label %24
24: ; preds = %23, %22, %21, %20, %19, %18, %11
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @position(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 %13
7: ; preds = %1
switch i32 %2, label %12 [
i32 65, label %13
i32 75, label %8
i32 81, label %9
i32 74, label %10
i32 84, label %11
]
8: ; preds = %7
br label %13
9: ; preds = %7
br label %13
10: ; preds = %7
br label %13
11: ; preds = %7
br label %13
12: ; preds = %7
br label %13
13: ; preds = %7, %12, %11, %10, %9, %8, %5
%14 = phi i32 [ %6, %5 ], [ 0, %12 ], [ 10, %11 ], [ 11, %10 ], [ 12, %9 ], [ 13, %8 ], [ 14, %7 ]
ret i32 %14
}