#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 card_value(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char card_name[3];
  int val = 0;
  int count = 0;
  printf("Enter the card name : ");
  scanf("%2s", card_name);
  while (card_name[0] != 'X') {
    if (val = card_value(card_name)) {
      printf("The value of the card is : %i\n", val);
      if ((val > 2) && (val < 7)) {
        count += 1;
      } else if (val == 10) {
        count -= 1;
      }
      printf("count: %i\n", count);
    } else
      printf("Not a valid card name\n");
    printf("Enter the card name : ");
    scanf("%2s", card_name);
  }
  printf("Total count = %i\n", count);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x7(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1050 <scanf@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
je     122f <main+0xef>
lea    -0x7(%rbp),%rdi
call   1030 <card_value@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11fe <main+0xbe>
mov    -0xc(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x2,-0xc(%rbp)
jle    11d0 <main+0x90>
cmpl   $0x7,-0xc(%rbp)
jge    11d0 <main+0x90>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e8 <main+0xa8>
cmpl   $0xa,-0xc(%rbp)
jne    11e3 <main+0xa3>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e8 <main+0xa8>
mov    -0x10(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120c <main+0xcc>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x7(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1050 <scanf@plt>
jmp    117b <main+0x3b>
mov    -0x10(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0x5(%rsp),%rsi
call   1060 <scanf@plt>
cmpb   $0x58,0x5(%rsp)
jne    119a <main+0x4a>
lea    0xebb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0x5(%rsp),%r14
lea    0xe5a(%rip),%r12
lea    0xe6a(%rip),%r13
lea    0xe86(%rip),%r15
xor    %ebx,%ebx
jmp    11e8 <main+0x98>
nopl   0x0(%rax,%rax,1)
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
cmpb   $0x58,0x5(%rsp)
je     1183 <main+0x33>
mov    %r14,%rdi
call   1040 <card_value@plt>
test   %eax,%eax
je     11c0 <main+0x70>
mov    %eax,%ebp
lea    0xe1e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x3(%rbp),%eax
xor    %ecx,%ecx
cmp    $0xa,%ebp
sete   %cl
neg    %ecx
cmp    $0x4,%eax
mov    $0x1,%eax
cmovb  %eax,%ecx
add    %ecx,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cc <main+0x7c>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter the card name : \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [31 x i8] c"The value of the card is : %i\0A\00"
@.str.3 = [11 x i8] c"count: %i\0A\00"
@.str.4 = [23 x i8] c"Not a valid card name\0A\00"
@.str.5 = [18 x i8] c"Total 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
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %40, %0
%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
%12 = icmp ne i32 %11, 88
br i1 %12, label %13, label %44
13: ; preds = %8
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%15 = call i32 @card_value(i8* %14)
store i32 %15, i32* %3
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 2
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i32, i32* %3
%24 = icmp slt i32 %23, 7
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %35
28: ; preds = %22, %17
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %31, %28
br label %35
35: ; preds = %34, %25
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %40
38: ; preds = %13
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%43 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %8
44: ; preds = %8
%45 = load i32, i32* %4
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter the card name : \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [31 x i8] c"The value of the card is : %i\0A\00"
@.str.3 = [11 x i8] c"count: %i\0A\00"
@.str.5 = [18 x i8] c"Total count = %i\0A\00"
@str = [22 x i8] c"Not a valid card name\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 88
br i1 %6, label %28, label %7
7: ; preds = %0, %22
%8 = phi i32 [ %23, %22 ], [ 0, %0 ]
%9 = call i32 @card_value(i8* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%13 = add i32 %9, -3
%14 = icmp ult i32 %13, 4
%15 = icmp eq i32 %9, 10
%16 = sext i1 %15 to i32
%17 = select i1 %14, i32 1, i32 %16
%18 = add nsw i32 %17, %8
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %7
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %11
%23 = phi i32 [ %18, %11 ], [ %8, %20 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%26 = load i8, i8* %2
%27 = icmp eq i8 %26, 88
br i1 %27, label %28, label %7
28: ; preds = %22, %0
%29 = phi i32 [ 0, %0 ], [ %23, %22 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = call i32 @exit(i32 0)
unreachable
}