#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 *, int *);
char **human_move(char **board, char piece) {
  int x, y, valid;
  valid = 0;
  do {
    printf("\nEnter your move (x,y): ");
    scanf("%i,%i", &x, &y);
    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    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x4,-0x10(%rbp)
jge    11c4 <human_move+0x94>
cmpl   $0x0,-0x10(%rbp)
jle    11c4 <human_move+0x94>
cmpl   $0x0,-0x14(%rbp)
jle    11c4 <human_move+0x94>
cmpl   $0x4,-0x14(%rbp)
jge    11c4 <human_move+0x94>
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    11bf <human_move+0x8f>
movl   $0x1,-0x18(%rbp)
jmp    11c4 <human_move+0x94>
cmpl   $0x0,-0x18(%rbp)
jne    11e3 <human_move+0xb3>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <displayboard@plt>
jmp    11e8 <human_move+0xb8>
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
sub    $0x18,%rsp
mov    %esi,0xc(%rsp)
mov    %rdi,%rbx
lea    0xea4(%rip),%r15
lea    0xeb6(%rip),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbp
lea    0xeab(%rip),%r14
jmp    1190 <human_move+0x50>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <displayboard@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <scanf@plt>
mov    0x14(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    $0x2,%ecx
ja     1180 <human_move+0x40>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    1180 <human_move+0x40>
cmp    $0x3,%eax
jg     1180 <human_move+0x40>
mov    %ecx,%ecx
mov    (%rbx,%rcx,8),%rcx
add    $0xffffffff,%eax
cmpb   $0x2d,(%rcx,%rax,1)
jne    1180 <human_move+0x40>
mov    %eax,%eax
mov    0xc(%rsp),%edx
mov    %dl,(%rcx,%rax,1)
mov    %rbx,%rax
add    $0x18,%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 = [6 x i8] c"%i,%i\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
store i8** %0, i8*** %3
store i8 %1, i8* %4
store i32 0, i32* %7
br label %8
8: ; preds = %46, %2
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %38
13: ; preds = %8
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %38
16: ; preds = %13
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 4
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = load i8**, i8*** %3
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %23, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* %6
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 45
br i1 %35, label %36, label %37
36: ; preds = %22
store i32 1, i32* %7
br label %37
37: ; preds = %36, %22
br label %38
38: ; preds = %37, %19, %16, %13, %8
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%43 = load i8**, i8*** %3
%44 = call i32 @displayboard(i8** %43)
br label %45
45: ; preds = %41, %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
%49 = xor i1 %48, true
br i1 %49, label %8, label %50
50: ; preds = %46
%51 = load i8, i8* %4
%52 = load i8**, i8*** %3
%53 = load i32, i32* %5
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %52, i64 %55
%57 = load i8*, i8** %56
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
store i8 %51, i8* %61
%62 = load i8**, i8*** %3
ret i8** %62
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0AEnter your move (x,y): \00"
@.str.1 = [6 x i8] c"%i,%i\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 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
br label %7
7: ; preds = %27, %2
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = add i32 %10, -1
%12 = icmp ult i32 %11, 3
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
%15 = select i1 %12, i1 %14, i1 false
%16 = icmp slt i32 %13, 4
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %18, label %27
18: ; preds = %7
%19 = zext i32 %11 to i64
%20 = getelementptr inbounds i8*, i8** %0, i64 %19
%21 = load i8*, i8** %20
%22 = add nsw i32 %13, -1
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 45
br i1 %26, label %30, label %27
27: ; preds = %7, %18
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%29 = call i32 @displayboard(i8** %0)
br label %7
30: ; preds = %18
%31 = zext i32 %22 to i64
%32 = getelementptr inbounds i8, i8* %21, i64 %31
store i8 %1, i8* %32
ret i8** %0
}