#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 scanf(char *, int *);
int get_human_response(int movec) {
  int response;
  printf("This is your turn. Enter number to place your piece.\n");
  while (1) {
    int ret = scanf("%d", &response);
    if (ret < 1) {
      printf("Invalid input. Try again.\n");
      continue;
    }
    if (response >= movec) {
      printf("Invalid choice. Try again.\n");
      continue;
    }
    break;
  }
  return response;
}


x86 assembly (clang, -O0):
<get_human_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1165 <get_human_response+0x45>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
jmp    1137 <get_human_response+0x17>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1182 <get_human_response+0x62>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
jmp    1137 <get_human_response+0x17>
jmp    1187 <get_human_response+0x67>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_human_response>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xf05(%rip),%r12
lea    0xee3(%rip),%r13
jmp    1165 <get_human_response+0x45>
nopw   0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    %r12,%rdi
test   %eax,%eax
jle    1160 <get_human_response+0x40>
mov    0xc(%rsp),%eax
mov    %r13,%rdi
cmp    %ebx,%eax
jge    1160 <get_human_response+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [54 x i8] c"This is your turn. Enter number to place your piece.\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Invalid input. Try again.\0A\00"
@.str.3 = [28 x i8] c"Invalid choice. Try again.\0A\00"
define i32 @get_human_response(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %1, %10, %16
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %6
12: ; preds = %6
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %6
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [53 x i8] c"This is your turn. Enter number to place your piece.\00"
@str.4 = [27 x i8] c"Invalid choice. Try again.\00"
@str.5 = [26 x i8] c"Invalid input. Try again.\00"
define i32 @get_human_response(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %11, %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = icmp slt i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, %0
br i1 %10, label %14, label %11
11: ; preds = %8, %5
%12 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0), %5 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0), %8 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
br label %5
14: ; preds = %8
ret i32 %9
}