#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 GetDataSize();
double CalculateV(double **dm, double *lineSum, int i) {
  double v = 0;
  int j;
  for (j = 0; j < GetDataSize(); ++j) {
    v += dm[i][j] / lineSum[j];
  }
  return v;
}


x86 assembly (clang, -O0):
<CalculateV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <GetDataSize@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    1186 <CalculateV+0x76>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <CalculateV+0x22>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateV>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <GetDataSize@plt>
test   %eax,%eax
jle    1171 <CalculateV+0x61>
movslq %ebp,%rbp
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbp,8),%rax
movsd  (%rax,%rbx,8),%xmm1
divsd  (%r14,%rbx,8),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
add    $0x1,%rbx
xor    %eax,%eax
call   1030 <GetDataSize@plt>
movsd  (%rsp),%xmm0
cltq
cmp    %rax,%rbx
jl     1140 <CalculateV+0x30>
jmp    1175 <CalculateV+0x65>
xorpd  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @CalculateV(double** nocapture %0, double* nocapture %1, i32 %2) {
%4 = tail call i32 (...) @GetDataSize()
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds double*, double** %0, i64 %7
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %19, %9 ]
%11 = phi double [ 0.000000e+00, %6 ], [ %18, %9 ]
%12 = load double*, double** %8
%13 = getelementptr inbounds double, double* %12, i64 %10
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 %10
%16 = load double, double* %15
%17 = fdiv double %14, %16
%18 = fadd double %11, %17
%19 = add nuw nsw i64 %10, 1
%20 = tail call i32 (...) @GetDataSize()
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %9, label %23
23: ; preds = %9, %3
%24 = phi double [ 0.000000e+00, %3 ], [ %18, %9 ]
ret double %24
}