#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 board_get_position(int, int);
int /*<<< orphan*/ board_set_position(int, int, int);
void invert_all_moves(void) {
  int i;
  int j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      if (board_get_position(i, j) == 1) {
        board_set_position(i, j, 2);
      } else if (board_get_position(i, j) == 2) {
        board_set_position(i, j, 1);
      }
    }
  }
}


x86 assembly (clang, -O0):
<invert_all_moves>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    11c2 <invert_all_moves+0xa2>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11af <invert_all_moves+0x8f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <board_get_position@plt>
cmp    $0x1,%eax
jne    1173 <invert_all_moves+0x53>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2,%edx
call   1030 <board_set_position@plt>
jmp    119c <invert_all_moves+0x7c>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <board_get_position@plt>
cmp    $0x2,%eax
jne    1197 <invert_all_moves+0x77>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1030 <board_set_position@plt>
jmp    119c <invert_all_moves+0x7c>
jmp    11a1 <invert_all_moves+0x81>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1140 <invert_all_moves+0x20>
jmp    11b4 <invert_all_moves+0x94>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <invert_all_moves+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invert_all_moves>:
push   %rbx
xor    %edi,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    $0x2,%edx
cmp    $0x1,%eax
je     1147 <invert_all_moves+0x27>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%edx
cmp    $0x2,%eax
jne    1150 <invert_all_moves+0x30>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <board_set_position@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    $0x2,%edx
cmp    $0x1,%eax
je     117c <invert_all_moves+0x5c>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%edx
cmp    $0x2,%eax
jne    1188 <invert_all_moves+0x68>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <board_set_position@plt>
mov    $0x2,%ebx
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
cmp    $0x1,%eax
je     11b4 <invert_all_moves+0x94>
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jne    11c2 <invert_all_moves+0xa2>
xor    %edi,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1030 <board_set_position@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    $0x2,%edx
cmp    $0x1,%eax
je     11ee <invert_all_moves+0xce>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%edx
cmp    $0x2,%eax
jne    11fa <invert_all_moves+0xda>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <board_set_position@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    $0x2,%edx
cmp    $0x1,%eax
je     122c <invert_all_moves+0x10c>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%edx
cmp    $0x2,%eax
jne    123b <invert_all_moves+0x11b>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <board_set_position@plt>
mov    $0x2,%ebx
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
cmp    $0x1,%eax
je     126d <invert_all_moves+0x14d>
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jne    127e <invert_all_moves+0x15e>
mov    $0x1,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1030 <board_set_position@plt>
mov    $0x2,%ebx
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
cmp    $0x1,%eax
je     12aa <invert_all_moves+0x18a>
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jne    12b8 <invert_all_moves+0x198>
mov    $0x2,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1030 <board_set_position@plt>
mov    $0x2,%ebx
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
cmp    $0x1,%eax
je     12ea <invert_all_moves+0x1ca>
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jne    12fb <invert_all_moves+0x1db>
mov    $0x2,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1030 <board_set_position@plt>
mov    $0x2,%ebx
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
cmp    $0x1,%eax
je     132d <invert_all_moves+0x20d>
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jne    133f <invert_all_moves+0x21f>
mov    $0x2,%edi
mov    $0x2,%esi
mov    %ebx,%edx
pop    %rbx
jmp    1030 <board_set_position@plt>
pop    %rbx
ret

LLVM IR (-O0):
define void @invert_all_moves() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %34, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 3
br i1 %5, label %6, label %37
6: ; preds = %3
store i32 0, i32* %2
br label %7
7: ; preds = %30, %6
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %33
10: ; preds = %7
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @board_get_position(i32 %11, i32 %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 @board_set_position(i32 %16, i32 %17, i32 2)
br label %29
19: ; preds = %10
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 @board_get_position(i32 %20, i32 %21)
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = call i32 @board_set_position(i32 %25, i32 %26, i32 1)
br label %28
28: ; preds = %24, %19
br label %29
29: ; preds = %28, %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %7
33: ; preds = %7
br label %34
34: ; preds = %33
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
store i32 %36, i32* %1
br label %3
37: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @invert_all_moves() {
%1 = tail call i32 @board_get_position(i32 0, i32 0)
%2 = icmp eq i32 %1, 1
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @board_get_position(i32 0, i32 0)
%5 = icmp eq i32 %4, 2
br i1 %5, label %6, label %9
6: ; preds = %3, %0
%7 = phi i32 [ 2, %0 ], [ 1, %3 ]
%8 = tail call i32 @board_set_position(i32 0, i32 0, i32 %7)
br label %9
9: ; preds = %6, %3
%10 = tail call i32 @board_get_position(i32 0, i32 1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @board_get_position(i32 0, i32 1)
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %9, %12
%16 = phi i32 [ 1, %12 ], [ 2, %9 ]
%17 = tail call i32 @board_set_position(i32 0, i32 1, i32 %16)
br label %18
18: ; preds = %15, %12
%19 = tail call i32 @board_get_position(i32 0, i32 2)
%20 = icmp eq i32 %19, 1
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @board_get_position(i32 0, i32 2)
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %18, %21
%25 = phi i32 [ 1, %21 ], [ 2, %18 ]
%26 = tail call i32 @board_set_position(i32 0, i32 2, i32 %25)
br label %27
27: ; preds = %24, %21
%28 = tail call i32 @board_get_position(i32 1, i32 0)
%29 = icmp eq i32 %28, 1
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = tail call i32 @board_get_position(i32 1, i32 0)
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %36
33: ; preds = %30, %27
%34 = phi i32 [ 2, %27 ], [ 1, %30 ]
%35 = tail call i32 @board_set_position(i32 1, i32 0, i32 %34)
br label %36
36: ; preds = %33, %30
%37 = tail call i32 @board_get_position(i32 1, i32 1)
%38 = icmp eq i32 %37, 1
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = tail call i32 @board_get_position(i32 1, i32 1)
%41 = icmp eq i32 %40, 2
br i1 %41, label %42, label %45
42: ; preds = %39, %36
%43 = phi i32 [ 1, %39 ], [ 2, %36 ]
%44 = tail call i32 @board_set_position(i32 1, i32 1, i32 %43)
br label %45
45: ; preds = %42, %39
%46 = tail call i32 @board_get_position(i32 1, i32 2)
%47 = icmp eq i32 %46, 1
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = tail call i32 @board_get_position(i32 1, i32 2)
%50 = icmp eq i32 %49, 2
br i1 %50, label %51, label %54
51: ; preds = %48, %45
%52 = phi i32 [ 1, %48 ], [ 2, %45 ]
%53 = tail call i32 @board_set_position(i32 1, i32 2, i32 %52)
br label %54
54: ; preds = %51, %48
%55 = tail call i32 @board_get_position(i32 2, i32 0)
%56 = icmp eq i32 %55, 1
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = tail call i32 @board_get_position(i32 2, i32 0)
%59 = icmp eq i32 %58, 2
br i1 %59, label %60, label %63
60: ; preds = %57, %54
%61 = phi i32 [ 2, %54 ], [ 1, %57 ]
%62 = tail call i32 @board_set_position(i32 2, i32 0, i32 %61)
br label %63
63: ; preds = %60, %57
%64 = tail call i32 @board_get_position(i32 2, i32 1)
%65 = icmp eq i32 %64, 1
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = tail call i32 @board_get_position(i32 2, i32 1)
%68 = icmp eq i32 %67, 2
br i1 %68, label %69, label %72
69: ; preds = %66, %63
%70 = phi i32 [ 1, %66 ], [ 2, %63 ]
%71 = tail call i32 @board_set_position(i32 2, i32 1, i32 %70)
br label %72
72: ; preds = %69, %66
%73 = tail call i32 @board_get_position(i32 2, i32 2)
%74 = icmp eq i32 %73, 1
br i1 %74, label %78, label %75
75: ; preds = %72
%76 = tail call i32 @board_get_position(i32 2, i32 2)
%77 = icmp eq i32 %76, 2
br i1 %77, label %78, label %81
78: ; preds = %75, %72
%79 = phi i32 [ 1, %75 ], [ 2, %72 ]
%80 = tail call i32 @board_set_position(i32 2, i32 2, i32 %79)
br label %81
81: ; preds = %78, %75
ret void
}