#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int askForCard(char *question) {
  printf("%s\n> ", question);
  char choice[80];
  scanf("%s", choice);
  while (1) {
    if ((choice[0] >= '2') && (choice[0] <= '9')) {
      return choice[0] - '0' - 2;
    }
    if ((choice[0] == '1') && (choice[1] == '0')) {
      return 8;
    }
    if ((choice[0] == 'j') || (choice[0] == 'J')) {
      if ((choice[1] == 'o') || (choice[1] == 'O')) {
        return 13;
      }
      if ((choice[1] == 'a') || (choice[1] == 'A')) {
        return 9;
      }
    }
    if ((choice[0] == 'q') || (choice[0] == 'Q')) {
      return 10;
    }
    if ((choice[0] == 'k') || (choice[0] == 'K')) {
      return 11;
    }
    if ((choice[0] == 'a') || (choice[0] == 'A')) {
      return 12;
    }
    printf("Invalid card value, please enter a card value (Ace, 2-10, Jack, "
           "Queen, King, Joker).\n> ");
    scanf("%s", choice);
  }
}


x86 assembly (clang, -O0):
<askForCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1040 <scanf@plt>
movsbl -0x60(%rbp),%eax
cmp    $0x32,%eax
jl     117a <askForCard+0x5a>
movsbl -0x60(%rbp),%eax
cmp    $0x39,%eax
jg     117a <askForCard+0x5a>
movsbl -0x60(%rbp),%eax
sub    $0x30,%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
movsbl -0x60(%rbp),%eax
cmp    $0x31,%eax
jne    11a0 <askForCard+0x80>
movsbl -0x5f(%rbp),%eax
cmp    $0x30,%eax
jne    11a0 <askForCard+0x80>
movl   $0x8,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
movsbl -0x60(%rbp),%eax
cmp    $0x6a,%eax
je     11ba <askForCard+0x9a>
movsbl -0x60(%rbp),%eax
cmp    $0x4a,%eax
jne    120b <askForCard+0xeb>
movsbl -0x5f(%rbp),%eax
cmp    $0x6f,%eax
je     11d4 <askForCard+0xb4>
movsbl -0x5f(%rbp),%eax
cmp    $0x4f,%eax
jne    11e0 <askForCard+0xc0>
movl   $0xd,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
movsbl -0x5f(%rbp),%eax
cmp    $0x61,%eax
je     11fa <askForCard+0xda>
movsbl -0x5f(%rbp),%eax
cmp    $0x41,%eax
jne    1206 <askForCard+0xe6>
movl   $0x9,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
jmp    120b <askForCard+0xeb>
movsbl -0x60(%rbp),%eax
cmp    $0x71,%eax
je     1225 <askForCard+0x105>
movsbl -0x60(%rbp),%eax
cmp    $0x51,%eax
jne    1231 <askForCard+0x111>
movl   $0xa,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
movsbl -0x60(%rbp),%eax
cmp    $0x6b,%eax
je     124b <askForCard+0x12b>
movsbl -0x60(%rbp),%eax
cmp    $0x4b,%eax
jne    1257 <askForCard+0x137>
movl   $0xb,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
movsbl -0x60(%rbp),%eax
cmp    $0x61,%eax
je     1271 <askForCard+0x151>
movsbl -0x60(%rbp),%eax
cmp    $0x41,%eax
jne    127d <askForCard+0x15d>
movl   $0xc,-0x4(%rbp)
jmp    12a0 <askForCard+0x180>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xd70(%rip),%rdi
call   1040 <scanf@plt>
jmp    114e <askForCard+0x2e>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askForCard>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rsi
lea    0xf0f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%cl
lea    -0x32(%rcx),%eax
cmp    $0x8,%al
jae    1167 <askForCard+0x47>
movzbl %cl,%eax
add    $0xffffffce,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xedf(%rip),%r14
lea    0xed5(%rip),%r15
mov    %rsp,%r12
lea    0xe81(%rip),%rbx
jmp    11b0 <askForCard+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
movzbl (%rsp),%ecx
lea    -0x32(%rcx),%eax
cmp    $0x8,%al
jb     1155 <askForCard+0x35>
movzbl 0x1(%rsp),%edx
cmp    $0x31,%cl
jne    11bf <askForCard+0x9f>
cmp    $0x30,%dl
je     11f7 <askForCard+0xd7>
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x10,%cl
ja     1190 <askForCard+0x70>
mov    $0xb,%esi
mov    $0xa,%eax
movzbl %cl,%ecx
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
and    $0xdf,%dl
cmp    $0x41,%dl
je     120b <askForCard+0xeb>
cmp    $0x4f,%dl
jne    1190 <askForCard+0x70>
mov    $0xd,%eax
jmp    115b <askForCard+0x3b>
mov    $0x8,%eax
jmp    115b <askForCard+0x3b>
mov    $0xc,%eax
jmp    115b <askForCard+0x3b>
mov    $0x9,%esi
mov    %esi,%eax
jmp    115b <askForCard+0x3b>

LLVM IR (-O0):
@.str = [6 x i8] c"%s\0A> \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [88 x i8] c"Invalid card value, please enter a card value (Ace, 2-10, Jack, Queen, King, Joker).\0A> \00"
define i32 @askForCard(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [80 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %1, %102
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 50
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sle i32 %17, 57
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 48
%24 = sub nsw i32 %23, 2
store i32 %24, i32* %2
br label %106
25: ; preds = %14, %9
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 49
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 48
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 8, i32* %2
br label %106
36: ; preds = %30, %25
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 106
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 74
br i1 %45, label %46, label %69
46: ; preds = %41, %36
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 1
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 111
br i1 %50, label %56, label %51
51: ; preds = %46
%52 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 1
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 79
br i1 %55, label %56, label %57
56: ; preds = %51, %46
store i32 13, i32* %2
br label %106
57: ; preds = %51
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 1
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 97
br i1 %61, label %67, label %62
62: ; preds = %57
%63 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 1
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 65
br i1 %66, label %67, label %68
67: ; preds = %62, %57
store i32 9, i32* %2
br label %106
68: ; preds = %62
br label %69
69: ; preds = %68, %41
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 113
br i1 %73, label %79, label %74
74: ; preds = %69
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 81
br i1 %78, label %79, label %80
79: ; preds = %74, %69
store i32 10, i32* %2
br label %106
80: ; preds = %74
%81 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 107
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 75
br i1 %89, label %90, label %91
90: ; preds = %85, %80
store i32 11, i32* %2
br label %106
91: ; preds = %85
%92 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 97
br i1 %95, label %101, label %96
96: ; preds = %91
%97 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp eq i32 %99, 65
br i1 %100, label %101, label %102
101: ; preds = %96, %91
store i32 12, i32* %2
br label %106
102: ; preds = %96
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%105 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %104)
br label %9
106: ; preds = %101, %90, %79, %67, %56, %35, %19
%107 = load i32, i32* %2
ret i32 %107
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s\0A> \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [88 x i8] c"Invalid card value, please enter a card value (Ace, 2-10, Jack, Queen, King, Joker).\0A> \00"
define i32 @askForCard(i8* %0) {
%2 = alloca [80 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = load i8, i8* %4
%7 = add i8 %6, -50
%8 = icmp ult i8 %7, 8
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 1
br label %15
11: ; preds = %25, %1
%12 = phi i8 [ %6, %1 ], [ %28, %25 ]
%13 = zext i8 %12 to i32
%14 = add nsw i32 %13, -50
br label %35
15: ; preds = %9, %25
%16 = phi i8 [ %6, %9 ], [ %28, %25 ]
%17 = icmp eq i8 %16, 49
%18 = load i8, i8* %10
%19 = icmp eq i8 %18, 48
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %31, label %21
21: ; preds = %15
%22 = and i8 %16, -33
switch i8 %22, label %25 [
i8 74, label %23
i8 81, label %31
i8 75, label %33
i8 65, label %35
]
23: ; preds = %21
%24 = and i8 %18, -33
switch i8 %24, label %25 [
i8 79, label %31
i8 65, label %33
]
25: ; preds = %21, %23
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%28 = load i8, i8* %4
%29 = add i8 %28, -50
%30 = icmp ult i8 %29, 8
br i1 %30, label %11, label %15
31: ; preds = %15, %23, %21
%32 = phi i32 [ 8, %15 ], [ 13, %23 ], [ 10, %21 ]
br label %35
33: ; preds = %23, %21
%34 = phi i32 [ 9, %23 ], [ 11, %21 ]
br label %35
35: ; preds = %21, %33, %31, %11
%36 = phi i32 [ %14, %11 ], [ %32, %31 ], [ %34, %33 ], [ 12, %21 ]
ret i32 %36
}