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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x58,-0x5(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
lea    -0xf(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1050 <scanf@plt>
movsbl -0xf(%rbp),%eax
cmp    $0x58,%eax
jne    118f <main+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    120e <main+0xce>
lea    -0xf(%rbp),%rdi
call   1060 <parseCard@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11aa <main+0x6a>
jmp    11fa <main+0xba>
cmpl   $0x3,-0xc(%rbp)
jl     11cc <main+0x8c>
cmpl   $0x6,-0xc(%rbp)
jg     11cc <main+0x8c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <main+0xa4>
cmpl   $0xa,-0xc(%rbp)
jne    11df <main+0x9f>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <main+0xa4>
jmp    11e9 <main+0xa9>
mov    -0x14(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0xf(%rbp),%eax
cmp    $0x58,%eax
jne    115a <main+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
lea    0xeae(%rip),%r14
lea    0xebd(%rip),%r15
lea    0x5(%rsp),%rbx
mov    $0x1,%r13d
lea    0xeaf(%rip),%r12
xor    %ebp,%ebp
jmp    1177 <main+0x37>
nop
cmpb   $0x58,0x5(%rsp)
je     11c2 <main+0x82>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpb   $0x58,0x5(%rsp)
je     11c2 <main+0x82>
mov    %rbx,%rdi
call   1060 <parseCard@plt>
cmp    $0xffffffff,%eax
je     1170 <main+0x30>
lea    -0x3(%rax),%ecx
xor    %edx,%edx
cmp    $0xa,%eax
sete   %dl
neg    %edx
cmp    $0x4,%ecx
cmovb  %r13d,%edx
add    %edx,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x30>
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 = [19 x i8] c"Current count: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca [3 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i8 88, i8* %2
store i32 0, i32* %5
br label %6
6: ; preds = %41, %0
%7 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 88
br i1 %13, label %14, label %15
14: ; preds = %6
store i32 0, i32* %1
br label %47
15: ; preds = %6
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%17 = call i32 @parseCard(i8* %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %15
br label %41
21: ; preds = %15
%22 = load i32, i32* %3
%23 = icmp sge i32 %22, 3
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp sle i32 %25, 6
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %37
30: ; preds = %24, %21
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %5
%35 = add nsw i32 %34, -1
store i32 %35, i32* %5
br label %36
36: ; preds = %33, %30
br label %37
37: ; preds = %36, %27
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38, %20
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 88
br i1 %45, label %6, label %46
46: ; preds = %41
store i32 0, i32* %1
br label %47
47: ; preds = %46, %14
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter the card name: \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [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 = %20, %0
%4 = phi i32 [ 0, %0 ], [ %21, %20 ]
%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 = icmp eq i8 %7, 88
br i1 %8, label %24, label %9
9: ; preds = %3
%10 = call i32 @parseCard(i8* %2)
%11 = icmp eq i32 %10, -1
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = add i32 %10, -3
%14 = icmp ult i32 %13, 4
%15 = icmp eq i32 %10, 10
%16 = sext i1 %15 to i32
%17 = select i1 %14, i32 1, i32 %16
%18 = add nsw i32 %17, %4
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %9, %12
%21 = phi i32 [ %4, %9 ], [ %18, %12 ]
%22 = load i8, i8* %2
%23 = icmp eq i8 %22, 88
br i1 %23, label %24, label %3
24: ; preds = %20, %3
ret i32 0
}