#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 determine_card_number(char card_name[]) {
  puts("We are in determine_card_number");
  int val;
  switch (card_name[0]) {
  case 'K':
  case 'Q':
  case 'J':
    val = 10;
    break;
  case 'A':
    val = 11;
    break;
  default:
    val = atoi(card_name);
    if ((val < 1) || (val > 10)) {
      puts("I don't understand that value!");
    }
  }
  return val;
}


x86 assembly (clang, -O0):
<determine_card_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
sub    $0x41,%eax
je     1181 <determine_card_number+0x61>
jmp    1150 <determine_card_number+0x30>
mov    -0x10(%rbp),%eax
add    $0xffffffb6,%eax
sub    $0x2,%eax
jb     1175 <determine_card_number+0x55>
jmp    1164 <determine_card_number+0x44>
mov    -0x10(%rbp),%eax
sub    $0x51,%eax
jne    118d <determine_card_number+0x6d>
jmp    1175 <determine_card_number+0x55>
movl   $0xa,-0xc(%rbp)
jmp    11be <determine_card_number+0x9e>
movl   $0xb,-0xc(%rbp)
jmp    11be <determine_card_number+0x9e>
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11ad <determine_card_number+0x8d>
cmpl   $0xa,-0xc(%rbp)
jle    11b9 <determine_card_number+0x99>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
jmp    11be <determine_card_number+0x9e>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_card_number>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
movsbl (%rbx),%eax
mov    $0xa,%ebp
lea    -0x4a(%rax),%ecx
cmp    $0x2,%ecx
jb     1171 <determine_card_number+0x51>
cmp    $0x51,%eax
je     1171 <determine_card_number+0x51>
cmp    $0x41,%eax
jne    1153 <determine_card_number+0x33>
mov    $0xb,%ebp
jmp    1171 <determine_card_number+0x51>
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
add    $0xfffffff5,%eax
cmp    $0xfffffff5,%eax
ja     1171 <determine_card_number+0x51>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"We are in determine_card_number\00"
@.str.1 = [31 x i8] c"I don't understand that value!\00"
define i32 @determine_card_number(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %11 [
i32 75, label %9
i32 81, label %9
i32 74, label %9
i32 65, label %10
]
9: ; preds = %1, %1, %1
store i32 10, i32* %3
br label %22
10: ; preds = %1
store i32 11, i32* %3
br label %22
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 10
br i1 %18, label %19, label %21
19: ; preds = %16, %11
%20 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
br label %22
22: ; preds = %21, %10, %9
%23 = load i32, i32* %3
ret i32 %23
}

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