#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*/ draw(char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void move(int player, char board[3][3]) {
  int row, column, number;
  draw(board);
  printf("Select a number to place your %c on: ", (player == 1) ? 'X' : 'O');
  scanf("%i", &number);
  row = --number / 3;
  column = number % 3;
  if (board[row][column] == 'X' || board[row][column] == 'Y') {
    printf("You cannot place that there. Try again: ");
    scanf("%i", &number);
    row = --number / 3;
    column = number % 3;
  }
  board[row][column] = (player == 1) ? 'X' : 'O';
}


x86 assembly (clang, -O0):
<move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <draw@plt>
mov    -0x4(%rbp),%ecx
mov    $0x4f,%esi
mov    $0x58,%eax
cmp    $0x1,%ecx
cmove  %eax,%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x58,%eax
je     11db <move+0xab>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x59,%eax
jne    121b <move+0xeb>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x4f,%eax
mov    $0x58,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <draw@plt>
xor    %eax,%eax
cmp    $0x1,%ebp
sete   %al
lea    (%rax,%rax,8),%ebp
add    $0x4f,%ebp
lea    0xeab(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
movslq %ecx,%rcx
imul   $0x55555556,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
neg    %edx
add    %edx,%eax
add    $0xffffffff,%eax
movslq %ecx,%rcx
cltq
lea    (%rcx,%rcx,2),%rdx
add    %rbx,%rdx
mov    (%rax,%rdx,1),%dl
and    $0xfe,%dl
cmp    $0x58,%dl
jne    11f8 <move+0xc8>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
sub    %edx,%eax
movslq %ecx,%rcx
cltq
lea    (%rcx,%rcx,2),%rcx
add    %rcx,%rbx
mov    %bpl,(%rax,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Select a number to place your %c on: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [41 x i8] c"You cannot place that there. Try again: \00"
define void @move(i32 %0, [3 x i8]* %1) {
%3 = alloca i32
%4 = alloca [3 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store [3 x i8]* %1, [3 x i8]** %4
%8 = load [3 x i8]*, [3 x i8]** %4
%9 = bitcast [3 x i8]* %8 to i8**
%10 = call i32 @draw(i8** %9)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 88, i32 79
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%17 = load i32, i32* %7
%18 = add nsw i32 %17, -1
store i32 %18, i32* %7
%19 = sdiv i32 %18, 3
store i32 %19, i32* %5
%20 = load i32, i32* %7
%21 = srem i32 %20, 3
store i32 %21, i32* %6
%22 = load [3 x i8]*, [3 x i8]** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %22, i64 %24
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %25, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 88
br i1 %31, label %43, label %32
32: ; preds = %2
%33 = load [3 x i8]*, [3 x i8]** %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [3 x i8], [3 x i8]* %33, i64 %35
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %36, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 89
br i1 %42, label %43, label %51
43: ; preds = %32, %2
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%46 = load i32, i32* %7
%47 = add nsw i32 %46, -1
store i32 %47, i32* %7
%48 = sdiv i32 %47, 3
store i32 %48, i32* %5
%49 = load i32, i32* %7
%50 = srem i32 %49, 3
store i32 %50, i32* %6
br label %51
51: ; preds = %43, %32
%52 = load i32, i32* %3
%53 = icmp eq i32 %52, 1
%54 = zext i1 %53 to i64
%55 = select i1 %53, i32 88, i32 79
%56 = trunc i32 %55 to i8
%57 = load [3 x i8]*, [3 x i8]** %4
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [3 x i8], [3 x i8]* %57, i64 %59
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %60, i64 0, i64 %62
store i8 %56, i8* %63
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Select a number to place your %c on: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [41 x i8] c"You cannot place that there. Try again: \00"
define void @move(i32 %0, [3 x i8]* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = bitcast [3 x i8]* %1 to i8**
%6 = tail call i32 @draw(i8** %5)
%7 = icmp eq i32 %0, 1
%8 = select i1 %7, i32 88, i32 79
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
%13 = sdiv i32 %12, 3
%14 = srem i32 %12, 3
%15 = sext i32 %13 to i64
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 %15, i64 %16
%18 = load i8, i8* %17
%19 = and i8 %18, -2
%20 = icmp eq i8 %19, 88
br i1 %20, label %21, label %30
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
%26 = sdiv i32 %25, 3
%27 = srem i32 %25, 3
%28 = sext i32 %26 to i64
%29 = sext i32 %27 to i64
br label %30
30: ; preds = %2, %21
%31 = phi i64 [ %16, %2 ], [ %29, %21 ]
%32 = phi i64 [ %15, %2 ], [ %28, %21 ]
%33 = trunc i32 %8 to i8
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 %32, i64 %31
store i8 %33, i8* %34
ret void
}