#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;
  do {
    puts("Input Card Name: ");
    scanf("%s", card_name);
    int val = 0;
    switch (card_name[0]) {
    case 'K':
    case 'k':
    case 'Q':
    case 'q':
    case 'J':
    case 'j':
      val = 10;
      break;
    case 'A':
    case 'a':
      val = 11;
      break;
    case 'X':
    case 'x':
      continue;
    default:
      val = atoi(card_name);
      if (val < 1 || val > 10) {
        puts("I can not understand this value!");
        continue;
      }
    }
    if (val > 2 && val < 7) {
      count++;
    } else if (val == 10) {
      count--;
    }
    printf("Now count is : %d\n", count);
  } while (card_name[0] != 'X' && 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    0xea3(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movsbl -0x7(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x41,%eax
je     1217 <main+0xd7>
jmp    118e <main+0x4e>
mov    -0x14(%rbp),%eax
add    $0xffffffb6,%eax
sub    $0x2,%eax
jb     120b <main+0xcb>
jmp    11a2 <main+0x62>
mov    -0x14(%rbp),%eax
sub    $0x51,%eax
je     120b <main+0xcb>
jmp    11b3 <main+0x73>
mov    -0x14(%rbp),%eax
sub    $0x58,%eax
je     1223 <main+0xe3>
jmp    11c4 <main+0x84>
mov    -0x14(%rbp),%eax
sub    $0x61,%eax
je     1217 <main+0xd7>
jmp    11d5 <main+0x95>
mov    -0x14(%rbp),%eax
add    $0xffffff96,%eax
sub    $0x2,%eax
jb     120b <main+0xcb>
jmp    11e9 <main+0xa9>
mov    -0x14(%rbp),%eax
sub    $0x71,%eax
je     120b <main+0xcb>
jmp    11fa <main+0xba>
mov    -0x14(%rbp),%eax
sub    $0x78,%eax
je     1223 <main+0xe3>
jmp    1228 <main+0xe8>
movl   $0xa,-0x10(%rbp)
jmp    125e <main+0x11e>
movl   $0xb,-0x10(%rbp)
jmp    125e <main+0x11e>
jmp    12a7 <main+0x167>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     1248 <main+0x108>
cmpl   $0xa,-0x10(%rbp)
jle    1259 <main+0x119>
lea    0xdc6(%rip),%rdi
call   1030 <puts@plt>
jmp    12a7 <main+0x167>
jmp    125e <main+0x11e>
cmpl   $0x2,-0x10(%rbp)
jle    1280 <main+0x140>
cmpl   $0x7,-0x10(%rbp)
jge    1280 <main+0x140>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1298 <main+0x158>
cmpl   $0xa,-0x10(%rbp)
jne    1293 <main+0x153>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1298 <main+0x158>
mov    -0xc(%rbp),%esi
lea    0xd94(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x7(%rbp),%ecx
xor    %eax,%eax
cmp    $0x58,%ecx
mov    %al,-0x15(%rbp)
je     12c6 <main+0x186>
movsbl -0x7(%rbp),%eax
cmp    $0x78,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
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    0xeac(%rip),%r14
lea    0xeb7(%rip),%r15
lea    0x5(%rsp),%r12
lea    0xecf(%rip),%rbp
movabs $0x1060000010600,%r13
jmp    119c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
movzbl 0x5(%rsp),%eax
and    $0xdf,%al
cmp    $0x58,%al
je     121f <main+0xdf>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movsbl 0x5(%rsp),%eax
add    $0xffffffbf,%eax
cmp    $0x37,%eax
ja     11e2 <main+0xa2>
bt     %rax,%r13
jb     1180 <main+0x40>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     1183 <main+0x43>
movabs $0x80000000800000,%rcx
bt     %rax,%rcx
jb     118d <main+0x4d>
mov    %r12,%rdi
call   1060 <atoi@plt>
lea    -0xb(%rax),%ecx
cmp    $0xfffffff5,%ecx
ja     1200 <main+0xc0>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
jmp    118d <main+0x4d>
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    1183 <main+0x43>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Input Card Name: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [33 x i8] c"I can not understand this value!\00"
@.str.3 = [19 x i8] c"Now count is : %d\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 = %55, %0
%6 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 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 ([3 x i8], [3 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 107, label %12
i32 81, label %12
i32 113, label %12
i32 74, label %12
i32 106, label %12
i32 65, label %13
i32 97, label %13
i32 88, label %14
i32 120, label %14
]
12: ; preds = %5, %5, %5, %5, %5, %5
store i32 10, i32* %4
br label %26
13: ; preds = %5, %5
store i32 11, i32* %4
br label %26
14: ; preds = %5, %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 ([33 x i8], [33 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 %50, label %55
50: ; preds = %45
%51 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 120
br label %55
55: ; preds = %50, %45
%56 = phi i1 [ false, %45 ], [ %54, %50 ]
br i1 %56, label %5, label %57
57: ; preds = %55
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Input Card Name: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [33 x i8] c"I can not understand this value!\00"
@.str.3 = [19 x i8] c"Now count is : %d\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 = %27, %0
%4 = phi i32 [ 0, %0 ], [ %28, %27 ]
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 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 107, label %15
i32 81, label %15
i32 113, label %15
i32 74, label %15
i32 106, label %15
i32 65, label %24
i32 97, label %24
i32 88, label %27
i32 120, label %27
]
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 ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %27
15: ; preds = %3, %3, %3, %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, %3
%25 = phi i32 [ %4, %3 ], [ %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 = %3, %3, %24, %13
%28 = phi i32 [ %4, %13 ], [ %25, %24 ], [ %4, %3 ], [ %4, %3 ]
%29 = load i8, i8* %2
%30 = and i8 %29, -33
%31 = icmp eq i8 %30, 88
br i1 %31, label %32, label %3
32: ; preds = %27
ret i32 0
}