#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*/ isValid(int);
int /*<<< orphan*/ puts(char *);
void getCardValue(int *val, int *notX, char *ch, char *prompt) {
  switch (ch[0]) {
  case 'K':
  case 'Q':
  case 'J':
    *val = 10;
    break;
  case 'A':
    *val = 11;
    break;
  case 'X':
    *notX = 0;
    break;
  default:
    *val = atoi(ch);
    if (!isValid(*val)) {
      puts(prompt);
    }
  }
}


x86 assembly (clang, -O0):
<getCardValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x17,%eax
ja     11a2 <getCardValue+0x72>
mov    -0x28(%rbp),%rax
lea    0xe94(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
movl   $0xa,(%rax)
jmp    11d5 <getCardValue+0xa5>
mov    -0x8(%rbp),%rax
movl   $0xb,(%rax)
jmp    11d5 <getCardValue+0xa5>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    11d5 <getCardValue+0xa5>
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <isValid@plt>
cmp    $0x0,%eax
jne    11d0 <getCardValue+0xa0>
mov    -0x20(%rbp),%rdi
call   1030 <puts@plt>
jmp    11d5 <getCardValue+0xa5>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCardValue>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdi,%rbx
movsbl (%rdx),%eax
add    $0xffffffbf,%eax
cmp    $0x17,%eax
ja     1165 <getCardValue+0x35>
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,(%rbx)
jmp    118f <getCardValue+0x5f>
movl   $0xb,(%rbx)
jmp    118f <getCardValue+0x5f>
mov    %rdx,%rdi
call   1040 <atoi@plt>
mov    %eax,(%rbx)
mov    %eax,%edi
call   1050 <isValid@plt>
test   %eax,%eax
jne    118f <getCardValue+0x5f>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
movl   $0x0,(%rsi)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @getCardValue(i32* %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %19 [
i32 75, label %13
i32 81, label %13
i32 74, label %13
i32 65, label %15
i32 88, label %17
]
13: ; preds = %4, %4, %4
%14 = load i32*, i32** %5
store i32 10, i32* %14
br label %31
15: ; preds = %4
%16 = load i32*, i32** %5
store i32 11, i32* %16
br label %31
17: ; preds = %4
%18 = load i32*, i32** %6
store i32 0, i32* %18
br label %31
19: ; preds = %4
%20 = load i8*, i8** %7
%21 = call i32 @atoi(i8* %20)
%22 = load i32*, i32** %5
store i32 %21, i32* %22
%23 = load i32*, i32** %5
%24 = load i32, i32* %23
%25 = call i32 @isValid(i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %19
%28 = load i8*, i8** %8
%29 = call i32 @puts(i8* %28)
br label %30
30: ; preds = %27, %19
br label %31
31: ; preds = %30, %17, %15, %13
ret void
}

LLVM IR (-O2):
define void @getCardValue(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i8* nocapture %2, i8* nocapture %3) {
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
switch i32 %6, label %10 [
i32 75, label %7
i32 81, label %7
i32 74, label %7
i32 65, label %8
i32 88, label %9
]
7: ; preds = %4, %4, %4
store i32 10, i32* %0
br label %16
8: ; preds = %4
store i32 11, i32* %0
br label %16
9: ; preds = %4
store i32 0, i32* %1
br label %16
10: ; preds = %4
%11 = tail call i32 @atoi(i8* %2)
store i32 %11, i32* %0
%12 = tail call i32 @isValid(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) %3)
br label %16
16: ; preds = %10, %14, %9, %8, %7
ret void
}