#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(void) {
  char card_name[3];
  puts("Enter the card name: ");
  scanf("%2s", card_name);
  int val = 0;
  if (card_name[0] == 'K') {
    val = 10;
  } else if (card_name[0] == 'Q') {
    val = 10;
  } else if (card_name[0] == 'J') {
    val = 10;
  } else if (card_name[0] == 'A') {
    val = 11;
  } else {
    val = atoi(card_name);
  }
  if ((val > 2) && (val < 7)) {
    puts("Count has gone up");
  } else if (val == 10) {
    puts("Count has gone down");
  }
  printf("The card value is: %i\n", val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    -0x7(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x4b,%eax
jne    118b <main+0x4b>
movl   $0xa,-0xc(%rbp)
jmp    11f1 <main+0xb1>
movsbl -0x7(%rbp),%eax
cmp    $0x51,%eax
jne    11a4 <main+0x64>
movl   $0xa,-0xc(%rbp)
jmp    11ec <main+0xac>
movsbl -0x7(%rbp),%eax
cmp    $0x4a,%eax
jne    11bd <main+0x7d>
movl   $0xa,-0xc(%rbp)
jmp    11e7 <main+0xa7>
movsbl -0x7(%rbp),%eax
cmp    $0x41,%eax
jne    11d6 <main+0x96>
movl   $0xb,-0xc(%rbp)
jmp    11e2 <main+0xa2>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
jmp    11e7 <main+0xa7>
jmp    11ec <main+0xac>
jmp    11f1 <main+0xb1>
cmpl   $0x2,-0xc(%rbp)
jle    1216 <main+0xd6>
cmpl   $0x7,-0xc(%rbp)
jge    1216 <main+0xd6>
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
jmp    1231 <main+0xf1>
cmpl   $0xa,-0xc(%rbp)
jne    122c <main+0xec>
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
jmp    1231 <main+0xf1>
mov    -0xc(%rbp),%esi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
lea    0x5(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xa,%ebp
lea    0xec0(%rip),%rbx
mov    0x5(%rsp),%al
lea    -0x4a(%rax),%ecx
cmp    $0x2,%cl
jb     11ab <main+0x6b>
cmp    $0x41,%al
je     119f <main+0x5f>
cmp    $0x51,%al
je     11ab <main+0x6b>
lea    0x5(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%esi
lea    -0x3(%rsi),%eax
cmp    $0x4,%eax
jae    11a6 <main+0x66>
lea    0xe7f(%rip),%rbx
mov    %esi,%ebp
jmp    11ab <main+0x6b>
mov    $0xb,%esi
jmp    11b5 <main+0x75>
cmp    $0xa,%esi
jne    11b5 <main+0x75>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %ebp,%esi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 = [18 x i8] c"Count has gone up\00"
@.str.3 = [20 x i8] c"Count has gone down\00"
@.str.4 = [23 x i8] c"The card value is: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
store i32 0, i32* %3
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 75
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 10, i32* %3
br label %36
12: ; preds = %0
%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
%16 = icmp eq i32 %15, 81
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 10, i32* %3
br label %35
18: ; preds = %12
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 74
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 10, i32* %3
br label %34
24: ; preds = %18
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 65
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 11, i32* %3
br label %33
30: ; preds = %24
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %3
br label %33
33: ; preds = %30, %29
br label %34
34: ; preds = %33, %23
br label %35
35: ; preds = %34, %17
br label %36
36: ; preds = %35, %11
%37 = load i32, i32* %3
%38 = icmp sgt i32 %37, 2
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i32, i32* %3
%41 = icmp slt i32 %40, 7
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %50
44: ; preds = %39, %36
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
br label %50
50: ; preds = %49, %42
%51 = load i32, i32* %3
%52 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 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 = [18 x i8] c"Count has gone up\00"
@.str.3 = [20 x i8] c"Count has gone down\00"
@.str.4 = [23 x i8] c"The card value 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
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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
switch i8 %5, label %6 [
i8 75, label %12
i8 81, label %12
i8 74, label %12
i8 65, label %16
]
6: ; preds = %0
%7 = call i32 @atoi(i8* %2)
%8 = add i32 %7, -3
%9 = icmp ult i32 %8, 4
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = icmp eq i32 %7, 10
br i1 %11, label %12, label %16
12: ; preds = %10, %0, %0, %0, %6
%13 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %10 ]
%14 = phi i32 [ %7, %6 ], [ 10, %0 ], [ 10, %0 ], [ 10, %0 ], [ 10, %10 ]
%15 = call i32 @puts(i8* dereferenceable(1) %13)
br label %16
16: ; preds = %12, %0, %10
%17 = phi i32 [ %7, %10 ], [ 11, %0 ], [ %14, %12 ]
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %17)
ret i32 0
}