#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*/ arrayAdd(int, double *, double *, double *);
void matrixAdd(int m, int n, double **left, double **right, double **sum) {
  int j;
  for (j = 0; j < m; j++) {
    arrayAdd(n, left[j], right[j], sum[j]);
  }
}


x86 assembly (clang, -O0):
<matrixAdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1177 <matrixAdd+0x67>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
call   1030 <arrayAdd@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <matrixAdd+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixAdd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    114d <matrixAdd+0x3d>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %esi,%r13d
mov    %edi,%ebx
xor    %ebp,%ebp
nop
mov    (%r12,%rbp,8),%rsi
mov    (%r15,%rbp,8),%rdx
mov    (%r14,%rbp,8),%rcx
mov    %r13d,%edi
call   1030 <arrayAdd@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <matrixAdd+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @matrixAdd(i32 %0, i32 %1, double** nocapture %2, double** nocapture %3, double** nocapture %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %20
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %18, %9 ]
%11 = getelementptr inbounds double*, double** %2, i64 %10
%12 = load double*, double** %11
%13 = getelementptr inbounds double*, double** %3, i64 %10
%14 = load double*, double** %13
%15 = getelementptr inbounds double*, double** %4, i64 %10
%16 = load double*, double** %15
%17 = tail call i32 @arrayAdd(i32 %1, double* %12, double* %14, double* %16)
%18 = add nuw nsw i64 %10, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %20, label %9
20: ; preds = %9, %5
ret void
}