#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);
int compute_sum(int A[][4], int row_size, int col_size) {
  int index_1, index_2;
  int sum;
  sum = 0;
  for (index_1 = 0; index_1 < row_size; ++index_1) {
    for (index_2 = 0; index_2 < col_size; ++index_2) {
      sum += A[index_1][index_2];
      printf("SUM is %d\n", sum);
    }
  }
  return (sum);
}


x86 assembly (clang, -O0):
<compute_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119b <compute_sum+0x8b>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1188 <compute_sum+0x78>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <compute_sum+0x33>
jmp    118d <compute_sum+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <compute_sum+0x20>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_sum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1189 <compute_sum+0x79>
mov    %rdi,%rbx
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    %edx,%r13d
xor    %r14d,%r14d
lea    0xec7(%rip),%r15
xor    %ebp,%ebp
mov    %edx,0xc(%rsp)
jmp    1163 <compute_sum+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
add    $0x10,%rbx
cmp    0x10(%rsp),%r14
mov    0xc(%rsp),%edx
je     118b <compute_sum+0x7b>
test   %edx,%edx
jle    1150 <compute_sum+0x40>
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
add    (%rbx,%r12,4),%ebp
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r13
jne    1170 <compute_sum+0x60>
jmp    1150 <compute_sum+0x40>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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