#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*/ displayboard(char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
char **human_move(char **board, char piece) {
  int x, y, valid;
  int move;
  valid = 0;
  do {
    printf("\nEnter your move (x y): ");
    scanf("%d", &move);
    x = (move - 1) / 3 + 1;
    y = (move - 1) % 3 + 1;
    if (x < 4 && x > 0 && y > 0 && y < 4)
      if (board[x - 1][y - 1] == '-')
        valid = 1;
    if (!valid) {
      printf("\nINVALID MOVE. TRY AGAIN.\n");
      displayboard(board);
    }
  } while (!valid);
  board[x - 1][y - 1] = piece;
  return board;
}


x86 assembly (clang, -O0):
<human_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11e8 <human_move+0xb8>
cmpl   $0x0,-0x10(%rbp)
jle    11e8 <human_move+0xb8>
cmpl   $0x0,-0x14(%rbp)
jle    11e8 <human_move+0xb8>
cmpl   $0x4,-0x14(%rbp)
jge    11e8 <human_move+0xb8>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    11e3 <human_move+0xb3>
movl   $0x1,-0x18(%rbp)
jmp    11e8 <human_move+0xb8>
cmpl   $0x0,-0x18(%rbp)
jne    1207 <human_move+0xd7>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <displayboard@plt>
jmp    120c <human_move+0xdc>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1149 <human_move+0x19>
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<human_move>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xea8(%rip),%r15
lea    0xeba(%rip),%r12
lea    0x4(%rsp),%rbp
lea    0xeb1(%rip),%r13
jmp    1180 <human_move+0x40>
nopl   (%rax)
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <displayboard@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
lea    -0x1(%rcx),%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
add    %edx,%eax
lea    (%rax,%rax,2),%edx
neg    %edx
lea    0x1(%rcx),%esi
cmp    $0xa,%esi
ja     1170 <human_move+0x30>
add    %edx,%ecx
add    $0xffffffff,%ecx
test   %ecx,%ecx
js     1170 <human_move+0x30>
cltq
mov    (%rbx,%rax,8),%rax
mov    %ecx,%ecx
cmpb   $0x2d,(%rax,%rcx,1)
jne    1170 <human_move+0x30>
mov    %r14b,(%rax,%rcx,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0AEnter your move (x y): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"\0AINVALID MOVE. TRY AGAIN.\0A\00"
define i8** @human_move(i8** %0, i8 signext %1) {
%3 = alloca i8**
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %3
store i8 %1, i8* %4
store i32 0, i32* %7
br label %9
9: ; preds = %55, %2
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%12 = load i32, i32* %8
%13 = sub nsw i32 %12, 1
%14 = sdiv i32 %13, 3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load i32, i32* %8
%17 = sub nsw i32 %16, 1
%18 = srem i32 %17, 3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 4
br i1 %21, label %22, label %47
22: ; preds = %9
%23 = load i32, i32* %5
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %47
25: ; preds = %22
%26 = load i32, i32* %6
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %47
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 4
br i1 %30, label %31, label %47
31: ; preds = %28
%32 = load i8**, i8*** %3
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %32, i64 %35
%37 = load i8*, i8** %36
%38 = load i32, i32* %6
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 45
br i1 %44, label %45, label %46
45: ; preds = %31
store i32 1, i32* %7
br label %46
46: ; preds = %45, %31
br label %47
47: ; preds = %46, %28, %25, %22, %9
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%52 = load i8**, i8*** %3
%53 = call i32 @displayboard(i8** %52)
br label %54
54: ; preds = %50, %47
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = icmp ne i32 %56, 0
%58 = xor i1 %57, true
br i1 %58, label %9, label %59
59: ; preds = %55
%60 = load i8, i8* %4
%61 = load i8**, i8*** %3
%62 = load i32, i32* %5
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %61, i64 %64
%66 = load i8*, i8** %65
%67 = load i32, i32* %6
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
store i8 %60, i8* %70
%71 = load i8**, i8*** %3
ret i8** %71
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0AEnter your move (x y): \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [26 x i8] c"\0AINVALID MOVE. TRY AGAIN.\00"
define i8** @human_move(i8** returned %0, i8 signext %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %24, %2
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = add nsw i32 %8, -1
%10 = srem i32 %9, 3
%11 = sdiv i32 %9, 3
%12 = add i32 %8, 1
%13 = icmp ult i32 %12, 11
%14 = icmp sgt i32 %10, -1
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %24
16: ; preds = %5
%17 = sext i32 %11 to i64
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = zext i32 %10 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 45
br i1 %23, label %27, label %24
24: ; preds = %5, %16
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%26 = call i32 @displayboard(i8** %0)
br label %5
27: ; preds = %16
%28 = zext i32 %10 to i64
%29 = getelementptr inbounds i8, i8* %19, i64 %28
store i8 %1, i8* %29
ret i8** %0
}