#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 /*<<< orphan*/ puts(char *);
int card_count(int val, char *card_name) {
  if (card_name[0] == 'K' || card_name[0] == 'Q' || card_name[0] == 'J') {
    val = 10;
  } else if (card_name[0] == 'A') {
    val = 11;
  } else {
    val = atoi(card_name);
    if ((val < 1) || (val > 10)) {
      puts("I don't understand that value!");
    }
  }
}


x86 assembly (clang, -O0):
<card_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4b,%eax
je     115f <card_count+0x3f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x51,%eax
je     115f <card_count+0x3f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4a,%eax
jne    116b <card_count+0x4b>
movl   $0xa,-0x8(%rbp)
jmp    11bd <card_count+0x9d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jne    1187 <card_count+0x67>
movl   $0xb,-0x8(%rbp)
jmp    11b8 <card_count+0x98>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     11a7 <card_count+0x87>
cmpl   $0xa,-0x8(%rbp)
jle    11b3 <card_count+0x93>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
jmp    11b8 <card_count+0x98>
jmp    11bd <card_count+0x9d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<card_count>:
push   %rax
mov    (%rsi),%al
add    $0xbf,%al
cmp    $0x10,%al
ja     1139 <card_count+0x19>
movzbl %al,%eax
mov    $0x10601,%ecx
bt     %rax,%rcx
jae    1139 <card_count+0x19>
pop    %rcx
ret
mov    %rsi,%rdi
call   1040 <atoi@plt>
add    $0xfffffff5,%eax
cmp    $0xfffffff5,%eax
ja     1137 <card_count+0x17>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [31 x i8] c"I don't understand that value!\00"
define i32 @card_count(i32 %0, i8* nocapture %1) {
%3 = load i8, i8* %1
switch i8 %3, label %4 [
i8 75, label %10
i8 81, label %10
i8 74, label %10
i8 65, label %10
]
4: ; preds = %2
%5 = tail call i32 @atoi(i8* %1)
%6 = add i32 %5, -11
%7 = icmp ult i32 %6, -10
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %2, %2, %2, %2, %4, %8
ret i32 undef
}