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


x86 assembly (clang, -O0):
<get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x17,%eax
ja     1187 <get_value+0x67>
mov    -0x20(%rbp),%rax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
jmp    11cf <get_value+0xaf>
mov    -0x18(%rbp),%rax
movl   $0xb,(%rax)
jmp    11cf <get_value+0xaf>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <get_value+0xb6>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
jl     11b2 <get_value+0x92>
mov    -0x18(%rbp),%rax
cmpl   $0xa,(%rax)
jle    11ca <get_value+0xaa>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <get_value+0xb6>
jmp    11cf <get_value+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value>:
push   %rbx
mov    %rsi,%rbx
movsbl (%rdi),%eax
add    $0xffffffbf,%eax
cmp    $0x17,%eax
ja     114c <get_value+0x2c>
lea    0xeca(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
mov    $0x1,%eax
jmp    *%rdx
movl   $0xa,(%rbx)
jmp    1178 <get_value+0x58>
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    %eax,(%rbx)
add    $0xfffffff5,%ecx
xor    %eax,%eax
cmp    $0xfffffff5,%ecx
ja     1170 <get_value+0x50>
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
ret
movl   $0xb,(%rbx)
xor    %eax,%eax
pop    %rbx
ret

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

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