#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*/ vecNf_copy(float *, float *, int const);
void matNf_mult_vecNf_new(float result[], const float m[], const float v[],
                          const int n) {
  float 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];
  }
  vecNf_copy(result, tmp, n);
}


x86 assembly (clang, -O0):
<matNf_mult_vecNf_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d2 <matNf_mult_vecNf_new+0xb2>
movslq -0x64(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,-0x60(%rbp,%rax,4)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bf <matNf_mult_vecNf_new+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <matN_getIndex@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x68(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movslq -0x64(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x60(%rbp,%rax,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    115e <matNf_mult_vecNf_new+0x3e>
jmp    11c4 <matNf_mult_vecNf_new+0xa4>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    113e <matNf_mult_vecNf_new+0x1e>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <vecNf_copy@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matNf_mult_vecNf_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %ecx,%r15d
mov    %rdi,0x8(%rsp)
test   %ecx,%ecx
jle    11ad <matNf_mult_vecNf_new+0x8d>
mov    %rdx,%r12
mov    %rsi,%r13
mov    %r15d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movl   $0x0,0x10(%rsp,%rbp,4)
xorps  %xmm0,%xmm0
xor    %r14d,%r14d
xchg   %ax,%ax
movss  %xmm0,0x4(%rsp)
mov    %ebp,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <matN_getIndex@plt>
movss  0x0(%r13,%rax,4),%xmm0
mulss  (%r12,%r14,4),%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x10(%rsp,%rbp,4)
add    $0x1,%r14
cmp    %r14,%rbx
jne    1160 <matNf_mult_vecNf_new+0x40>
add    $0x1,%rbp
cmp    %rbx,%rbp
jne    1150 <matNf_mult_vecNf_new+0x30>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdi
mov    %r15d,%edx
call   1030 <vecNf_copy@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @matNf_mult_vecNf_new(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32
%9 = alloca [16 x float]
%10 = alloca i32
%11 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %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 float], [16 x float]* %9, i64 0, i64 %18
store float 0.000000e+00, float* %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 float*, float** %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 float, float* %25, i64 %29
%31 = load float, float* %30
%32 = load float*, float** %7
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
%36 = load float, float* %35
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [16 x float], [16 x float]* %9, i64 0, i64 %38
%40 = load float, float* %39
%41 = call float @llvm.fmuladd.f32(float %31, float %36, float %40)
store float %41, float* %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 float*, float** %5
%51 = getelementptr inbounds [16 x float], [16 x float]* %9, i64 0, i64 0
%52 = load i32, i32* %8
%53 = call i32 @vecNf_copy(float* %50, float* %51, i32 %52)
ret void
}

LLVM IR (-O2):
define void @matNf_mult_vecNf_new(float* %0, float* nocapture %1, float* nocapture %2, i32 %3) {
%5 = alloca [16 x float]
%6 = bitcast [16 x float]* %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 float], [16 x float]* %5, i64 0, i64 0
%12 = call i32 @vecNf_copy(float* %0, float* %11, i32 %3)
ret void
13: ; preds = %17, %8
%14 = phi i64 [ 0, %8 ], [ %18, %17 ]
%15 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 %14
store float 0.000000e+00, float* %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 float [ 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 float, float* %1, i64 %24
%26 = load float, float* %25
%27 = getelementptr inbounds float, float* %2, i64 %22
%28 = load float, float* %27
%29 = tail call float @llvm.fmuladd.f32(float %26, float %28, float %21)
store float %29, float* %15
%30 = add nuw nsw i64 %22, 1
%31 = icmp eq i64 %30, %9
br i1 %31, label %17, label %20
}