#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() {
  int count = 0;
  char card_name[3];
  while (card_name[0] != 'X') {
    puts("Enter the card_name: ");
    scanf("%2s", card_name);
    int 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)) {
        printf("Wrong value :%i\n", val);
        puts("It must be 1-7, J, Q, K or A");
        continue;
      }
    }
    if ((val > 2) && (val < 7))
      count++;
    else if (val == 10)
      count--;
  }
  printf("The card count is %i\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0xb(%rbp),%eax
cmp    $0x58,%eax
je     1251 <main+0x111>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xf00(%rip),%rdi
lea    -0xb(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movsbl -0xb(%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    1212 <main+0xd2>
movl   $0xb,-0x10(%rbp)
jmp    1212 <main+0xd2>
jmp    1156 <main+0x16>
lea    -0xb(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11ed <main+0xad>
cmpl   $0xa,-0x10(%rbp)
jle    120d <main+0xcd>
mov    -0x10(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
jmp    1156 <main+0x16>
jmp    1212 <main+0xd2>
cmpl   $0x2,-0x10(%rbp)
jle    1234 <main+0xf4>
cmpl   $0x7,-0x10(%rbp)
jge    1234 <main+0xf4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124c <main+0x10c>
cmpl   $0xa,-0x10(%rbp)
jne    1247 <main+0x107>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    124c <main+0x10c>
jmp    1156 <main+0x16>
mov    -0x8(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
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    0xebb(%rip),%r15
lea    0x5(%rsp),%r12
mov    $0x10600,%r13d
jmp    1179 <main+0x39>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
cmp    $0x58,%bpl
je     11f0 <main+0xb0>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movsbl 0x5(%rsp),%ebp
mov    %ebp,%eax
add    $0xffffffbf,%eax
cmp    $0x17,%eax
ja     11ab <main+0x6b>
bt     %eax,%r13d
jb     1170 <main+0x30>
mov    $0x800001,%ecx
bt     %eax,%ecx
jb     1173 <main+0x33>
mov    %r12,%rdi
call   1060 <atoi@plt>
lea    -0xb(%rax),%ecx
cmp    $0xfffffff5,%ecx
ja     11dc <main+0x9c>
lea    0xe58(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
movzbl 0x5(%rsp),%ebp
jmp    1173 <main+0x33>
lea    -0x3(%rax),%ecx
cmp    $0x3,%ecx
ja     11e9 <main+0xa9>
add    $0x1,%ebx
jmp    1173 <main+0x33>
cmp    $0xa,%eax
je     1170 <main+0x30>
jmp    1173 <main+0x33>
lea    0xe51(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
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 = [17 x i8] c"Wrong value :%i\0A\00"
@.str.3 = [29 x i8] c"It must be 1-7, J, Q, K or A\00"
@.str.4 = [22 x i8] c"The card count is %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %49, %28, %19, %0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, 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]* %3, 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]* %3, 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 %33
18: ; preds = %10
store i32 11, i32* %4
br label %33
19: ; preds = %10
br label %5
20: ; preds = %10
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %3, 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 %32
28: ; preds = %25, %20
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %5
32: ; preds = %25
br label %33
33: ; preds = %32, %18, %17
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 2
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i32, i32* %4
%38 = icmp slt i32 %37, 7
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %49
42: ; preds = %36, %33
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 10
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %2
%47 = add nsw i32 %46, -1
store i32 %47, i32* %2
br label %48
48: ; preds = %45, %42
br label %49
49: ; preds = %48, %39
br label %5
50: ; preds = %5
%51 = load i32, i32* %2
%52 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %51)
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 = [17 x i8] c"Wrong value :%i\0A\00"
@.str.3 = [29 x i8] c"It must be 1-7, J, Q, K or A\00"
@.str.4 = [22 x i8] c"The card count is %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, %26
%4 = phi i32 [ %28, %26 ], [ 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 %24
i32 81, label %24
i32 74, label %24
i32 65, label %26
i32 88, label %26
]
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 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%16 = load i8, i8* %2
br label %26
17: ; preds = %9
%18 = add nsw i32 %10, -3
%19 = icmp ult i32 %18, 4
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = add nsw i32 %4, 1
br label %26
22: ; preds = %17
%23 = icmp eq i32 %10, 10
br i1 %23, label %24, label %26
24: ; preds = %3, %3, %3, %22
%25 = add nsw i32 %4, -1
br label %26
26: ; preds = %3, %24, %22, %20, %3, %13
%27 = phi i8 [ %16, %13 ], [ %7, %3 ], [ %7, %20 ], [ %7, %24 ], [ %7, %22 ], [ %7, %3 ]
%28 = phi i32 [ %4, %13 ], [ %4, %3 ], [ %21, %20 ], [ %25, %24 ], [ %4, %22 ], [ %4, %3 ]
%29 = icmp eq i8 %27, 88
br i1 %29, label %30, label %3
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %28)
ret i32 0
}