#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int human_choice(int pile) {
  int input = 0;
  printf("enter a value between 1 & 3\n");
  scanf("%d", &input);
  while (getchar() != '\n' && getchar() != EOF) {
    ;
  }
  if ((input > 0 && input < 4) && input < pile) {
    return input;
  } else {
    printf("Must be between 1 and 3\n");
    return human_choice(pile);
  }
}


x86 assembly (clang, -O0):
<human_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     11a2 <human_choice+0x62>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
mov    0x2e51(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11b2 <human_choice+0x72>
jmp    11b7 <human_choice+0x77>
jmp    116e <human_choice+0x2e>
cmpl   $0x0,-0xc(%rbp)
jle    11e2 <human_choice+0xa2>
cmpl   $0x4,-0xc(%rbp)
jge    11e2 <human_choice+0xa2>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e2 <human_choice+0xa2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <human_choice+0xb9>
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <human_choice@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<human_choice>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e77(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1196 <human_choice+0x56>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%al
jne    1180 <human_choice+0x40>
mov    0x4(%rsp),%eax
cmp    %ebp,%eax
jge    11a6 <human_choice+0x66>
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
jb     11b9 <human_choice+0x79>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1050 <human_choice@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"enter a value between 1 & 3\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i8 0
@.str.2 = [25 x i8] c"Must be between 1 and 3\0A\00"
define i32 @human_choice(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %7
7: ; preds = %19, %1
%8 = call signext i8 (...) @getchar()
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = call signext i8 (...) @getchar()
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br label %17
17: ; preds = %11, %7
%18 = phi i1 [ false, %7 ], [ %16, %11 ]
br i1 %18, label %19, label %20
19: ; preds = %17
br label %7
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i32, i32* %4
store i32 %31, i32* %2
br label %36
32: ; preds = %26, %23, %20
%33 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* %3
%35 = call i32 @human_choice(i32 %34)
store i32 %35, i32* %2
br label %36
36: ; preds = %32, %30
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i8 0
@str = [28 x i8] c"enter a value between 1 & 3\00"
@str.3 = [24 x i8] c"Must be between 1 and 3\00"
define i32 @human_choice(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %9, %1
%7 = call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 10
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = call signext i8 (...) @getchar()
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %13, label %6
13: ; preds = %6, %9
%14 = load i32, i32* %2
%15 = add i32 %14, -1
%16 = icmp ult i32 %15, 3
%17 = icmp slt i32 %14, %0
%18 = and i1 %17, %16
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
%21 = call i32 @human_choice(i32 %0)
br label %22
22: ; preds = %13, %19
%23 = phi i32 [ %21, %19 ], [ %14, %13 ]
ret i32 %23
}