#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*/ checkAndWriteEffect(int, int, int, int, int **);
void writePositionEffect(int **chessboard) {
  int i, j, row, col;
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (chessboard[i][j] == 1) {
        for (row = 0; row < 8; row++) {
          for (col = 0; col < 8; col++) {
            checkAndWriteEffect(row, col, i, j, chessboard);
          }
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<writePositionEffect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11db <writePositionEffect+0xcb>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    11c8 <writePositionEffect+0xb8>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11b5 <writePositionEffect+0xa5>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11b0 <writePositionEffect+0xa0>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    119d <writePositionEffect+0x8d>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%r8
call   1030 <checkAndWriteEffect@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <writePositionEffect+0x60>
jmp    11a2 <writePositionEffect+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <writePositionEffect+0x4f>
jmp    11b5 <writePositionEffect+0xa5>
jmp    11ba <writePositionEffect+0xaa>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <writePositionEffect+0x24>
jmp    11cd <writePositionEffect+0xbd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <writePositionEffect+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writePositionEffect>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %r15d,%r15d
jmp    112e <writePositionEffect+0x1e>
nop
add    $0x1,%r15
cmp    $0x8,%r15
je     120e <writePositionEffect+0xfe>
xor    %ebx,%ebx
jmp    114a <writePositionEffect+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x8,%rbx
je     1120 <writePositionEffect+0x10>
mov    (%r14,%r15,8),%rax
cmpl   $0x1,(%rax,%rbx,4)
jne    1140 <writePositionEffect+0x30>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
xor    %esi,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x2,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x3,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x4,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x5,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x6,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
mov    %ebp,%edi
mov    $0x7,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <checkAndWriteEffect@plt>
add    $0x1,%ebp
cmp    $0x8,%ebp
jne    1160 <writePositionEffect+0x50>
jmp    1140 <writePositionEffect+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @writePositionEffect(i32** %0) {
%2 = alloca i32**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32** %0, i32*** %2
store i32 0, i32* %3
br label %7
7: ; preds = %53, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %56
10: ; preds = %7
store i32 0, i32* %4
br label %11
11: ; preds = %49, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 8
br i1 %13, label %14, label %52
14: ; preds = %11
%15 = load i32**, i32*** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32*, i32** %15, i64 %17
%19 = load i32*, i32** %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %48
25: ; preds = %14
store i32 0, i32* %5
br label %26
26: ; preds = %44, %25
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 8
br i1 %28, label %29, label %47
29: ; preds = %26
store i32 0, i32* %6
br label %30
30: ; preds = %40, %29
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 8
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = load i32**, i32*** %2
%39 = call i32 @checkAndWriteEffect(i32 %34, i32 %35, i32 %36, i32 %37, i32** %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %30
43: ; preds = %30
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %26
47: ; preds = %26
br label %48
48: ; preds = %47, %14
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %11
52: ; preds = %11
br label %53
53: ; preds = %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %7
56: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @writePositionEffect(i32** %0) {
br label %2
2: ; preds = %1, %29
%3 = phi i64 [ 0, %1 ], [ %30, %29 ]
%4 = getelementptr inbounds i32*, i32** %0, i64 %3
%5 = trunc i64 %3 to i32
br label %6
6: ; preds = %2, %26
%7 = phi i64 [ 0, %2 ], [ %27, %26 ]
%8 = load i32*, i32** %4
%9 = getelementptr inbounds i32, i32* %8, i64 %7
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %26
12: ; preds = %6
%13 = trunc i64 %7 to i32
br label %14
14: ; preds = %12, %14
%15 = phi i32 [ %24, %14 ], [ 0, %12 ]
%16 = tail call i32 @checkAndWriteEffect(i32 %15, i32 0, i32 %5, i32 %13, i32** %0)
%17 = tail call i32 @checkAndWriteEffect(i32 %15, i32 1, i32 %5, i32 %13, i32** %0)
%18 = tail call i32 @checkAndWriteEffect(i32 %15, i32 2, i32 %5, i32 %13, i32** %0)
%19 = tail call i32 @checkAndWriteEffect(i32 %15, i32 3, i32 %5, i32 %13, i32** %0)
%20 = tail call i32 @checkAndWriteEffect(i32 %15, i32 4, i32 %5, i32 %13, i32** %0)
%21 = tail call i32 @checkAndWriteEffect(i32 %15, i32 5, i32 %5, i32 %13, i32** %0)
%22 = tail call i32 @checkAndWriteEffect(i32 %15, i32 6, i32 %5, i32 %13, i32** %0)
%23 = tail call i32 @checkAndWriteEffect(i32 %15, i32 7, i32 %5, i32 %13, i32** %0)
%24 = add nuw nsw i32 %15, 1
%25 = icmp eq i32 %24, 8
br i1 %25, label %26, label %14
26: ; preds = %14, %6
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, 8
br i1 %28, label %29, label %6
29: ; preds = %26
%30 = add nuw nsw i64 %3, 1
%31 = icmp eq i64 %30, 8
br i1 %31, label %32, label %2
32: ; preds = %29
ret void
}