#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*/ matNf_copy(float *, float *, int const);
int /*<<< orphan*/ matNf_getColumn(float *, float const *, int, int const);
int /*<<< orphan*/ matNf_getRow(float *, float const *, int, int const);
float vecNf_dot(float *, float *, int const);
void matNf_mult_matNf_new(float result[], const float matA[],
                          const float matB[], const int n) {
  float tempMatrix[4 * 4];
  float vecA[4], vecB[4];
  for (int i = 0; i < n; i++) {
    matNf_getRow(vecA, matA, i, n);
    for (int j = 0; j < n; j++) {
      matNf_getColumn(vecB, matB, j, n);
      tempMatrix[matN_getIndex(i, j, n)] = vecNf_dot(vecA, vecB, n);
    }
  }
  matNf_copy(result, tempMatrix, n);
}


x86 assembly (clang, -O0):
<matNf_mult_matNf_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122f <matNf_mult_matNf_new+0xdf>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x84(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1060 <matNf_getRow@plt>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1216 <matNf_mult_matNf_new+0xc6>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x88(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1050 <matNf_getColumn@plt>
lea    -0x70(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <vecNf_dot@plt>
movss  %xmm0,-0x8c(%rbp)
ff
mov    -0x84(%rbp),%edi
mov    -0x88(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <matN_getIndex@plt>
movss  -0x8c(%rbp),%xmm0
ff
movss  %xmm0,-0x60(%rbp,%rax,4)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    11a3 <matNf_mult_matNf_new+0x53>
jmp    121b <matNf_mult_matNf_new+0xcb>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1174 <matNf_mult_matNf_new+0x24>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <matNf_copy@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matNf_mult_matNf_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %ecx,%ebx
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
test   %ecx,%ecx
jle    11eb <matNf_mult_matNf_new+0x9b>
mov    %rdx,%r15
xor    %ebp,%ebp
lea    0x30(%rsp),%r13
lea    0x20(%rsp),%r14
mov    %r13,%rdi
mov    0x18(%rsp),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1060 <matNf_getRow@plt>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1050 <matNf_getColumn@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <vecNf_dot@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1070 <matN_getIndex@plt>
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x40(%rsp,%rax,4)
add    $0x1,%r12d
cmp    %r12d,%ebx
jne    11a0 <matNf_mult_matNf_new+0x50>
add    $0x1,%ebp
cmp    %ebx,%ebp
jne    1180 <matNf_mult_matNf_new+0x30>
lea    0x40(%rsp),%rsi
mov    0x10(%rsp),%rdi
mov    %ebx,%edx
call   1040 <matNf_copy@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @matNf_mult_matNf_new(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca [16 x float]
%6 = alloca [4 x float]
%7 = alloca [4 x float]
%8 = bitcast [16 x float]* %5 to i8*
%9 = bitcast [4 x float]* %6 to i8*
%10 = bitcast [4 x float]* %7 to i8*
%11 = icmp sgt i32 %3, 0
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = getelementptr inbounds [4 x float], [4 x float]* %6, i64 0, i64 0
%14 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
br label %18
15: ; preds = %21, %4
%16 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 0
%17 = call i32 @matNf_copy(float* %0, float* %16, i32 %3)
ret void
18: ; preds = %21, %12
%19 = phi i32 [ 0, %12 ], [ %22, %21 ]
%20 = call i32 @matNf_getRow(float* %13, float* %1, i32 %19, i32 %3)
br label %24
21: ; preds = %24
%22 = add nuw nsw i32 %19, 1
%23 = icmp eq i32 %22, %3
br i1 %23, label %15, label %18
24: ; preds = %18, %24
%25 = phi i32 [ %30, %24 ], [ 0, %18 ]
%26 = call i32 @matNf_getColumn(float* %14, float* %2, i32 %25, i32 %3)
%27 = call float @vecNf_dot(float* %13, float* %14, i32 %3)
%28 = call i64 @matN_getIndex(i32 %19, i32 %25, i32 %3)
%29 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 %28
store float %27, float* %29
%30 = add nuw nsw i32 %25, 1
%31 = icmp eq i32 %30, %3
br i1 %31, label %21, label %24
}