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


x86 assembly (clang, -O0):
<setVal>:
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 <setVal+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 <setVal+0xaf>
mov    -0x18(%rbp),%rax
movl   $0xb,(%rax)
jmp    11cf <setVal+0xaf>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <setVal+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 <setVal+0x92>
mov    -0x18(%rbp),%rax
cmpl   $0xa,(%rax)
jle    11ca <setVal+0xaa>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1f4,-0x4(%rbp)
jmp    11d6 <setVal+0xb6>
jmp    11cf <setVal+0xaf>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [30 x i8] c"I don't understand that value\00"
define i32 @setVal(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 0, 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 ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 500, i32* %3
br label %30
28: ; preds = %22
br label %29
29: ; preds = %28, %12, %10
store i32 1, i32* %3
br label %30
30: ; preds = %29, %26, %14
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [30 x i8] c"I don't understand that value\00"
define i32 @setVal(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 ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %5, %6, %7, %2, %11
%14 = phi i32 [ 500, %11 ], [ 0, %2 ], [ 1, %7 ], [ 1, %6 ], [ 1, %5 ]
ret i32 %14
}