#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;
  char str[] = "ABCDE";
  printf("%ld\n", sizeof str / sizeof str[0]);
  printf("%ld\n", sizeof card_name / sizeof card_name[0]);
  do {
    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)) {
        puts("I don't understand that value!");
        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)
mov    0xf04(%rip),%eax
mov    %eax,-0x12(%rbp)
mov    0xefe(%rip),%ax
mov    %ax,-0xe(%rbp)
lea    0xef5(%rip),%rdi
mov    $0x6,%esi
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xee2(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x18(%rbp)
movsbl -0x7(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x17,%eax
ja     11f6 <main+0xb6>
mov    -0x20(%rbp),%rax
lea    0xe30(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x18(%rbp)
jmp    122c <main+0xec>
movl   $0xb,-0x18(%rbp)
jmp    122c <main+0xec>
jmp    1275 <main+0x135>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jl     1216 <main+0xd6>
cmpl   $0xa,-0x18(%rbp)
jle    1227 <main+0xe7>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
jmp    1275 <main+0x135>
jmp    122c <main+0xec>
cmpl   $0x2,-0x18(%rbp)
jle    124e <main+0x10e>
cmpl   $0x7,-0x18(%rbp)
jge    124e <main+0x10e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1266 <main+0x126>
cmpl   $0xa,-0x18(%rbp)
jne    1261 <main+0x121>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1266 <main+0x126>
mov    -0xc(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
jne    118c <main+0x4c>
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
lea    0xf0e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
xor    %ebx,%ebx
lea    0xef0(%rip),%r14
lea    0xeff(%rip),%r15
lea    0x5(%rsp),%r12
lea    0xf16(%rip),%rbp
lea    0xe71(%rip),%r13
jmp    11b6 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
movzbl 0x5(%rsp),%eax
cmp    $0x58,%al
je     121a <main+0xda>
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     11e0 <main+0xa0>
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     11fe <main+0xbe>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
jmp    11ad <main+0x6d>
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    11a3 <main+0x63>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str = [6 x i8] c"ABCDE\00"
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [22 x i8] c"Enter the card_name: \00"
@.str.2 = [4 x i8] c"%2s\00"
@.str.3 = [31 x i8] c"I don't understand that value!\00"
@.str.4 = [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 [6 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%6 = bitcast [6 x i8]* %4 to i8*
%7 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 3)
br label %9
9: ; preds = %49, %0
%10 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
store i32 0, i32* %5
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %19 [
i32 75, label %16
i32 81, label %16
i32 74, label %16
i32 65, label %17
i32 88, label %18
]
16: ; preds = %9, %9, %9
store i32 10, i32* %5
br label %30
17: ; preds = %9
store i32 11, i32* %5
br label %30
18: ; preds = %9
br label %49
19: ; preds = %9
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 1
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 10
br i1 %26, label %27, label %29
27: ; preds = %24, %19
%28 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %49
29: ; preds = %24
br label %30
30: ; preds = %29, %17, %16
%31 = load i32, i32* %5
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 7
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %46
39: ; preds = %33, %30
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %3
%44 = add nsw i32 %43, -1
store i32 %44, i32* %3
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45, %36
%47 = load i32, i32* %3
%48 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %46, %27, %18
%50 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 88
br i1 %53, label %9, label %54
54: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [22 x i8] c"Enter the card_name: \00"
@.str.2 = [4 x i8] c"%2s\00"
@.str.3 = [31 x i8] c"I don't understand that value!\00"
@.str.4 = [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
%3 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 6)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 3)
br label %5
5: ; preds = %32, %0
%6 = phi i32 [ 0, %0 ], [ %34, %32 ]
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
switch i32 %10, label %11 [
i32 75, label %17
i32 81, label %17
i32 74, label %17
i32 65, label %26
i32 88, label %32
]
11: ; preds = %5
%12 = call i32 @atoi(i8* %2)
%13 = add i32 %12, -11
%14 = icmp ult i32 %13, -10
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %29
17: ; preds = %5, %5, %5
%18 = add nsw i32 %6, -1
br label %26
19: ; preds = %11
%20 = add nsw i32 %12, -3
%21 = icmp ult i32 %20, 4
%22 = icmp eq i32 %12, 10
%23 = sext i1 %22 to i32
%24 = select i1 %21, i32 1, i32 %23
%25 = add nsw i32 %24, %6
br label %26
26: ; preds = %19, %17, %5
%27 = phi i32 [ %6, %5 ], [ %18, %17 ], [ %25, %19 ]
%28 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %15, %26
%30 = phi i32 [ %27, %26 ], [ %6, %15 ]
%31 = load i8, i8* %2
br label %32
32: ; preds = %29, %5
%33 = phi i8 [ %31, %29 ], [ %9, %5 ]
%34 = phi i32 [ %30, %29 ], [ %6, %5 ]
%35 = icmp eq i8 %33, 88
br i1 %35, label %36, label %5
36: ; preds = %32
ret i32 0
}