#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 EXIT_FAILURE;
void *calloc(int, int);
int /*<<< orphan*/ playGame(int **, int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
int main(int argc, char *argv[]) {
  int i;
  int board_size;
  int **board;
  printf("===================================\n");
  printf("Welcome to verTIC-horizonTAC-TOE!\n");
  printf("===================================\n");
  printf("Please select the size of the board: ");
  if (scanf("%d", &board_size) != 1) {
    printf("Input Error!\n");
    return EXIT_FAILURE;
  }
  board = calloc(board_size, sizeof *board);
  for (i = 0; i < board_size; i++) {
    board[i] = calloc(board_size, sizeof *board[i]);
  }
  playGame(board, board_size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11bc <main+0x7c>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x18(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    120a <main+0xca>
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d4 <main+0x94>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <playGame@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeeb(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11e9 <main+0x99>
mov    0xc(%rsp),%r15d
mov    %r15d,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    11da <main+0x8a>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11c0 <main+0x70>
mov    %r14,%rdi
mov    %r15d,%esi
call   1070 <playGame@plt>
xor    %eax,%eax
jmp    11fe <main+0xae>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"===================================\0A\00"
@.str.1 = [35 x i8] c"Welcome to verTIC-horizonTAC-TOE!\0A\00"
@.str.2 = [38 x i8] c"Please select the size of the board: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c"Input Error!\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %41
18: ; preds = %2
%19 = load i32, i32* %7
%20 = call i8* @calloc(i32 %19, i32 8)
%21 = bitcast i8* %20 to i32**
store i32** %21, i32*** %8
store i32 0, i32* %6
br label %22
22: ; preds = %34, %18
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i32, i32* %7
%28 = call i8* @calloc(i32 %27, i32 4)
%29 = bitcast i8* %28 to i32*
%30 = load i32**, i32*** %8
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32*, i32** %30, i64 %32
store i32* %29, i32** %33
br label %34
34: ; preds = %26
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %22
37: ; preds = %22
%38 = load i32**, i32*** %8
%39 = load i32, i32* %7
%40 = call i32 @playGame(i32** %38, i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %37, %15
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str.2 = [38 x i8] c"Please select the size of the board: \00"
@.str.3 = [3 x i8] c"%d\00"
@EXIT_FAILURE = global i32 0
@str.5 = [34 x i8] c"Welcome to verTIC-horizonTAC-TOE!\00"
@str.6 = [36 x i8] c"===================================\00"
@str.7 = [13 x i8] c"Input Error!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.6, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.6, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
br label %30
14: ; preds = %2
%15 = load i32, i32* %3
%16 = call i8* @calloc(i32 %15, i32 8)
%17 = bitcast i8* %16 to i32**
%18 = icmp sgt i32 %15, 0
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = zext i32 %15 to i64
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ 0, %19 ], [ %26, %21 ]
%23 = call i8* @calloc(i32 %15, i32 4)
%24 = getelementptr inbounds i32*, i32** %17, i64 %22
%25 = bitcast i32** %24 to i8**
store i8* %23, i8** %25
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %20
br i1 %27, label %28, label %21
28: ; preds = %21, %14
%29 = call i32 @playGame(i32** %17, i32 %15)
br label %30
30: ; preds = %28, %11
%31 = phi i32 [ %13, %11 ], [ 0, %28 ]
ret i32 %31
}