#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 */
double A(int, int);
void mult_Av(double *v, double *out, const int n) {
  int i, j;
  double sum;
#pragma omp parallel for private(sum, j)
  for (i = 0; i < n; i++) {
    for (sum = j = 0; j < n; j++)
      sum += v[j] / A(i, j);
    out[i] = sum;
  }
}


x86 assembly (clang, -O0):
<mult_Av>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <mult_Av+0xa2>
movl   $0x0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1192 <mult_Av+0x82>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <A@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <mult_Av+0x35>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <mult_Av+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult_Av>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    1186 <mult_Av+0x76>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r13d
xor    %r12d,%r12d
nopl   (%rax)
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
mov    %r12d,%edi
mov    %ebx,%esi
call   1030 <A@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <mult_Av+0x30>
movsd  %xmm0,(%r14,%r12,8)
add    $0x1,%r12
cmp    %r13,%r12
jne    1130 <mult_Av+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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