#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*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char card_name[3];
  int count = 0;
  int val;
  do {
    puts("Enter the card name: ");
    scanf("%2s", card_name);
    val = 0;
    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("That value doesn't work");
        continue;
      }
    }
    if ((val > 2) && (val < 7)) {
      count++;
    } else if (val == 10) {
      count--;
    }
    printf("Current count: %i\n", count);
  } while (card_name[0] != 'X');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xf03(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0d(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movsbl -0x7(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x17,%eax
ja     11c0 <main+0x80>
mov    -0x18(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x10(%rbp)
jmp    11f6 <main+0xb6>
movl   $0xb,-0x10(%rbp)
jmp    11f6 <main+0xb6>
jmp    123f <main+0xff>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11e0 <main+0xa0>
cmpl   $0xa,-0x10(%rbp)
jle    11f1 <main+0xb1>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
jmp    123f <main+0xff>
jmp    11f6 <main+0xb6>
cmpl   $0x2,-0x10(%rbp)
jle    1218 <main+0xd8>
cmpl   $0x7,-0x10(%rbp)
jge    1218 <main+0xd8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1230 <main+0xf0>
cmpl   $0xa,-0x10(%rbp)
jne    122b <main+0xeb>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1230 <main+0xf0>
mov    -0xc(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
jne    1156 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0xf0c(%rip),%r14
lea    0xf1b(%rip),%r15
lea    0x5(%rsp),%r12
lea    0xf2b(%rip),%rbp
lea    0xe92(%rip),%r13
jmp    1186 <main+0x46>
add    $0xffffffff,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
movzbl 0x5(%rsp),%eax
cmp    $0x58,%al
je     11ea <main+0xaa>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movsbl 0x5(%rsp),%eax
lea    -0x41(%rax),%ecx
cmp    $0x17,%ecx
ja     11b0 <main+0x70>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
mov    %r12,%rdi
call   1060 <atoi@plt>
lea    -0xb(%rax),%ecx
cmp    $0xfffffff5,%ecx
ja     11ce <main+0x8e>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
jmp    117d <main+0x3d>
lea    -0x3(%rax),%ecx
xor    %edx,%edx
cmp    $0xa,%eax
sete   %dl
neg    %edx
cmp    $0x4,%ecx
mov    $0x1,%eax
cmovb  %eax,%edx
add    %edx,%ebx
jmp    1173 <main+0x33>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter the card name: \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [24 x i8] c"That value doesn't work\00"
@.str.3 = [19 x i8] c"Current count: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %45, %0
%6 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
store i32 0, i32* %4
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %15 [
i32 75, label %12
i32 81, label %12
i32 74, label %12
i32 65, label %13
i32 88, label %14
]
12: ; preds = %5, %5, %5
store i32 10, i32* %4
br label %26
13: ; preds = %5
store i32 11, i32* %4
br label %26
14: ; preds = %5
br label %45
15: ; preds = %5
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 10
br i1 %22, label %23, label %25
23: ; preds = %20, %15
%24 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %45
25: ; preds = %20
br label %26
26: ; preds = %25, %13, %12
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 7
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %42
35: ; preds = %29, %26
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %3
%40 = add nsw i32 %39, -1
store i32 %40, i32* %3
br label %41
41: ; preds = %38, %35
br label %42
42: ; preds = %41, %32
%43 = load i32, i32* %3
%44 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %23, %14
%46 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 88
br i1 %49, label %5, label %50
50: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter the card name: \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [24 x i8] c"That value doesn't work\00"
@.str.3 = [19 x i8] c"Current count: %i\0A\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %30, %0
%4 = phi i32 [ 0, %0 ], [ %32, %30 ]
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
switch i32 %8, label %9 [
i32 75, label %15
i32 81, label %15
i32 74, label %15
i32 65, label %24
i32 88, label %30
]
9: ; preds = %3
%10 = call i32 @atoi(i8* %2)
%11 = add i32 %10, -11
%12 = icmp ult i32 %11, -10
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %27
15: ; preds = %3, %3, %3
%16 = add nsw i32 %4, -1
br label %24
17: ; preds = %9
%18 = add nsw i32 %10, -3
%19 = icmp ult i32 %18, 4
%20 = icmp eq i32 %10, 10
%21 = sext i1 %20 to i32
%22 = select i1 %19, i32 1, i32 %21
%23 = add nsw i32 %22, %4
br label %24
24: ; preds = %17, %15, %3
%25 = phi i32 [ %4, %3 ], [ %16, %15 ], [ %23, %17 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %13, %24
%28 = phi i32 [ %25, %24 ], [ %4, %13 ]
%29 = load i8, i8* %2
br label %30
30: ; preds = %27, %3
%31 = phi i8 [ %29, %27 ], [ %7, %3 ]
%32 = phi i32 [ %28, %27 ], [ %4, %3 ]
%33 = icmp eq i8 %31, 88
br i1 %33, label %34, label %3
34: ; preds = %30
ret i32 0
}