#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*/ check_val(int *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int assign_val() {
  char card_name[3];
  int count = 0;
  while (card_name[0] != 'X') {
    puts("Enter the card_name: ");
    scanf("%2s", card_name);
    int val;
    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("Naaaahhhh");
        continue;
      }
    }
    check_val(&val);
  }
}


x86 assembly (clang, -O0):
<assign_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
je     120a <assign_val+0xca>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xf07(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movsbl -0x7(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x17,%eax
ja     11c6 <assign_val+0x86>
mov    -0x18(%rbp),%rax
lea    0xe60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x10(%rbp)
jmp    11fc <assign_val+0xbc>
movl   $0xb,-0x10(%rbp)
jmp    11fc <assign_val+0xbc>
jmp    114f <assign_val+0xf>
lea    -0x7(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11e6 <assign_val+0xa6>
cmpl   $0xa,-0x10(%rbp)
jle    11f7 <assign_val+0xb7>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
jmp    114f <assign_val+0xf>
jmp    11fc <assign_val+0xbc>
lea    -0x10(%rbp),%rdi
call   1060 <check_val@plt>
jmp    114f <assign_val+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assign_val>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf0e(%rip),%r14
lea    0xf1d(%rip),%r15
lea    0x5(%rsp),%rbx
lea    0xf15(%rip),%r12
mov    %rsp,%r13
lea    0xe91(%rip),%rbp
jmp    1198 <assign_val+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0xa,(%rsp)
mov    %r13,%rdi
call   1060 <check_val@plt>
movzbl 0x5(%rsp),%eax
cmp    $0x58,%al
je     11ef <assign_val+0xaf>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movl   $0x0,(%rsp)
movsbl 0x5(%rsp),%eax
lea    -0x41(%rax),%ecx
cmp    $0x17,%ecx
ja     11d2 <assign_val+0x92>
movslq 0x0(%rbp,%rcx,4),%rcx
add    %rbp,%rcx
jmp    *%rcx
movl   $0xb,(%rsp)
jmp    1187 <assign_val+0x47>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,(%rsp)
add    $0xfffffff5,%eax
cmp    $0xfffffff5,%eax
ja     1187 <assign_val+0x47>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    118f <assign_val+0x4f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 = [10 x i8] c"Naaaahhhh\00"
define i32 @assign_val() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %3
br label %5
5: ; preds = %31, %28, %19, %0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 88
br i1 %9, label %10, label %33
10: ; preds = %5
%11 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %4
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %20 [
i32 75, label %17
i32 81, label %17
i32 74, label %17
i32 65, label %18
i32 88, label %19
]
17: ; preds = %10, %10, %10
store i32 10, i32* %4
br label %31
18: ; preds = %10
store i32 11, i32* %4
br label %31
19: ; preds = %10
br label %5
20: ; preds = %10
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 10
br i1 %27, label %28, label %30
28: ; preds = %25, %20
%29 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %5
30: ; preds = %25
br label %31
31: ; preds = %30, %18, %17
%32 = call i32 @check_val(i32* %4)
br label %5
33: ; preds = %5
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter the card_name: \00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [10 x i8] c"Naaaahhhh\00"
define i32 @assign_val() {
%1 = alloca [3 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %22
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
store i32 0, i32* %2
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
switch i32 %9, label %12 [
i32 75, label %10
i32 81, label %10
i32 74, label %10
i32 65, label %11
i32 88, label %22
]
10: ; preds = %5, %5, %5
store i32 10, i32* %2
br label %18
11: ; preds = %5
store i32 11, i32* %2
br label %18
12: ; preds = %5
%13 = call i32 @atoi(i8* %3)
store i32 %13, i32* %2
%14 = add i32 %13, -11
%15 = icmp ult i32 %14, -10
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %12, %11, %10
%19 = call i32 @check_val(i32* %2)
br label %20
20: ; preds = %16, %18
%21 = load i8, i8* %3
br label %22
22: ; preds = %20, %5
%23 = phi i8 [ %21, %20 ], [ %8, %5 ]
%24 = icmp eq i8 %23, 88
br i1 %24, label %25, label %5
25: ; preds = %22
ret i32 undef
}