#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);
int /*<<< orphan*/ vecNd_copy(double *, double *, int const);
void matNd_mult_vecNd_new(double result[], const double m[], const double v[],
                          const int n) {
  double tmp[4 * 4];
  for (int i = 0; i < n; i++) {
    tmp[i] = 0;
    for (int j = 0; j < n; j++)
      tmp[i] += m[matN_getIndex(i, j, n)] * v[j];
  }
  vecNd_copy(result, tmp, n);
}


x86 assembly (clang, -O0):
<matNd_mult_vecNd_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120b <matNd_mult_vecNd_new+0xeb>
movslq -0xa4(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f2 <matNd_mult_vecNd_new+0xd2>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0xa4(%rbp),%edi
mov    -0xa8(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <matN_getIndex@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movslq -0xa4(%rbp),%rax
movsd  -0xa0(%rbp,%rax,8),%xmm1
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    1170 <matNd_mult_vecNd_new+0x50>
jmp    11f7 <matNd_mult_vecNd_new+0xd7>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1144 <matNd_mult_vecNd_new+0x24>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <vecNd_copy@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matNd_mult_vecNd_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %ecx,%r15d
mov    %rdi,0x8(%rsp)
test   %ecx,%ecx
jle    11a9 <matNd_mult_vecNd_new+0x89>
mov    %rdx,%r12
mov    %rsi,%r13
mov    %r15d,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movq   $0x0,0x10(%rsp,%rbp,8)
xorps  %xmm0,%xmm0
xor    %r14d,%r14d
nop
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <matN_getIndex@plt>
movsd  0x0(%r13,%rax,8),%xmm0
mulsd  (%r12,%r14,8),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp,%rbp,8)
add    $0x1,%r14
cmp    %r14,%rbx
jne    1160 <matNd_mult_vecNd_new+0x40>
add    $0x1,%rbp
cmp    %rbx,%rbp
jne    1150 <matNd_mult_vecNd_new+0x30>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdi
mov    %r15d,%edx
call   1030 <vecNd_copy@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @matNd_mult_vecNd_new(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca [16 x double]
%10 = alloca i32
%11 = 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* %10
br label %12
12: ; preds = %46, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %8
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %49
16: ; preds = %12
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x double], [16 x double]* %9, i64 0, i64 %18
store double 0.000000e+00, double* %19
store i32 0, i32* %11
br label %20
20: ; preds = %42, %16
%21 = load i32, i32* %11
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %45
24: ; preds = %20
%25 = load double*, double** %6
%26 = load i32, i32* %10
%27 = load i32, i32* %11
%28 = load i32, i32* %8
%29 = call i64 @matN_getIndex(i32 %26, i32 %27, i32 %28)
%30 = getelementptr inbounds double, double* %25, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %7
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [16 x double], [16 x double]* %9, i64 0, i64 %38
%40 = load double, double* %39
%41 = call double @llvm.fmuladd.f64(double %31, double %36, double %40)
store double %41, double* %39
br label %42
42: ; preds = %24
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %20
45: ; preds = %20
br label %46
46: ; preds = %45
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %12
49: ; preds = %12
%50 = load double*, double** %5
%51 = getelementptr inbounds [16 x double], [16 x double]* %9, i64 0, i64 0
%52 = load i32, i32* %8
%53 = call i32 @vecNd_copy(double* %50, double* %51, i32 %52)
ret void
}

LLVM IR (-O2):
define void @matNd_mult_vecNd_new(double* %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = alloca [16 x double]
%6 = bitcast [16 x double]* %5 to i8*
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = zext i32 %3 to i64
br label %13
10: ; preds = %17, %4
%11 = getelementptr inbounds [16 x double], [16 x double]* %5, i64 0, i64 0
%12 = call i32 @vecNd_copy(double* %0, double* %11, i32 %3)
ret void
13: ; preds = %17, %8
%14 = phi i64 [ 0, %8 ], [ %18, %17 ]
%15 = getelementptr inbounds [16 x double], [16 x double]* %5, i64 0, i64 %14
store double 0.000000e+00, double* %15
%16 = trunc i64 %14 to i32
br label %20
17: ; preds = %20
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %10, label %13
20: ; preds = %13, %20
%21 = phi double [ 0.000000e+00, %13 ], [ %29, %20 ]
%22 = phi i64 [ 0, %13 ], [ %30, %20 ]
%23 = trunc i64 %22 to i32
%24 = tail call i64 @matN_getIndex(i32 %16, i32 %23, i32 %3)
%25 = getelementptr inbounds double, double* %1, i64 %24
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %2, i64 %22
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double %28, double %21)
store double %29, double* %15
%30 = add nuw nsw i64 %22, 1
%31 = icmp eq i64 %30, %9
br i1 %31, label %17, label %20
}