#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char card_name[3];
  puts("Enter the card_name: ");
  scanf("%2s", card_name);
  puts(card_name);
  int val = 0;
  switch (card_name[0]) {
  case 'K':
  case 'Q':
  case 'J':
    val = 10;
    break;
  case 'A':
    val = 11;
    break;
  default:
    val = atoi(card_name);
  }
  if (3 <= val && val <= 6) {
    puts("Count has gone up");
  } else if (val == 10) {
    puts("Count has gone down");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xec4(%rip),%rdi
lea    -0x7(%rbp),%rsi
mov    %rsi,-0x18(%rbp)
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <puts@plt>
movl   $0x0,-0xc(%rbp)
movsbl -0x7(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x41,%eax
je     11b5 <main+0x85>
jmp    1184 <main+0x54>
mov    -0x10(%rbp),%eax
add    $0xffffffb6,%eax
sub    $0x2,%eax
jb     11a9 <main+0x79>
jmp    1198 <main+0x68>
mov    -0x10(%rbp),%eax
sub    $0x51,%eax
jne    11c1 <main+0x91>
jmp    11a9 <main+0x79>
movl   $0xa,-0xc(%rbp)
jmp    11cd <main+0x9d>
movl   $0xb,-0xc(%rbp)
jmp    11cd <main+0x9d>
lea    -0x7(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    $0x3,%eax
cmp    -0xc(%rbp),%eax
jg     11f6 <main+0xc6>
cmpl   $0x6,-0xc(%rbp)
jg     11f6 <main+0xc6>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
jmp    1211 <main+0xe1>
cmpl   $0xa,-0xc(%rbp)
jne    120c <main+0xdc>
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
jmp    1211 <main+0xe1>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rdi
lea    0xd(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
movsbl 0xd(%rsp),%eax
lea    0xec3(%rip),%rbx
lea    -0x4a(%rax),%ecx
cmp    $0x2,%ecx
jb     119b <main+0x6b>
cmp    $0x41,%eax
je     11a3 <main+0x73>
cmp    $0x51,%eax
je     119b <main+0x6b>
lea    0xd(%rsp),%rdi
call   1050 <atoi@plt>
lea    -0x3(%rax),%ecx
cmp    $0x4,%ecx
jae    1196 <main+0x66>
lea    0xe86(%rip),%rbx
jmp    119b <main+0x6b>
cmp    $0xa,%eax
jne    11a3 <main+0x73>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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"
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)
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%8 = call i32 @puts(i8* %7)
store i32 0, i32* %3
%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
switch i32 %11, label %14 [
i32 75, label %12
i32 81, label %12
i32 74, label %12
i32 65, label %13
]
12: ; preds = %0, %0, %0
store i32 10, i32* %3
br label %17
13: ; preds = %0
store i32 11, i32* %3
br label %17
14: ; preds = %0
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %13, %12
%18 = load i32, i32* %3
%19 = icmp sle i32 3, %18
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp sle i32 %21, 6
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %31
25: ; preds = %20, %17
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
br label %31
31: ; preds = %30, %23
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"
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 = call i32 @puts(i8* %2)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
switch i32 %7, label %8 [
i32 75, label %14
i32 81, label %14
i32 74, label %14
i32 65, label %17
]
8: ; preds = %0
%9 = call i32 @atoi(i8* %2)
%10 = add i32 %9, -3
%11 = icmp ult i32 %10, 4
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = icmp eq i32 %9, 10
br i1 %13, label %14, label %17
14: ; preds = %12, %0, %0, %0, %8
%15 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %8 ], [ 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), %12 ]
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %14, %0, %12
ret i32 0
}