#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 */
size_t matN_getIndex(int, int, int const);
void vecNd_mult_vecNd(double m[], const double A[], const double B[],
                      const int n) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      m[matN_getIndex(i, j, n)] = A[i] * B[j];
    }
  }
}


x86 assembly (clang, -O0):
<vecNd_mult_vecNd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b4 <vecNd_mult_vecNd+0xa4>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a1 <vecNd_mult_vecNd+0x91>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <matN_getIndex@plt>
movsd  -0x38(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <vecNd_mult_vecNd+0x31>
jmp    11a6 <vecNd_mult_vecNd+0x96>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <vecNd_mult_vecNd+0x1e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vecNd_mult_vecNd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    117a <vecNd_mult_vecNd+0x6a>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%r13d
xor    %ebx,%ebx
nopl   (%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r15,%rbx,8),%xmm0
mulsd  (%r14,%rbp,8),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r13d,%edx
call   1030 <matN_getIndex@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r12,%rax,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1140 <vecNd_mult_vecNd+0x30>
add    $0x1,%rbx
cmp    %r13,%rbx
jne    1130 <vecNd_mult_vecNd+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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