#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 cases(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':
    break;
  default:
    val = atoi(card_name);
    if ((val < 1) || (val > 10)) {
      puts("I don't understand that value!");
      break;
    }
  }
  return val;
}


x86 assembly (clang, -O0):
<cases>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x17,%eax
ja     1179 <cases+0x59>
mov    -0x18(%rbp),%rax
lea    0xead(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0xc(%rbp)
jmp    11af <cases+0x8f>
movl   $0xb,-0xc(%rbp)
jmp    11af <cases+0x8f>
jmp    11af <cases+0x8f>
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     1199 <cases+0x79>
cmpl   $0xa,-0xc(%rbp)
jle    11aa <cases+0x8a>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
jmp    11af <cases+0x8f>
jmp    11af <cases+0x8f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cases>:
push   %rbx
movsbl (%rdi),%eax
add    $0xffffffbf,%eax
cmp    $0x17,%eax
ja     1145 <cases+0x25>
mov    %esi,%ebx
lea    0xecb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xa,%ebx
jmp    1167 <cases+0x47>
call   1040 <atoi@plt>
mov    %eax,%ebx
add    $0xfffffff5,%eax
cmp    $0xfffffff5,%eax
ja     1167 <cases+0x47>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
jmp    1167 <cases+0x47>
mov    $0xb,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

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