#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int board[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
  int i = 0, i2 = 0;
  int gx, gy;
  int fin = 0;
  printf("-----------------\n");
  while (i < 3) {
    printf("%d ", board[i][i2]);
    i2 = i2 + 1;
    if (i2 > 2) {
      i2 = 0;
      i = i + 1;
      printf("\n");
    }
  }
  i = 0;
  i2 = 0;
  printf("-----------------\n");
  while (fin == 0) {
    printf("Please enter a x coordinate (0-2): ");
    scanf("%d", &gx);
    printf("Please enter a y coordinate (0-2): ");
    scanf("%d", &gy);
    if (board[gx][gy] == 0)
      board[gx][gy] = 1;
    else if (board[gx][gy] == 1)
      board[gx][gy] = 0;
    printf("-----------------\n");
    while (i < 3) {
      printf("%d ", board[i][i2]);
      i2 = i2 + 1;
      if (i2 > 2) {
        i2 = 0;
        i = i + 1;
        printf("\n");
      }
    }
    i = 0;
    i2 = 0;
    printf("-----------------\n");
    printf("Are you finished? (0 = No, 1 = Yes): ");
    scanf("%d", &fin);
    printf("-----------------\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1040 <memset@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x34(%rbp)
jge    11cf <main+0x9f>
movslq -0x34(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x2,-0x38(%rbp)
jle    11ca <main+0x9a>
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116b <main+0x3b>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x44(%rbp)
jne    1368 <main+0x238>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe31(%rip),%rdi
lea    -0x3c(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x3c(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    126d <main+0x13d>
movslq -0x3c(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    12a9 <main+0x179>
movslq -0x3c(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    12a4 <main+0x174>
movslq -0x3c(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    12a9 <main+0x179>
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x34(%rbp)
jge    131b <main+0x1eb>
movslq -0x34(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x2,-0x38(%rbp)
jle    1316 <main+0x1e6>
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b7 <main+0x187>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcef(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xca4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xbb>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x30(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xf03(%rip),%rdi
call   1040 <puts@plt>
lea    0xe82(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11a4 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
cmp    $0x3,%ebp
jge    11d0 <main+0x90>
movslq %ebp,%rax
movslq %ebx,%rcx
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
mov    (%rax,%rcx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x2,%ebx
jge    1190 <main+0x50>
add    $0x1,%ebx
cmp    $0x3,%ebp
jl     11a4 <main+0x64>
lea    0xe9e(%rip),%r15
mov    %r15,%rdi
call   1040 <puts@plt>
lea    0xe42(%rip),%rbx
lea    0xe13(%rip),%r14
lea    0x4(%rsp),%r13
jmp    1234 <main+0xf4>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1040 <puts@plt>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jne    12fc <main+0x1bc>
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
movslq 0xc(%rsp),%rcx
movslq 0x8(%rsp),%rax
lea    (%rcx,%rcx,2),%rcx
lea    (%rsp,%rcx,4),%rcx
add    $0x10,%rcx
mov    (%rcx,%rax,4),%edx
test   %edx,%edx
je     1290 <main+0x150>
cmp    $0x1,%edx
jne    129b <main+0x15b>
xor    %edx,%edx
jmp    1295 <main+0x155>
mov    $0x1,%edx
lea    (%rcx,%rax,4),%rax
mov    %edx,(%rax)
mov    %r15,%rdi
call   1040 <puts@plt>
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    12bd <main+0x17d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    $0x3,%ebp
jge    1200 <main+0xc0>
movslq %ebp,%rax
movslq %r12d,%rcx
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
mov    (%rax,%rcx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x2,%r12d
jl     12b0 <main+0x170>
add    $0x1,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r12d,%r12d
cmp    $0x3,%ebp
jl     12bd <main+0x17d>
jmp    1200 <main+0xc0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"-----------------\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [36 x i8] c"Please enter a x coordinate (0-2): \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [36 x i8] c"Please enter a y coordinate (0-2): \00"
@.str.6 = [38 x i8] c"Are you finished? (0 = No, 1 = Yes): \00"
define void @main() {
%1 = alloca [3 x [3 x i32]]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [3 x [3 x i32]]* %1 to i8*
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %29, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %14
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = icmp sgt i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %12
store i32 0, i32* %3
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %25, %12
br label %9
30: ; preds = %9
store i32 0, i32* %2
store i32 0, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %95, %30
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %100
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %41
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [3 x i32], [3 x i32]* %42, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %35
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %50
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [3 x i32], [3 x i32]* %51, i64 0, i64 %53
store i32 1, i32* %54
br label %72
55: ; preds = %35
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %57
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x i32], [3 x i32]* %58, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %71
64: ; preds = %55
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %66
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [3 x i32], [3 x i32]* %67, i64 0, i64 %69
store i32 0, i32* %70
br label %71
71: ; preds = %64, %55
br label %72
72: ; preds = %71, %48
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %74
74: ; preds = %94, %72
%75 = load i32, i32* %2
%76 = icmp slt i32 %75, 3
br i1 %76, label %77, label %95
77: ; preds = %74
%78 = load i32, i32* %2
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %79
%81 = load i32, i32* %3
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [3 x i32], [3 x i32]* %80, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %84)
%86 = load i32, i32* %3
%87 = add nsw i32 %86, 1
store i32 %87, i32* %3
%88 = load i32, i32* %3
%89 = icmp sgt i32 %88, 2
br i1 %89, label %90, label %94
90: ; preds = %77
store i32 0, i32* %3
%91 = load i32, i32* %2
%92 = add nsw i32 %91, 1
store i32 %92, i32* %2
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %94
94: ; preds = %90, %77
br label %74
95: ; preds = %74
store i32 0, i32* %2
store i32 0, i32* %3
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%98 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %32
100: ; preds = %32
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [36 x i8] c"Please enter a x coordinate (0-2): \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [36 x i8] c"Please enter a y coordinate (0-2): \00"
@.str.6 = [38 x i8] c"Are you finished? (0 = No, 1 = Yes): \00"
@str.10 = [18 x i8] c"-----------------\00"
define void @main() {
%1 = alloca [3 x [3 x i32]]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [3 x [3 x i32]]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
br label %10
10: ; preds = %0, %23
%11 = phi i32 [ 0, %0 ], [ %25, %23 ]
%12 = phi i32 [ 0, %0 ], [ %24, %23 ]
%13 = sext i32 %12 to i64
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %13, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nsw i32 %11, 1
%19 = icmp sgt i32 %11, 1
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = add nsw i32 %12, 1
%22 = tail call i32 @putchar(i32 10)
br label %23
23: ; preds = %20, %10
%24 = phi i32 [ %21, %20 ], [ %12, %10 ]
%25 = phi i32 [ 0, %20 ], [ %18, %10 ]
%26 = icmp slt i32 %24, 3
br i1 %26, label %10, label %27
27: ; preds = %23
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
br label %29
29: ; preds = %27, %62
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %35, i64 %37
%39 = load i32, i32* %38
switch i32 %39, label %43 [
i32 0, label %41
i32 1, label %40
]
40: ; preds = %29
br label %41
41: ; preds = %29, %40
%42 = phi i32 [ 0, %40 ], [ 1, %29 ]
store i32 %42, i32* %38
br label %43
43: ; preds = %41, %29
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
br label %45
45: ; preds = %43, %58
%46 = phi i32 [ 0, %43 ], [ %60, %58 ]
%47 = phi i32 [ 0, %43 ], [ %59, %58 ]
%48 = sext i32 %47 to i64
%49 = sext i32 %46 to i64
%50 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %48, i64 %49
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = add nsw i32 %46, 1
%54 = icmp sgt i32 %46, 1
br i1 %54, label %55, label %58
55: ; preds = %45
%56 = add nsw i32 %47, 1
%57 = call i32 @putchar(i32 10)
br label %58
58: ; preds = %55, %45
%59 = phi i32 [ %56, %55 ], [ %47, %45 ]
%60 = phi i32 [ 0, %55 ], [ %53, %45 ]
%61 = icmp slt i32 %59, 3
br i1 %61, label %45, label %62
62: ; preds = %58
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%67 = load i32, i32* %4
%68 = icmp eq i32 %67, 0
br i1 %68, label %29, label %69
69: ; preds = %62
ret void
}