#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];
  puts("Enter the card_name: ");
  scanf("%2s", card_name);
  int val = 0;
  switch (card_name[0]) {
  case 'J':
  case 'Q':
  case 'K':
    val = 10;
    break;
  case 'A':
    val = 11;
    break;
  default:
    val = atoi(card_name);
  }
  printf("The card value is %d\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    0xeb4(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movsbl -0x7(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x41,%eax
je     11b8 <main+0x78>
jmp    1187 <main+0x47>
mov    -0x10(%rbp),%eax
add    $0xffffffb6,%eax
sub    $0x2,%eax
jb     11ac <main+0x6c>
jmp    119b <main+0x5b>
mov    -0x10(%rbp),%eax
sub    $0x51,%eax
jne    11c4 <main+0x84>
jmp    11ac <main+0x6c>
movl   $0xa,-0xc(%rbp)
jmp    11d0 <main+0x90>
movl   $0xb,-0xc(%rbp)
jmp    11d0 <main+0x90>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xec2(%rip),%rdi
lea    0x5(%rsp),%rsi
call   1050 <scanf@plt>
movsbl 0x5(%rsp),%eax
mov    $0xa,%esi
lea    -0x4a(%rax),%ecx
cmp    $0x2,%ecx
jb     118d <main+0x4d>
cmp    $0x51,%eax
je     118d <main+0x4d>
cmp    $0x41,%eax
jne    1181 <main+0x41>
mov    $0xb,%esi
jmp    118d <main+0x4d>
lea    0x5(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%esi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter the card_name: \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [22 x i8] c"The card value is %d\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
switch i32 %9, label %12 [
i32 74, label %10
i32 81, label %10
i32 75, label %10
i32 65, label %11
]
10: ; preds = %0, %0, %0
store i32 10, i32* %3
br label %15
11: ; preds = %0
store i32 11, i32* %3
br label %15
12: ; preds = %0
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %3
br label %15
15: ; preds = %12, %11, %10
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %16)
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 = [22 x i8] c"The card value is %d\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
%6 = sext i8 %5 to i32
switch i32 %6, label %8 [
i32 74, label %10
i32 81, label %10
i32 75, label %10
i32 65, label %7
]
7: ; preds = %0
br label %10
8: ; preds = %0
%9 = call i32 @atoi(i8* %2)
br label %10
10: ; preds = %0, %0, %0, %8, %7
%11 = phi i32 [ %9, %8 ], [ 11, %7 ], [ 10, %0 ], [ 10, %0 ], [ 10, %0 ]
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %11)
ret i32 0
}