#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void *get_player_move() {
  int *move = (int *)malloc(sizeof(int));
  scanf("%d", move);
  while (*move < 1 || *move > 3) {
    printf("Improper move, please try again: ");
    scanf("%d", move);
  }
  return (void *)move;
}


x86 assembly (clang, -O0):
<get_player_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%rcx
mov    $0x1,%al
cmpl   $0x1,(%rcx)
mov    %al,-0x9(%rbp)
jl     1175 <get_player_move+0x45>
mov    -0x8(%rbp),%rax
cmpl   $0x3,(%rax)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1185 <get_player_move+0x55>
jmp    11a6 <get_player_move+0x76>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1050 <scanf@plt>
jmp    1156 <get_player_move+0x26>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_player_move>:
push   %r15
push   %r14
push   %rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb7(%rip),%rdi
mov    %rax,%rsi
call   1050 <scanf@plt>
mov    (%rbx),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffffc,%eax
ja     118d <get_player_move+0x5d>
lea    0xea1(%rip),%r14
lea    0xe97(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    (%rbx),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffffd,%eax
jb     1170 <get_player_move+0x40>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [34 x i8] c"Improper move, please try again: \00"
define i8* @get_player_move() {
%1 = alloca i32*
%2 = call i64 @malloc(i32 4)
%3 = inttoptr i64 %2 to i32*
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %6
6: ; preds = %16, %0
%7 = load i32*, i32** %1
%8 = load i32, i32* %7
%9 = icmp slt i32 %8, 1
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i32*, i32** %1
%12 = load i32, i32* %11
%13 = icmp sgt i32 %12, 3
br label %14
14: ; preds = %10, %6
%15 = phi i1 [ true, %6 ], [ %13, %10 ]
br i1 %15, label %16, label %20
16: ; preds = %14
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32*, i32** %1
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
br label %6
20: ; preds = %14
%21 = load i32*, i32** %1
%22 = bitcast i32* %21 to i8*
ret i8* %22
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [34 x i8] c"Improper move, please try again: \00"
define i8* @get_player_move() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%4 = load i32, i32* %2
%5 = add i32 %4, -4
%6 = icmp ult i32 %5, -3
br i1 %6, label %7, label %13
7: ; preds = %0, %7
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = add i32 %10, -4
%12 = icmp ult i32 %11, -3
br i1 %12, label %7, label %13
13: ; preds = %7, %0
%14 = inttoptr i64 %1 to i8*
ret i8* %14
}