#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ stderr;
void make_accumulation(int DATA[500][500], int ACC[500][500], int rows,
                       int cols) {
  int i, j;
  int no_more_data = 0;
  int valid_cell = 0;
  int local_row, local_col;
  int new_row, new_col;
  int cells_in_flowpath = 0;
  int LOOP[500][500];
  int k, l;
  for (i = 1; i < rows + 1; i++) {
    for (j = 1; j < cols + 1; j++) {
      valid_cell = 0;
      if (DATA[i][j] == 9)
        valid_cell = 1;
      if (valid_cell == 0) {
        local_row = new_row = i;
        local_col = new_col = j;
        no_more_data = 0;
        cells_in_flowpath = 0;
        for (k = 0; k < rows + 2; k++)
          for (l = 0; l < cols + 2; l++)
            LOOP[k][l] = 0;
        while (no_more_data == 0) {
          LOOP[local_row][local_col] = LOOP[local_row][local_col] + 1;
          ACC[local_row][local_col] = ACC[local_row][local_col] + 1;
          cells_in_flowpath++;
          if (DATA[local_row][local_col] == 1) {
            new_row--;
          }
          if (DATA[local_row][local_col] == 2) {
            new_row--;
            new_col++;
          }
          if (DATA[local_row][local_col] == 3) {
            new_col++;
          }
          if (DATA[local_row][local_col] == 4) {
            new_row++;
            new_col++;
          }
          if (DATA[local_row][local_col] == 5) {
            new_row++;
          }
          if (DATA[local_row][local_col] == 6) {
            new_row++;
            new_col--;
          }
          if (DATA[local_row][local_col] == 7) {
            new_col--;
          }
          if (DATA[local_row][local_col] == 8) {
            new_row--;
            new_col--;
          }
          if (DATA[new_row][new_col] == 9)
            no_more_data = 1;
          if (LOOP[local_row][local_col] > 1) {
            fprintf(stderr, "LOOP at local_row %d local_col %d\n", local_row,
                    local_col);
            fprintf(stderr, "in gridcell i= %d j= %d\n", i, j);
            fprintf(stderr, "DATA[i][j] = %d\n", DATA[i][j]);
            no_more_data = 1;
            exit(0);
          }
          local_row = new_row;
          local_col = new_col;
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<make_accumulation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4290,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1557 <make_accumulation+0x437>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1544 <make_accumulation+0x424>
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x9,(%rax,%rcx,4)
jne    11ac <make_accumulation+0x8c>
movl   $0x1,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1531 <make_accumulation+0x411>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0xf4284(%rbp)
mov    -0xf4284(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1265 <make_accumulation+0x145>
movl   $0x0,-0xf4288(%rbp)
mov    -0xf4288(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    124c <make_accumulation+0x12c>
movslq -0xf4284(%rbp),%rcx
lea    -0xf4280(%rbp),%rax
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0xf4288(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xf4288(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4288(%rbp)
jmp    11fe <make_accumulation+0xde>
jmp    1251 <make_accumulation+0x131>
mov    -0xf4284(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4284(%rbp)
jmp    11e0 <make_accumulation+0xc0>
jmp    126a <make_accumulation+0x14a>
cmpl   $0x0,-0x24(%rbp)
jne    152c <make_accumulation+0x40c>
movslq -0x2c(%rbp),%rcx
lea    -0xf4280(%rbp),%rax
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
movslq -0x2c(%rbp),%rcx
lea    -0xf4280(%rbp),%rax
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1316 <make_accumulation+0x1f6>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x2,(%rax,%rcx,4)
jne    1348 <make_accumulation+0x228>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x3,(%rax,%rcx,4)
jne    1371 <make_accumulation+0x251>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x4,(%rax,%rcx,4)
jne    13a3 <make_accumulation+0x283>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x5,(%rax,%rcx,4)
jne    13cc <make_accumulation+0x2ac>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x6,(%rax,%rcx,4)
jne    13fe <make_accumulation+0x2de>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x7,(%rax,%rcx,4)
jne    1427 <make_accumulation+0x307>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x8,(%rax,%rcx,4)
jne    1459 <make_accumulation+0x339>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
cmpl   $0x9,(%rax,%rcx,4)
jne    1480 <make_accumulation+0x360>
movl   $0x1,-0x24(%rbp)
movslq -0x2c(%rbp),%rcx
lea    -0xf4280(%rbp),%rax
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jle    151b <make_accumulation+0x3fb>
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xb47(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2b19(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xb4d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xb36(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
xor    %edi,%edi
call   1040 <exit@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    126a <make_accumulation+0x14a>
jmp    1531 <make_accumulation+0x411>
jmp    1536 <make_accumulation+0x416>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116d <make_accumulation+0x4d>
jmp    1549 <make_accumulation+0x429>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1155 <make_accumulation+0x35>
add    $0xf4290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_accumulation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf4298,%rsp
mov    %rsi,0x48(%rsp)
test   %edx,%edx
jle    13cc <make_accumulation+0x29c>
mov    %ecx,%r12d
mov    %rdi,%r15
mov    %rdx,%rax
lea    0x2(%r12),%r13d
shl    $0x2,%r13
mov    %eax,%ecx
lea    0x2(%rcx),%rdx
lea    0x1(%r12),%esi
mov    %rsi,0x38(%rsp)
add    $0x1,%eax
mov    %rax,0x10(%rsp)
add    $0x1,%rcx
mov    %rcx,0x28(%rsp)
mov    %edx,%eax
and    $0x3,%eax
and    $0xfffffffc,%edx
mov    %rdx,0x18(%rsp)
mov    %rax,0x20(%rsp)
imul   $0x7d0,%rax,%rax
mov    %rax,0x40(%rsp)
mov    $0x1,%eax
mov    %rax,(%rsp)
jmp    11c7 <make_accumulation+0x97>
nopw   0x0(%rax,%rax,1)
mov    (%rsp),%rax
add    $0x1,%rax
mov    %rax,(%rsp)
cmp    0x10(%rsp),%rax
je     13cc <make_accumulation+0x29c>
test   %r12d,%r12d
jle    11b0 <make_accumulation+0x80>
mov    $0x1,%eax
jmp    11f0 <make_accumulation+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rax
add    $0x1,%rax
cmp    0x38(%rsp),%rax
je     11b0 <make_accumulation+0x80>
imul   $0x7d0,(%rsp),%rcx
add    %r15,%rcx
mov    %rax,0x8(%rsp)
cmpl   $0x9,(%rcx,%rax,4)
je     11e0 <make_accumulation+0xb0>
mov    %rcx,0x30(%rsp)
cmpq   $0x3,0x28(%rsp)
jae    1360 <make_accumulation+0x230>
xor    %r14d,%r14d
cmpq   $0x0,0x20(%rsp)
je     1270 <make_accumulation+0x140>
imul   $0x7d0,%r14,%rax
lea    (%rsp,%rax,1),%rbx
add    $0x50,%rbx
xor    %ebp,%ebp
jmp    124e <make_accumulation+0x11e>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x7d0,%rbp
cmp    %rbp,0x40(%rsp)
je     1270 <make_accumulation+0x140>
cmp    $0xffffffff,%r12d
jl     1240 <make_accumulation+0x110>
lea    (%rbx,%rbp,1),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1030 <memset@plt>
jmp    1240 <make_accumulation+0x110>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rcx
mov    0x30(%rsp),%rax
lea    (%rax,%rcx,4),%r14
xor    %edi,%edi
mov    (%rsp),%rax
mov    %eax,%ebp
mov    %ecx,%esi
nopl   0x0(%rax,%rax,1)
test   %edi,%edi
jne    11e0 <make_accumulation+0xb0>
mov    %esi,%ecx
mov    %ebp,%edx
movslq %ebp,%rbx
movslq %esi,%rsi
imul   $0x7d0,%rbx,%rdi
lea    (%rsp,%rdi,1),%rbp
add    $0x50,%rbp
mov    0x0(%rbp,%rsi,4),%r8d
lea    0x1(%r8),%eax
mov    %eax,0x0(%rbp,%rsi,4)
mov    0x48(%rsp),%rax
add    %rdi,%rax
addl   $0x1,(%rax,%rsi,4)
add    %r15,%rdi
mov    (%rdi,%rsi,4),%edi
xor    %eax,%eax
cmp    $0x1,%edi
sete   %al
sub    %eax,%ebx
xor    %eax,%eax
cmp    $0x2,%edi
sete   %al
sub    %eax,%ebx
add    %ecx,%eax
xor    %esi,%esi
cmp    $0x3,%edi
sete   %sil
add    %eax,%esi
xor    %eax,%eax
cmp    $0x4,%edi
sete   %al
add    %eax,%ebx
add    %eax,%esi
xor    %ebp,%ebp
cmp    $0x5,%edi
sete   %bpl
add    %ebx,%ebp
xor    %eax,%eax
cmp    $0x6,%edi
sete   %al
add    %eax,%ebp
sub    %eax,%esi
xor    %eax,%eax
cmp    $0x7,%edi
sete   %al
sub    %eax,%esi
xor    %eax,%eax
cmp    $0x8,%edi
sete   %al
sub    %eax,%ebp
sub    %eax,%esi
movslq %ebp,%rax
movslq %esi,%rbx
imul   $0x7d0,%rax,%rax
add    %r15,%rax
xor    %edi,%edi
cmpl   $0x9,(%rax,%rbx,4)
sete   %dil
test   %r8d,%r8d
jle    1290 <make_accumulation+0x160>
jmp    13de <make_accumulation+0x2ae>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x50(%rsp),%rbp
xor    %r14d,%r14d
mov    0x18(%rsp),%rbx
jmp    1384 <make_accumulation+0x254>
nop
add    $0x4,%r14
add    $0x1f40,%rbp
cmp    %r14,%rbx
je     121a <make_accumulation+0xea>
cmp    $0xffffffff,%r12d
jl     1370 <make_accumulation+0x240>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1030 <memset@plt>
lea    0x7d0(%rbp),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1030 <memset@plt>
lea    0xfa0(%rbp),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1030 <memset@plt>
lea    0x1770(%rbp),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1030 <memset@plt>
jmp    1370 <make_accumulation+0x240>
add    $0xf4298,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bfb(%rip),%rbx
mov    (%rbx),%edi
lea    0xc12(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc25(%rip),%rsi
mov    (%rsp),%rdx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    (%r14),%edx
lea    0xc22(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"LOOP at local_row %d local_col %d\0A\00"
@.str.1 = [25 x i8] c"in gridcell i= %d j= %d\0A\00"
@.str.2 = [17 x i8] c"DATA[i][j] = %d\0A\00"
define void @make_accumulation([500 x i32]* %0, [500 x i32]* %1, i32 %2, i32 %3) {
%5 = alloca [500 x i32]*
%6 = alloca [500 x i32]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [500 x [500 x i32]]
%19 = alloca i32
%20 = alloca i32
store [500 x i32]* %0, [500 x i32]** %5
store [500 x i32]* %1, [500 x i32]** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %17
store i32 1, i32* %9
br label %21
21: ; preds = %271, %4
%22 = load i32, i32* %9
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %274
26: ; preds = %21
store i32 1, i32* %10
br label %27
27: ; preds = %267, %26
%28 = load i32, i32* %10
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %270
32: ; preds = %27
store i32 0, i32* %12
%33 = load [500 x i32]*, [500 x i32]** %5
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [500 x i32], [500 x i32]* %33, i64 %35
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [500 x i32], [500 x i32]* %36, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 9
br i1 %41, label %42, label %43
42: ; preds = %32
store i32 1, i32* %12
br label %43
43: ; preds = %42, %32
%44 = load i32, i32* %12
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %266
46: ; preds = %43
%47 = load i32, i32* %9
store i32 %47, i32* %15
store i32 %47, i32* %13
%48 = load i32, i32* %10
store i32 %48, i32* %16
store i32 %48, i32* %14
store i32 0, i32* %11
store i32 0, i32* %17
store i32 0, i32* %19
br label %49
49: ; preds = %71, %46
%50 = load i32, i32* %19
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 2
%53 = icmp slt i32 %50, %52
br i1 %53, label %54, label %74
54: ; preds = %49
store i32 0, i32* %20
br label %55
55: ; preds = %67, %54
%56 = load i32, i32* %20
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 2
%59 = icmp slt i32 %56, %58
br i1 %59, label %60, label %70
60: ; preds = %55
%61 = load i32, i32* %19
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [500 x [500 x i32]], [500 x [500 x i32]]* %18, i64 0, i64 %62
%64 = load i32, i32* %20
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [500 x i32], [500 x i32]* %63, i64 0, i64 %65
store i32 0, i32* %66
br label %67
67: ; preds = %60
%68 = load i32, i32* %20
%69 = add nsw i32 %68, 1
store i32 %69, i32* %20
br label %55
70: ; preds = %55
br label %71
71: ; preds = %70
%72 = load i32, i32* %19
%73 = add nsw i32 %72, 1
store i32 %73, i32* %19
br label %49
74: ; preds = %49
br label %75
75: ; preds = %262, %74
%76 = load i32, i32* %11
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %265
78: ; preds = %75
%79 = load i32, i32* %13
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [500 x [500 x i32]], [500 x [500 x i32]]* %18, i64 0, i64 %80
%82 = load i32, i32* %14
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [500 x i32], [500 x i32]* %81, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = add nsw i32 %85, 1
%87 = load i32, i32* %13
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [500 x [500 x i32]], [500 x [500 x i32]]* %18, i64 0, i64 %88
%90 = load i32, i32* %14
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [500 x i32], [500 x i32]* %89, i64 0, i64 %91
store i32 %86, i32* %92
%93 = load [500 x i32]*, [500 x i32]** %6
%94 = load i32, i32* %13
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [500 x i32], [500 x i32]* %93, i64 %95
%97 = load i32, i32* %14
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [500 x i32], [500 x i32]* %96, i64 0, i64 %98
%100 = load i32, i32* %99
%101 = add nsw i32 %100, 1
%102 = load [500 x i32]*, [500 x i32]** %6
%103 = load i32, i32* %13
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [500 x i32], [500 x i32]* %102, i64 %104
%106 = load i32, i32* %14
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [500 x i32], [500 x i32]* %105, i64 0, i64 %107
store i32 %101, i32* %108
%109 = load i32, i32* %17
%110 = add nsw i32 %109, 1
store i32 %110, i32* %17
%111 = load [500 x i32]*, [500 x i32]** %5
%112 = load i32, i32* %13
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [500 x i32], [500 x i32]* %111, i64 %113
%115 = load i32, i32* %14
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [500 x i32], [500 x i32]* %114, i64 0, i64 %116
%118 = load i32, i32* %117
%119 = icmp eq i32 %118, 1
br i1 %119, label %120, label %123
120: ; preds = %78
%121 = load i32, i32* %15
%122 = add nsw i32 %121, -1
store i32 %122, i32* %15
br label %123
123: ; preds = %120, %78
%124 = load [500 x i32]*, [500 x i32]** %5
%125 = load i32, i32* %13
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [500 x i32], [500 x i32]* %124, i64 %126
%128 = load i32, i32* %14
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [500 x i32], [500 x i32]* %127, i64 0, i64 %129
%131 = load i32, i32* %130
%132 = icmp eq i32 %131, 2
br i1 %132, label %133, label %138
133: ; preds = %123
%134 = load i32, i32* %15
%135 = add nsw i32 %134, -1
store i32 %135, i32* %15
%136 = load i32, i32* %16
%137 = add nsw i32 %136, 1
store i32 %137, i32* %16
br label %138
138: ; preds = %133, %123
%139 = load [500 x i32]*, [500 x i32]** %5
%140 = load i32, i32* %13
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [500 x i32], [500 x i32]* %139, i64 %141
%143 = load i32, i32* %14
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [500 x i32], [500 x i32]* %142, i64 0, i64 %144
%146 = load i32, i32* %145
%147 = icmp eq i32 %146, 3
br i1 %147, label %148, label %151
148: ; preds = %138
%149 = load i32, i32* %16
%150 = add nsw i32 %149, 1
store i32 %150, i32* %16
br label %151
151: ; preds = %148, %138
%152 = load [500 x i32]*, [500 x i32]** %5
%153 = load i32, i32* %13
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds [500 x i32], [500 x i32]* %152, i64 %154
%156 = load i32, i32* %14
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [500 x i32], [500 x i32]* %155, i64 0, i64 %157
%159 = load i32, i32* %158
%160 = icmp eq i32 %159, 4
br i1 %160, label %161, label %166
161: ; preds = %151
%162 = load i32, i32* %15
%163 = add nsw i32 %162, 1
store i32 %163, i32* %15
%164 = load i32, i32* %16
%165 = add nsw i32 %164, 1
store i32 %165, i32* %16
br label %166
166: ; preds = %161, %151
%167 = load [500 x i32]*, [500 x i32]** %5
%168 = load i32, i32* %13
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [500 x i32], [500 x i32]* %167, i64 %169
%171 = load i32, i32* %14
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [500 x i32], [500 x i32]* %170, i64 0, i64 %172
%174 = load i32, i32* %173
%175 = icmp eq i32 %174, 5
br i1 %175, label %176, label %179
176: ; preds = %166
%177 = load i32, i32* %15
%178 = add nsw i32 %177, 1
store i32 %178, i32* %15
br label %179
179: ; preds = %176, %166
%180 = load [500 x i32]*, [500 x i32]** %5
%181 = load i32, i32* %13
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds [500 x i32], [500 x i32]* %180, i64 %182
%184 = load i32, i32* %14
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds [500 x i32], [500 x i32]* %183, i64 0, i64 %185
%187 = load i32, i32* %186
%188 = icmp eq i32 %187, 6
br i1 %188, label %189, label %194
189: ; preds = %179
%190 = load i32, i32* %15
%191 = add nsw i32 %190, 1
store i32 %191, i32* %15
%192 = load i32, i32* %16
%193 = add nsw i32 %192, -1
store i32 %193, i32* %16
br label %194
194: ; preds = %189, %179
%195 = load [500 x i32]*, [500 x i32]** %5
%196 = load i32, i32* %13
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds [500 x i32], [500 x i32]* %195, i64 %197
%199 = load i32, i32* %14
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds [500 x i32], [500 x i32]* %198, i64 0, i64 %200
%202 = load i32, i32* %201
%203 = icmp eq i32 %202, 7
br i1 %203, label %204, label %207
204: ; preds = %194
%205 = load i32, i32* %16
%206 = add nsw i32 %205, -1
store i32 %206, i32* %16
br label %207
207: ; preds = %204, %194
%208 = load [500 x i32]*, [500 x i32]** %5
%209 = load i32, i32* %13
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [500 x i32], [500 x i32]* %208, i64 %210
%212 = load i32, i32* %14
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [500 x i32], [500 x i32]* %211, i64 0, i64 %213
%215 = load i32, i32* %214
%216 = icmp eq i32 %215, 8
br i1 %216, label %217, label %222
217: ; preds = %207
%218 = load i32, i32* %15
%219 = add nsw i32 %218, -1
store i32 %219, i32* %15
%220 = load i32, i32* %16
%221 = add nsw i32 %220, -1
store i32 %221, i32* %16
br label %222
222: ; preds = %217, %207
%223 = load [500 x i32]*, [500 x i32]** %5
%224 = load i32, i32* %15
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds [500 x i32], [500 x i32]* %223, i64 %225
%227 = load i32, i32* %16
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds [500 x i32], [500 x i32]* %226, i64 0, i64 %228
%230 = load i32, i32* %229
%231 = icmp eq i32 %230, 9
br i1 %231, label %232, label %233
232: ; preds = %222
store i32 1, i32* %11
br label %233
233: ; preds = %232, %222
%234 = load i32, i32* %13
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds [500 x [500 x i32]], [500 x [500 x i32]]* %18, i64 0, i64 %235
%237 = load i32, i32* %14
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [500 x i32], [500 x i32]* %236, i64 0, i64 %238
%240 = load i32, i32* %239
%241 = icmp sgt i32 %240, 1
br i1 %241, label %242, label %262
242: ; preds = %233
%243 = load i32, i32* @stderr
%244 = load i32, i32* %13
%245 = load i32, i32* %14
%246 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %243, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %244, i32 %245)
%247 = load i32, i32* @stderr
%248 = load i32, i32* %9
%249 = load i32, i32* %10
%250 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %247, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %248, i32 %249)
%251 = load i32, i32* @stderr
%252 = load [500 x i32]*, [500 x i32]** %5
%253 = load i32, i32* %9
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds [500 x i32], [500 x i32]* %252, i64 %254
%256 = load i32, i32* %10
%257 = sext i32 %256 to i64
%258 = getelementptr inbounds [500 x i32], [500 x i32]* %255, i64 0, i64 %257
%259 = load i32, i32* %258
%260 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %251, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %259)
store i32 1, i32* %11
%261 = call i32 @exit(i32 0)
unreachable
262: ; preds = %233
%263 = load i32, i32* %15
store i32 %263, i32* %13
%264 = load i32, i32* %16
store i32 %264, i32* %14
br label %75
265: ; preds = %75
br label %266
266: ; preds = %265, %43
br label %267
267: ; preds = %266
%268 = load i32, i32* %10
%269 = add nsw i32 %268, 1
store i32 %269, i32* %10
br label %27
270: ; preds = %27
br label %271
271: ; preds = %270
%272 = load i32, i32* %9
%273 = add nsw i32 %272, 1
store i32 %273, i32* %9
br label %21
274: ; preds = %21
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"LOOP at local_row %d local_col %d\0A\00"
@.str.1 = [25 x i8] c"in gridcell i= %d j= %d\0A\00"
@.str.2 = [17 x i8] c"DATA[i][j] = %d\0A\00"
define void @make_accumulation([500 x i32]* nocapture %0, [500 x i32]* nocapture %1, i32 %2, i32 %3) {
%5 = alloca [500 x [500 x i32]]
%6 = bitcast [500 x [500 x i32]]* %5 to i8*
%7 = icmp slt i32 %2, 1
br i1 %7, label %138, label %8
8: ; preds = %4
%9 = icmp slt i32 %3, 1
%10 = icmp sgt i32 %3, -2
%11 = add i32 %3, 2
%12 = zext i32 %11 to i64
%13 = shl nuw nsw i64 %12, 2
%14 = add nuw i32 %2, 2
%15 = add nsw i32 %3, 1
%16 = add nuw nsw i32 %2, 1
%17 = zext i32 %16 to i64
%18 = zext i32 %15 to i64
%19 = zext i32 %14 to i64
%20 = add nsw i64 %19, -1
%21 = and i64 %19, 3
%22 = icmp ult i64 %20, 3
%23 = and i64 %19, 4294967292
%24 = icmp eq i64 %21, 0
br label %25
25: ; preds = %8, %135
%26 = phi i64 [ 1, %8 ], [ %136, %135 ]
br i1 %9, label %135, label %27
27: ; preds = %25
%28 = trunc i64 %26 to i32
br label %29
29: ; preds = %27, %132
%30 = phi i64 [ 1, %27 ], [ %133, %132 ]
%31 = getelementptr inbounds [500 x i32], [500 x i32]* %0, i64 %26, i64 %30
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 9
br i1 %33, label %132, label %34
34: ; preds = %29
br i1 %22, label %35, label %49
35: ; preds = %64, %34
%36 = phi i64 [ 0, %34 ], [ %65, %64 ]
br i1 %24, label %47, label %37
37: ; preds = %35, %43
%38 = phi i64 [ %44, %43 ], [ %36, %35 ]
%39 = phi i64 [ %45, %43 ], [ 0, %35 ]
br i1 %10, label %40, label %43
40: ; preds = %37
%41 = getelementptr [500 x [500 x i32]], [500 x [500 x i32]]* %5, i64 0, i64 %38, i64 0
%42 = bitcast i32* %41 to i8*
br label %43
43: ; preds = %40, %37
%44 = add nuw nsw i64 %38, 1
%45 = add i64 %39, 1
%46 = icmp eq i64 %45, %21
br i1 %46, label %47, label %37
47: ; preds = %43, %35
%48 = trunc i64 %30 to i32
br label %68
49: ; preds = %34, %64
%50 = phi i64 [ %65, %64 ], [ 0, %34 ]
%51 = phi i64 [ %66, %64 ], [ 0, %34 ]
br i1 %10, label %52, label %64
52: ; preds = %49
%53 = getelementptr [500 x [500 x i32]], [500 x [500 x i32]]* %5, i64 0, i64 %50, i64 0
%54 = bitcast i32* %53 to i8*
%55 = or i64 %50, 1
%56 = getelementptr [500 x [500 x i32]], [500 x [500 x i32]]* %5, i64 0, i64 %55, i64 0
%57 = bitcast i32* %56 to i8*
%58 = or i64 %50, 2
%59 = getelementptr [500 x [500 x i32]], [500 x [500 x i32]]* %5, i64 0, i64 %58, i64 0
%60 = bitcast i32* %59 to i8*
%61 = or i64 %50, 3
%62 = getelementptr [500 x [500 x i32]], [500 x [500 x i32]]* %5, i64 0, i64 %61, i64 0
%63 = bitcast i32* %62 to i8*
br label %64
64: ; preds = %49, %52
%65 = add nuw nsw i64 %50, 4
%66 = add i64 %51, 4
%67 = icmp eq i64 %66, %23
br i1 %67, label %35, label %49
68: ; preds = %47, %73
%69 = phi i32 [ %119, %73 ], [ 0, %47 ]
%70 = phi i32 [ %112, %73 ], [ %28, %47 ]
%71 = phi i32 [ %113, %73 ], [ %48, %47 ]
%72 = icmp eq i32 %69, 0
br i1 %72, label %73, label %132
73: ; preds = %68
%74 = sext i32 %70 to i64
%75 = sext i32 %71 to i64
%76 = getelementptr inbounds [500 x [500 x i32]], [500 x [500 x i32]]* %5, i64 0, i64 %74, i64 %75
%77 = load i32, i32* %76
%78 = add nsw i32 %77, 1
store i32 %78, i32* %76
%79 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 %74, i64 %75
%80 = load i32, i32* %79
%81 = add nsw i32 %80, 1
store i32 %81, i32* %79
%82 = getelementptr inbounds [500 x i32], [500 x i32]* %0, i64 %74, i64 %75
%83 = load i32, i32* %82
%84 = icmp eq i32 %83, 1
%85 = sext i1 %84 to i32
%86 = add nsw i32 %70, %85
%87 = icmp eq i32 %83, 2
%88 = sext i1 %87 to i32
%89 = add nsw i32 %86, %88
%90 = zext i1 %87 to i32
%91 = add nsw i32 %71, %90
%92 = icmp eq i32 %83, 3
%93 = zext i1 %92 to i32
%94 = add nsw i32 %91, %93
%95 = icmp eq i32 %83, 4
%96 = zext i1 %95 to i32
%97 = add nsw i32 %89, %96
%98 = add nsw i32 %94, %96
%99 = icmp eq i32 %83, 5
%100 = zext i1 %99 to i32
%101 = add nsw i32 %97, %100
%102 = icmp eq i32 %83, 6
%103 = zext i1 %102 to i32
%104 = add nsw i32 %101, %103
%105 = sext i1 %102 to i32
%106 = add nsw i32 %98, %105
%107 = icmp eq i32 %83, 7
%108 = sext i1 %107 to i32
%109 = add nsw i32 %106, %108
%110 = icmp eq i32 %83, 8
%111 = sext i1 %110 to i32
%112 = add nsw i32 %104, %111
%113 = add nsw i32 %109, %111
%114 = sext i32 %112 to i64
%115 = sext i32 %113 to i64
%116 = getelementptr inbounds [500 x i32], [500 x i32]* %0, i64 %114, i64 %115
%117 = load i32, i32* %116
%118 = icmp eq i32 %117, 9
%119 = zext i1 %118 to i32
%120 = icmp sgt i32 %77, 0
br i1 %120, label %121, label %68
121: ; preds = %73
%122 = trunc i64 %26 to i32
%123 = trunc i64 %30 to i32
%124 = load i32, i32* @stderr
%125 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %70, i32 %71)
%126 = load i32, i32* @stderr
%127 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %122, i32 %123)
%128 = load i32, i32* @stderr
%129 = load i32, i32* %31
%130 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %129)
%131 = tail call i32 @exit(i32 0)
unreachable
132: ; preds = %68, %29
%133 = add nuw nsw i64 %30, 1
%134 = icmp eq i64 %133, %18
br i1 %134, label %135, label %29
135: ; preds = %132, %25
%136 = add nuw nsw i64 %26, 1
%137 = icmp eq i64 %136, %17
br i1 %137, label %138, label %25
138: ; preds = %135, %4
ret void
}