#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 *, ...);
void write_accumulation(int ACC[500][500], int rows, int cols) {
  int i, j;
  for (i = 1; i < rows + 1; i++) {
    for (j = 1; j < cols + 1; j++) {
      if (ACC[i][j] > 0)
        printf("%d ", ACC[i][j]);
      else
        printf("0 ");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<write_accumulation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11db <write_accumulation+0xcb>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11bf <write_accumulation+0xaf>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    119e <write_accumulation+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x7d0,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ac <write_accumulation+0x9c>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <write_accumulation+0xa1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1141 <write_accumulation+0x31>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <write_accumulation+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_accumulation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
test   %esi,%esi
jle    11d7 <write_accumulation+0xb7>
mov    %rdi,%rbx
mov    0x10(%rsp),%rax
lea    0x1(%rax),%ebp
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
add    $0x7d4,%rbx
add    $0xffffffffffffffff,%rbp
mov    $0x1,%r14d
lea    0xe90(%rip),%r12
lea    0xe8d(%rip),%r13
jmp    119c <write_accumulation+0x7c>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
add    $0x7d0,%rbx
cmp    0x8(%rsp),%r14
je     11d7 <write_accumulation+0xb7>
cmpl   $0x0,0x10(%rsp)
jle    1180 <write_accumulation+0x60>
xor    %r15d,%r15d
jmp    11c3 <write_accumulation+0xa3>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
je     1180 <write_accumulation+0x60>
mov    (%rbx,%r15,4),%esi
test   %esi,%esi
jle    11b0 <write_accumulation+0x90>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ba <write_accumulation+0x9a>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"0 \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @write_accumulation([500 x i32]* %0, i32 %1, i32 %2) {
%4 = alloca [500 x i32]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [500 x i32]* %0, [500 x i32]** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 1, i32* %7
br label %9
9: ; preds = %48, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = add nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %51
14: ; preds = %9
store i32 1, i32* %8
br label %15
15: ; preds = %43, %14
%16 = load i32, i32* %8
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %46
20: ; preds = %15
%21 = load [500 x i32]*, [500 x i32]** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [500 x i32], [500 x i32]* %21, i64 %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [500 x i32], [500 x i32]* %24, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %20
%31 = load [500 x i32]*, [500 x i32]** %4
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [500 x i32], [500 x i32]* %31, i64 %33
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [500 x i32], [500 x i32]* %34, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %42
40: ; preds = %20
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %42
42: ; preds = %40, %30
br label %43
43: ; preds = %42
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %15
46: ; preds = %15
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %9
51: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"0 \00"
define void @write_accumulation([500 x i32]* nocapture %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 1
br i1 %4, label %29, label %5
5: ; preds = %3
%6 = icmp slt i32 %2, 1
%7 = add i32 %2, 1
%8 = add nuw i32 %1, 1
%9 = zext i32 %8 to i64
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %5, %25
%12 = phi i64 [ 1, %5 ], [ %27, %25 ]
br i1 %6, label %25, label %13
13: ; preds = %11, %22
%14 = phi i64 [ %23, %22 ], [ 1, %11 ]
%15 = getelementptr inbounds [500 x i32], [500 x i32]* %0, i64 %12, i64 %14
%16 = load i32, i32* %15
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %22
20: ; preds = %13
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %18, %20
%23 = add nuw nsw i64 %14, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %13
25: ; preds = %22, %11
%26 = tail call i32 @putchar(i32 10)
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %11
29: ; preds = %25, %3
ret void
}