#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 */
int atoi(char *);
int parseCard(char *card_name) {
  int val;
  if (card_name[0] == 'A')
    val = 11;
  else if (card_name[0] == 'K' || card_name[0] == 'Q' || card_name[0] == 'J')
    val = 10;
  else {
    val = atoi(card_name);
    if (val > 10 || val < 2)
      return -1;
  }
  return val;
}


x86 assembly (clang, -O0):
<parseCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jne    1138 <parseCard+0x28>
movl   $0xb,-0x14(%rbp)
jmp    11aa <parseCard+0x9a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4b,%eax
je     1168 <parseCard+0x58>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x51,%eax
je     1168 <parseCard+0x58>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4a,%eax
jne    1174 <parseCard+0x64>
movl   $0xa,-0x14(%rbp)
jmp    11a5 <parseCard+0x95>
mov    -0x10(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jg     1194 <parseCard+0x84>
cmpl   $0x2,-0x14(%rbp)
jge    11a0 <parseCard+0x90>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <parseCard+0xa0>
jmp    11a5 <parseCard+0x95>
jmp    11aa <parseCard+0x9a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseCard>:
push   %rax
mov    (%rdi),%al
lea    -0x4a(%rax),%ecx
cmp    $0x2,%cl
jb     1123 <parseCard+0x13>
cmp    $0x41,%al
je     112a <parseCard+0x1a>
cmp    $0x51,%al
jne    1131 <parseCard+0x21>
mov    $0xa,%eax
jmp    1145 <parseCard+0x35>
mov    $0xb,%eax
jmp    1145 <parseCard+0x35>
call   1030 <atoi@plt>
mov    %eax,%edx
add    $0xfffffff5,%edx
mov    $0xffffffff,%ecx
cmp    $0xfffffff7,%edx
jb     1147 <parseCard+0x37>
mov    %eax,%ecx
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @parseCard(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 65
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 11, i32* %4
br label %41
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 75
br i1 %16, label %29, label %17
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 81
br i1 %22, label %29, label %23
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 74
br i1 %28, label %29, label %30
29: ; preds = %23, %17, %11
store i32 10, i32* %4
br label %40
30: ; preds = %23
%31 = load i8*, i8** %3
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 10
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 2
br i1 %37, label %38, label %39
38: ; preds = %35, %30
store i32 -1, i32* %2
br label %43
39: ; preds = %35
br label %40
40: ; preds = %39, %29
br label %41
41: ; preds = %40, %10
%42 = load i32, i32* %4
store i32 %42, i32* %2
br label %43
43: ; preds = %41, %38
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
define i32 @parseCard(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %4 [
i8 65, label %8
i8 75, label %3
i8 81, label %3
i8 74, label %3
]
3: ; preds = %1, %1, %1
br label %8
4: ; preds = %1
%5 = tail call i32 @atoi(i8* %0)
%6 = add i32 %5, -11
%7 = icmp ult i32 %6, -9
br i1 %7, label %10, label %8
8: ; preds = %1, %3, %4
%9 = phi i32 [ 10, %3 ], [ %5, %4 ], [ 11, %1 ]
br label %10
10: ; preds = %4, %8
%11 = phi i32 [ %9, %8 ], [ -1, %4 ]
ret i32 %11
}