#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char *strchr(char *, char);
int CardToInt(char rank, char suit) {
  const char *r = strchr("23456789TJQKA", rank);
  const char *s = strchr("CDHS", suit);
  if (!r || !s)
    return -1;
  return (r - "23456789TJQKA") * 4 + (s - "CDHS");
}


x86 assembly (clang, -O0):
<CardToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
lea    0xed5(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
lea    0xecf(%rip),%rdi
movsbl -0x6(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1162 <CardToInt+0x52>
cmpq   $0x0,-0x18(%rbp)
jne    116e <CardToInt+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <CardToInt+0x84>
mov    -0x10(%rbp),%rax
lea    0xe87(%rip),%rcx
sub    %rcx,%rax
shl    $0x2,%rax
mov    -0x18(%rbp),%rcx
lea    0xe83(%rip),%rdx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CardToInt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%esi
lea    0xede(%rip),%r14
mov    %r14,%rdi
call   1030 <strchr@plt>
mov    %rax,%rbx
lea    0xeda(%rip),%r15
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <strchr@plt>
mov    %ebx,%ecx
sub    %r14d,%ecx
mov    %eax,%edx
sub    %r15d,%edx
lea    (%rdx,%rcx,4),%ecx
cmp    $0x1,%rax
sbb    %edx,%edx
or     %ecx,%edx
cmp    $0x1,%rbx
sbb    %eax,%eax
or     %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"23456789TJQKA\00"
@.str.1 = [5 x i8] c"CDHS\00"
define i32 @CardToInt(i8 signext %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
store i8 %0, i8* %4
store i8 %1, i8* %5
%8 = load i8, i8* %4
%9 = call i8* @strchr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext %8)
store i8* %9, i8** %6
%10 = load i8, i8* %5
%11 = call i8* @strchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 signext %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14, %2
store i32 -1, i32* %3
br label %28
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = ptrtoint i8* %19 to i64
%21 = sub i64 %20, ptrtoint ([14 x i8]* @.str to i64)
%22 = mul nsw i64 %21, 4
%23 = load i8*, i8** %7
%24 = ptrtoint i8* %23 to i64
%25 = sub i64 %24, ptrtoint ([5 x i8]* @.str.1 to i64)
%26 = add nsw i64 %22, %25
%27 = trunc i64 %26 to i32
store i32 %27, i32* %3
br label %28
28: ; preds = %18, %17
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [14 x i8] c"23456789TJQKA\00"
@.str.1 = [5 x i8] c"CDHS\00"
define i32 @CardToInt(i8 signext %0, i8 signext %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext %0)
%4 = tail call i8* @strchr(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 signext %1)
%5 = icmp ne i8* %3, null
%6 = icmp ne i8* %4, null
%7 = select i1 %5, i1 %6, i1 false
%8 = ptrtoint i8* %3 to i64
%9 = sub i64 %8, ptrtoint ([14 x i8]* @.str to i64)
%10 = shl nsw i64 %9, 2
%11 = ptrtoint i8* %4 to i64
%12 = sub i64 %11, ptrtoint ([5 x i8]* @.str.1 to i64)
%13 = add nsw i64 %12, %10
%14 = trunc i64 %13 to i32
%15 = select i1 %7, i32 %14, i32 -1
ret i32 %15
}