#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*/ vvp(double *, double *, double *, int);
int /*<<< orphan*/ vzero(double *, int);
void sum2D(double *a, double **b, int nrows, int ncols) {
  int x;
  vzero(a, ncols);
  for (x = 0; x < nrows; ++x) {
    vvp(a, a, b[x], ncols);
  }
}


x86 assembly (clang, -O0):
<sum2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <vzero@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117f <sum2D+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%ecx
call   1030 <vvp@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <sum2D+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum2D>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %ecx,%esi
call   1040 <vzero@plt>
test   %r15d,%r15d
jle    116b <sum2D+0x4b>
mov    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbp,8),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r12d,%ecx
call   1030 <vvp@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1150 <sum2D+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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