#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 counter(int *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read_card(char *);
void choises(char card_name[], int *count) {
  while (card_name[0] != 'X') {
    int val = 0;
    read_card(card_name);
    switch (card_name[0]) {
    case 'K':
    case 'Q':
    case 'J':
      val = 10;
      break;
    case 'A':
      val = 11;
      break;
    case 'X':
      continue;
    default:
      val = atoi(card_name);
      if ((val < 1) || (val > 10)) {
        puts("I don't understand that value!");
        continue;
      }
    }
    printf("Current count: %i\n", counter(&val, count));
  }
}


x86 assembly (clang, -O0):
<choises>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x58,%eax
je     1220 <choises+0xd0>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <read_card@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x17,%eax
ja     11ca <choises+0x7a>
mov    -0x20(%rbp),%rax
lea    0xe5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x14(%rbp)
jmp    1200 <choises+0xb0>
movl   $0xb,-0x14(%rbp)
jmp    1200 <choises+0xb0>
jmp    1160 <choises+0x10>
mov    -0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11ea <choises+0x9a>
cmpl   $0xa,-0x14(%rbp)
jle    11fb <choises+0xab>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
jmp    1160 <choises+0x10>
jmp    1200 <choises+0xb0>
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdi
call   1050 <counter@plt>
mov    %eax,%esi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
jmp    1160 <choises+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choises>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmpb   $0x58,(%rdi)
jne    116f <choises+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xee4(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xef7(%rip),%r13
lea    0xe71(%rip),%rbp
jmp    11c4 <choises+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0xa,0x4(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <counter@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
movzbl (%rbx),%eax
cmp    $0x58,%al
je     1160 <choises+0x10>
movl   $0x0,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <read_card@plt>
movsbl (%rbx),%eax
lea    -0x41(%rax),%ecx
cmp    $0x17,%ecx
ja     11f3 <choises+0xa3>
movslq 0x0(%rbp,%rcx,4),%rcx
add    %rbp,%rcx
jmp    *%rcx
movl   $0xb,0x4(%rsp)
jmp    11a8 <choises+0x58>
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,0x4(%rsp)
add    $0xfffffff5,%eax
cmp    $0xfffffff5,%eax
ja     11a8 <choises+0x58>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11bd <choises+0x6d>

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

LLVM IR (-O2):
@.str = [31 x i8] c"I don't understand that value!\00"
@.str.1 = [19 x i8] c"Current count: %i\0A\00"
define void @choises(i8* %0, i32* %1) {
%3 = alloca i32
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 88
br i1 %5, label %28, label %6
6: ; preds = %2
%7 = bitcast i32* %3 to i8*
br label %8
8: ; preds = %6, %25
store i32 0, i32* %3
%9 = call i32 @read_card(i8* %0)
%10 = load i8, i8* %0
%11 = sext i8 %10 to i32
switch i32 %11, label %14 [
i32 75, label %12
i32 81, label %12
i32 74, label %12
i32 65, label %13
i32 88, label %25
]
12: ; preds = %8, %8, %8
store i32 10, i32* %3
br label %20
13: ; preds = %8
store i32 11, i32* %3
br label %20
14: ; preds = %8
%15 = call i32 @atoi(i8* %0)
store i32 %15, i32* %3
%16 = add i32 %15, -11
%17 = icmp ult i32 %16, -10
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %23
20: ; preds = %14, %13, %12
%21 = call i32 @counter(i32* %3, i32* %1)
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %18, %20
%24 = load i8, i8* %0
br label %25
25: ; preds = %23, %8
%26 = phi i8 [ %24, %23 ], [ %10, %8 ]
%27 = icmp eq i8 %26, 88
br i1 %27, label %28, label %8
28: ; preds = %25, %2
ret void
}