#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;
  while (card_name[0] != 'X') {
    puts("Enter the card_name: ");
    scanf("%2s", card_name);
    int val;
    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("Naaaahhhh");
        continue;
      }
    }
    if ((val > 2) && (val < 7))
      count++;
    else if (val == 10)
      count--;
    printf("Count %i\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
je     1251 <main+0x111>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xf00(%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     11cd <main+0x8d>
mov    -0x18(%rbp),%rax
lea    0xe59(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x10(%rbp)
jmp    1203 <main+0xc3>
movl   $0xb,-0x10(%rbp)
jmp    1203 <main+0xc3>
jmp    1156 <main+0x16>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11ed <main+0xad>
cmpl   $0xa,-0x10(%rbp)
jle    11fe <main+0xbe>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
jmp    1156 <main+0x16>
jmp    1203 <main+0xc3>
cmpl   $0x2,-0x10(%rbp)
jle    1225 <main+0xe5>
cmpl   $0x7,-0x10(%rbp)
jge    1225 <main+0xe5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    123d <main+0xfd>
cmpl   $0xa,-0x10(%rbp)
jne    1238 <main+0xf8>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    123d <main+0xfd>
mov    -0xc(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
jmp    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    0xf1d(%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 = [10 x i8] c"Naaaahhhh\00"
@.str.3 = [10 x i8] c"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 = %47, %28, %19, %0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 88
br i1 %9, label %10, label %50
10: ; preds = %5
%11 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %4
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %20 [
i32 75, label %17
i32 81, label %17
i32 74, label %17
i32 65, label %18
i32 88, label %19
]
17: ; preds = %10, %10, %10
store i32 10, i32* %4
br label %31
18: ; preds = %10
store i32 11, i32* %4
br label %31
19: ; preds = %10
br label %5
20: ; preds = %10
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 10
br i1 %27, label %28, label %30
28: ; preds = %25, %20
%29 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %5
30: ; preds = %25
br label %31
31: ; preds = %30, %18, %17
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 2
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i32, i32* %4
%36 = icmp slt i32 %35, 7
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %47
40: ; preds = %34, %31
%41 = load i32, i32* %4
%42 = icmp eq i32 %41, 10
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %3
%45 = add nsw i32 %44, -1
store i32 %45, i32* %3
br label %46
46: ; preds = %43, %40
br label %47
47: ; preds = %46, %37
%48 = load i32, i32* %3
%49 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %48)
br label %5
50: ; preds = %5
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 = [10 x i8] c"Naaaahhhh\00"
@.str.3 = [10 x i8] c"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 = %0, %30
%4 = phi i32 [ %32, %30 ], [ 0, %0 ]
%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 ([10 x i8], [10 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 ([10 x i8], [10 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
}