#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 checkState_(char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printBoard_(char **);
int /*<<< orphan*/ printf(char *, ...);
char *stateName_(int);
int main(int argc, char *argv[]) {
  char board[3][3];
  int i;
  int j;
  int state;
  if (argc != 10) {
    printf("Invalid parameters! Usage:\n");
    printf("ttt b11 b12 b13 b21 b22 b23 b31 b32 b33\n");
    printf("Where bij indicates the board position at i-row and "
           "j-column,\n");
    printf("being either X or O. Use _ for empty positions.\n");
    printf("As suggestions, one could invoke the command with line "
           "breaks, using the \\ character at the end of a line.\n");
    exit(1);
  }
  for (i = 0; i < 3; ++i) {
    for (j = 0; j < 3; ++j) {
      board[i][j] = argv[i * 3 + j][0];
    }
  }
  state = checkState_(board);
  printf("Tic Tac Toe board\n");
  printBoard_(board);
  printf("state is %s.\n", stateName_(state));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0xa,-0x8(%rbp)
je     11c0 <main+0x70>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    122d <main+0xdd>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    121a <main+0xca>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%dl
movslq -0x20(%rbp),%rcx
lea    -0x19(%rbp),%rax
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d8 <main+0x88>
jmp    121f <main+0xcf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c7 <main+0x77>
lea    -0x19(%rbp),%rdi
call   1070 <checkState_@plt>
mov    %eax,-0x28(%rbp)
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x19(%rbp),%rdi
call   1050 <printBoard_@plt>
mov    -0x28(%rbp),%edi
call   1030 <stateName_@plt>
mov    %rax,%rsi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
cmp    $0xa,%edi
jne    120c <main+0xac>
mov    (%rsi),%rax
mov    (%rax),%al
mov    %al,0xf(%rsp)
mov    0x8(%rsi),%rax
mov    (%rax),%al
mov    %al,0x10(%rsp)
mov    0x10(%rsi),%rax
mov    (%rax),%al
mov    %al,0x11(%rsp)
mov    0x18(%rsi),%rax
mov    (%rax),%al
mov    %al,0x12(%rsp)
mov    0x20(%rsi),%rax
mov    (%rax),%al
mov    %al,0x13(%rsp)
mov    0x28(%rsi),%rax
mov    (%rax),%al
mov    %al,0x14(%rsp)
mov    0x30(%rsi),%rax
mov    (%rax),%al
mov    %al,0x15(%rsp)
mov    0x38(%rsi),%rax
mov    (%rax),%al
mov    %al,0x16(%rsp)
mov    0x40(%rsi),%rax
mov    (%rax),%al
mov    %al,0x17(%rsp)
lea    0xf(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <checkState_@plt>
mov    %eax,%ebp
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <printBoard_@plt>
mov    %ebp,%edi
call   1040 <stateName_@plt>
lea    0xe07(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Invalid parameters! Usage:\0A\00"
@.str.1 = [41 x i8] c"ttt b11 b12 b13 b21 b22 b23 b31 b32 b33\0A\00"
@.str.2 = [63 x i8] c"Where bij indicates the board position at i-row and j-column,\0A\00"
@.str.3 = [49 x i8] c"being either X or O. Use _ for empty positions.\0A\00"
@.str.4 = [108 x i8] c"As suggestions, one could invoke the command with line breaks, using the \\ character at the end of a line.\0A\00"
@.str.5 = [19 x i8] c"Tic Tac Toe board\0A\00"
@.str.6 = [14 x i8] c"state is %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x [3 x i8]]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
store i32 0, i32* %7
br label %20
20: ; preds = %48, %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %51
23: ; preds = %20
store i32 0, i32* %8
br label %24
24: ; preds = %44, %23
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 3
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = load i32, i32* %7
%30 = mul nsw i32 %29, 3
%31 = load i32, i32* %8
%32 = add nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %28, i64 %33
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %6, i64 0, i64 %39
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x i8], [3 x i8]* %40, i64 0, i64 %42
store i8 %37, i8* %43
br label %44
44: ; preds = %27
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %24
47: ; preds = %24
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %20
51: ; preds = %20
%52 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %6, i64 0, i64 0
%53 = bitcast [3 x i8]* %52 to i8**
%54 = call i32 @checkState_(i8** %53)
store i32 %54, i32* %9
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%56 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %6, i64 0, i64 0
%57 = bitcast [3 x i8]* %56 to i8**
%58 = call i32 @printBoard_(i8** %57)
%59 = load i32, i32* %9
%60 = call i8* @stateName_(i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %60)
ret i32 0
}

LLVM IR (-O2):
@.str.6 = [14 x i8] c"state is %s.\0A\00"
@str = [18 x i8] c"Tic Tac Toe board\00"
@str.7 = [27 x i8] c"Invalid parameters! Usage:\00"
@str.8 = [40 x i8] c"ttt b11 b12 b13 b21 b22 b23 b31 b32 b33\00"
@str.9 = [62 x i8] c"Where bij indicates the board position at i-row and j-column,\00"
@str.10 = [48 x i8] c"being either X or O. Use _ for empty positions.\00"
@str.11 = [107 x i8] c"As suggestions, one could invoke the command with line breaks, using the \\ character at the end of a line.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x [3 x i8]]
%4 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 0, i64 0
%5 = icmp eq i32 %0, 10
br i1 %5, label %6, label %47
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = load i8, i8* %7
store i8 %8, i8* %4
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 0, i64 1
store i8 %11, i8* %12
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 0, i64 2
store i8 %15, i8* %16
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 1, i64 0
store i8 %19, i8* %20
%21 = getelementptr inbounds i8*, i8** %1, i64 4
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 1, i64 1
store i8 %23, i8* %24
%25 = getelementptr inbounds i8*, i8** %1, i64 5
%26 = load i8*, i8** %25
%27 = load i8, i8* %26
%28 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 1, i64 2
store i8 %27, i8* %28
%29 = getelementptr inbounds i8*, i8** %1, i64 6
%30 = load i8*, i8** %29
%31 = load i8, i8* %30
%32 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 2, i64 0
store i8 %31, i8* %32
%33 = getelementptr inbounds i8*, i8** %1, i64 7
%34 = load i8*, i8** %33
%35 = load i8, i8* %34
%36 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 2, i64 1
store i8 %35, i8* %36
%37 = getelementptr inbounds i8*, i8** %1, i64 8
%38 = load i8*, i8** %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 2, i64 2
store i8 %39, i8* %40
%41 = bitcast [3 x [3 x i8]]* %3 to i8**
%42 = call i32 @checkState_(i8** %41)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%44 = call i32 @printBoard_(i8** %41)
%45 = call i8* @stateName_(i32 %42)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %45)
ret i32 0
47: ; preds = %2
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.9, i64 0, i64 0))
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.10, i64 0, i64 0))
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([107 x i8], [107 x i8]* @str.11, i64 0, i64 0))
%53 = tail call i32 @exit(i32 1)
unreachable
}