#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 */
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_stone(char *, char, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stdin;
void human_turn(char *br, char current, int *round) {
  char buff[5];
  int x, y;
  bool input;
  printf("Enter moves as \"<row> <col>\" (no quotes)\n");
  do {
    input = true;
    printf("%c\'s move: ", current);
    if (fgets(buff, sizeof(buff), stdin) != NULL) {
      sscanf(buff, "%i%i", &x, &y);
      if ((x > 0 && x < 3 + 1) && (y > 0 && y < 3 + 1)) {
        if (!set_stone(br, current, ((3 * (x - 1)) + (y - 1)))) {
          printf("Illegal move (already taken), try again\n");
          input = false;
        }
      } else {
        printf("Illegal move (off board), try again\n");
        input = false;
      }
    }
  } while (!input);
  ++*round;
}


x86 assembly (clang, -O0):
<human_turn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
movsbl -0x9(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1d(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     123b <human_turn+0xfb>
lea    -0x1d(%rbp),%rdi
lea    0xe8d(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1050 <sscanf@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1221 <human_turn+0xe1>
cmpl   $0x4,-0x24(%rbp)
jge    1221 <human_turn+0xe1>
cmpl   $0x0,-0x28(%rbp)
jle    1221 <human_turn+0xe1>
cmpl   $0x4,-0x28(%rbp)
jge    1221 <human_turn+0xe1>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
imul   $0x3,%ecx,%edx
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
add    %ecx,%edx
movsbl %al,%esi
call   1060 <set_stone@plt>
cmp    $0x0,%eax
jne    121c <human_turn+0xdc>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
jmp    1236 <human_turn+0xf6>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
jmp    123b <human_turn+0xfb>
jmp    1240 <human_turn+0x100>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1164 <human_turn+0x24>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<human_turn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x18(%rsp)
mov    %esi,%ebp
mov    %rdi,0x20(%rsp)
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
lea    0x13(%rsp),%rdi
mov    $0x5,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     125a <human_turn+0x10a>
lea    0x13(%rsp),%rbx
lea    0x8(%rsp),%r14
lea    0xe82(%rip),%r13
movsbl %bpl,%r15d
lea    0xe3d(%rip),%r12
jmp    11fc <human_turn+0xac>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     125a <human_turn+0x10a>
mov    %rbx,%rdi
lea    0xe06(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r14,%rcx
call   1060 <sscanf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %r13,%rdi
cmp    $0x2,%ecx
ja     11d0 <human_turn+0x80>
mov    0x8(%rsp),%ecx
mov    %r13,%rdi
test   %ecx,%ecx
jle    11d0 <human_turn+0x80>
mov    %r13,%rdi
cmp    $0x3,%ecx
jg     11d0 <human_turn+0x80>
lea    (%rax,%rax,2),%eax
lea    (%rcx,%rax,1),%edx
add    $0xfffffffc,%edx
mov    0x20(%rsp),%rdi
mov    %r15d,%esi
call   1070 <set_stone@plt>
lea    0xe0c(%rip),%rdi
test   %eax,%eax
je     11d0 <human_turn+0x80>
mov    0x18(%rsp),%rax
addl   $0x1,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter moves as \22<row> <col>\22 (no quotes)\0A\00"
@.str.1 = [12 x i8] c"%c's move: \00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"%i%i\00"
@.str.3 = [41 x i8] c"Illegal move (already taken), try again\0A\00"
@.str.4 = [37 x i8] c"Illegal move (off board), try again\0A\00"
define void @human_turn(i8* %0, i8 signext %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32*
%7 = alloca [5 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
store i32* %2, i32** %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %52, %3
store i32 1, i32* %10
%13 = load i8, i8* %5
%14 = sext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i32* @fgets(i8* %16, i32 5, i32 %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %51
20: ; preds = %12
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %8, i32* %9)
%23 = load i32, i32* %8
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %48
25: ; preds = %20
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %48
28: ; preds = %25
%29 = load i32, i32* %9
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %48
31: ; preds = %28
%32 = load i32, i32* %9
%33 = icmp slt i32 %32, 4
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = load i8*, i8** %4
%36 = load i8, i8* %5
%37 = load i32, i32* %8
%38 = sub nsw i32 %37, 1
%39 = mul nsw i32 3, %38
%40 = load i32, i32* %9
%41 = sub nsw i32 %40, 1
%42 = add nsw i32 %39, %41
%43 = call i32 @set_stone(i8* %35, i8 signext %36, i32 %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %34
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
br label %47
47: ; preds = %45, %34
br label %50
48: ; preds = %31, %28, %25, %20
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %10
br label %50
50: ; preds = %48, %47
br label %51
51: ; preds = %50, %12
br label %52
52: ; preds = %51
%53 = load i32, i32* %10
%54 = icmp ne i32 %53, 0
%55 = xor i1 %54, true
br i1 %55, label %12, label %56
56: ; preds = %52
%57 = load i32*, i32** %6
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
ret void
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"%c's move: \00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"%i%i\00"
@str = [41 x i8] c"Enter moves as \22<row> <col>\22 (no quotes)\00"
@str.5 = [36 x i8] c"Illegal move (off board), try again\00"
@str.6 = [40 x i8] c"Illegal move (already taken), try again\00"
define void @human_turn(i8* %0, i8 signext %1, i32* nocapture %2) {
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%11 = sext i8 %1 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %7, i32 5, i32 %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %39, label %16
16: ; preds = %3, %32
%17 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %5, i32* %6)
%18 = load i32, i32* %5
%19 = add i32 %18, -1
%20 = icmp ult i32 %19, 3
%21 = load i32, i32* %6
%22 = icmp sgt i32 %21, 0
%23 = select i1 %20, i1 %22, i1 false
%24 = icmp slt i32 %21, 4
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %32
26: ; preds = %16
%27 = mul nuw nsw i32 %18, 3
%28 = add nuw nsw i32 %21, -4
%29 = add nsw i32 %28, %27
%30 = call i32 @set_stone(i8* %0, i8 signext %1, i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %16, %26
%33 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0), %26 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0), %16 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%36 = load i32, i32* @stdin
%37 = call i32* @fgets(i8* %7, i32 5, i32 %36)
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %16
39: ; preds = %32, %26, %3
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
ret void
}