void glmMultMatrix5d(double result[25], const double m1[25],
                     const double m2[25]) {
  double sum;
  int x, y, i;
  for (x = 0; x < 5; x++) {
    for (y = 0; y < 5; y++) {
      sum = 0;
      for (i = 0; i < 5; i++)
        sum += m1[y + 5 * i] * m2[5 * x + i];
      result[y + 5 * x] = sum;
    }
  }
}


x86 assembly (clang, -O0):
<glmMultMatrix5d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11ce <glmMultMatrix5d+0xce>
movl   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x28(%rbp)
jge    11bb <glmMultMatrix5d+0xbb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x2c(%rbp)
jge    1193 <glmMultMatrix5d+0x93>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   $0x5,-0x2c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x5,-0x24(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1141 <glmMultMatrix5d+0x41>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   $0x5,-0x24(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1128 <glmMultMatrix5d+0x28>
jmp    11c0 <glmMultMatrix5d+0xc0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1117 <glmMultMatrix5d+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmMultMatrix5d>:
mov    $0x20,%eax
xorpd  %xmm0,%xmm0
nopl   0x0(%rax)
movsd  (%rsi),%xmm1
mulsd  -0x20(%rdx,%rax,1),%xmm1
movsd  0x28(%rsi),%xmm2
addsd  %xmm0,%xmm1
mulsd  -0x18(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0x50(%rsi),%xmm1
mulsd  -0x10(%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  0x78(%rsi),%xmm2
mulsd  -0x8(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0xa0(%rsi),%xmm1
mulsd  (%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,-0x20(%rdi,%rax,1)
movsd  0x8(%rsi),%xmm1
movsd  0x30(%rsi),%xmm2
mulsd  -0x20(%rdx,%rax,1),%xmm1
mulsd  -0x18(%rdx,%rax,1),%xmm2
addsd  %xmm0,%xmm1
movsd  0x58(%rsi),%xmm3
mulsd  -0x10(%rdx,%rax,1),%xmm3
addsd  %xmm1,%xmm2
movsd  0x80(%rsi),%xmm1
mulsd  -0x8(%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm3
movsd  0xa8(%rsi),%xmm2
mulsd  (%rdx,%rax,1),%xmm2
addsd  %xmm3,%xmm1
addsd  %xmm1,%xmm2
movsd  %xmm2,-0x18(%rdi,%rax,1)
movsd  0x10(%rsi),%xmm1
movsd  0x38(%rsi),%xmm2
mulsd  -0x20(%rdx,%rax,1),%xmm1
addsd  %xmm0,%xmm1
mulsd  -0x18(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0x60(%rsi),%xmm1
mulsd  -0x10(%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  0x88(%rsi),%xmm2
mulsd  -0x8(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0xb0(%rsi),%xmm1
mulsd  (%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,-0x10(%rdi,%rax,1)
movsd  0x18(%rsi),%xmm1
movsd  0x40(%rsi),%xmm2
mulsd  -0x20(%rdx,%rax,1),%xmm1
addsd  %xmm0,%xmm1
mulsd  -0x18(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0x68(%rsi),%xmm1
mulsd  -0x10(%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  0x90(%rsi),%xmm2
mulsd  -0x8(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0xb8(%rsi),%xmm1
mulsd  (%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,-0x8(%rdi,%rax,1)
movsd  0x20(%rsi),%xmm1
mulsd  -0x20(%rdx,%rax,1),%xmm1
movsd  0x48(%rsi),%xmm2
addsd  %xmm0,%xmm1
mulsd  -0x18(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0x70(%rsi),%xmm1
mulsd  -0x10(%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  0x98(%rsi),%xmm2
mulsd  -0x8(%rdx,%rax,1),%xmm2
addsd  %xmm1,%xmm2
movsd  0xc0(%rsi),%xmm1
mulsd  (%rdx,%rax,1),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rdi,%rax,1)
add    $0x28,%rax
cmp    $0xe8,%rax
jne    1110 <glmMultMatrix5d+0x10>
ret

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

LLVM IR (-O2):
define void @glmMultMatrix5d(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %1, i64 4
%5 = getelementptr inbounds double, double* %1, i64 5
%6 = getelementptr inbounds double, double* %1, i64 10
%7 = getelementptr inbounds double, double* %1, i64 15
%8 = getelementptr inbounds double, double* %1, i64 20
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = getelementptr inbounds double, double* %1, i64 6
%11 = getelementptr inbounds double, double* %1, i64 11
%12 = getelementptr inbounds double, double* %1, i64 16
%13 = getelementptr inbounds double, double* %1, i64 21
%14 = getelementptr inbounds double, double* %1, i64 2
%15 = getelementptr inbounds double, double* %1, i64 7
%16 = getelementptr inbounds double, double* %1, i64 12
%17 = getelementptr inbounds double, double* %1, i64 17
%18 = getelementptr inbounds double, double* %1, i64 22
%19 = getelementptr inbounds double, double* %1, i64 3
%20 = getelementptr inbounds double, double* %1, i64 8
%21 = getelementptr inbounds double, double* %1, i64 13
%22 = getelementptr inbounds double, double* %1, i64 18
%23 = getelementptr inbounds double, double* %1, i64 23
%24 = getelementptr inbounds double, double* %1, i64 9
%25 = getelementptr inbounds double, double* %1, i64 14
%26 = getelementptr inbounds double, double* %1, i64 19
%27 = getelementptr inbounds double, double* %1, i64 24
br label %28
28: ; preds = %3, %28
%29 = phi i64 [ 0, %3 ], [ %120, %28 ]
%30 = mul nuw nsw i64 %29, 5
%31 = load double, double* %1
%32 = getelementptr inbounds double, double* %2, i64 %30
%33 = load double, double* %32
%34 = tail call double @llvm.fmuladd.f64(double %31, double %33, double 0.000000e+00)
%35 = load double, double* %5
%36 = add nuw nsw i64 %30, 1
%37 = getelementptr inbounds double, double* %2, i64 %36
%38 = load double, double* %37
%39 = tail call double @llvm.fmuladd.f64(double %35, double %38, double %34)
%40 = load double, double* %6
%41 = add nuw nsw i64 %30, 2
%42 = getelementptr inbounds double, double* %2, i64 %41
%43 = load double, double* %42
%44 = tail call double @llvm.fmuladd.f64(double %40, double %43, double %39)
%45 = load double, double* %7
%46 = add nuw nsw i64 %30, 3
%47 = getelementptr inbounds double, double* %2, i64 %46
%48 = load double, double* %47
%49 = tail call double @llvm.fmuladd.f64(double %45, double %48, double %44)
%50 = load double, double* %8
%51 = add nuw nsw i64 %30, 4
%52 = getelementptr inbounds double, double* %2, i64 %51
%53 = load double, double* %52
%54 = tail call double @llvm.fmuladd.f64(double %50, double %53, double %49)
%55 = getelementptr inbounds double, double* %0, i64 %30
store double %54, double* %55
%56 = load double, double* %9
%57 = load double, double* %32
%58 = tail call double @llvm.fmuladd.f64(double %56, double %57, double 0.000000e+00)
%59 = load double, double* %10
%60 = load double, double* %37
%61 = tail call double @llvm.fmuladd.f64(double %59, double %60, double %58)
%62 = load double, double* %11
%63 = load double, double* %42
%64 = tail call double @llvm.fmuladd.f64(double %62, double %63, double %61)
%65 = load double, double* %12
%66 = load double, double* %47
%67 = tail call double @llvm.fmuladd.f64(double %65, double %66, double %64)
%68 = load double, double* %13
%69 = load double, double* %52
%70 = tail call double @llvm.fmuladd.f64(double %68, double %69, double %67)
%71 = getelementptr inbounds double, double* %0, i64 %36
store double %70, double* %71
%72 = load double, double* %14
%73 = load double, double* %32
%74 = tail call double @llvm.fmuladd.f64(double %72, double %73, double 0.000000e+00)
%75 = load double, double* %15
%76 = load double, double* %37
%77 = tail call double @llvm.fmuladd.f64(double %75, double %76, double %74)
%78 = load double, double* %16
%79 = load double, double* %42
%80 = tail call double @llvm.fmuladd.f64(double %78, double %79, double %77)
%81 = load double, double* %17
%82 = load double, double* %47
%83 = tail call double @llvm.fmuladd.f64(double %81, double %82, double %80)
%84 = load double, double* %18
%85 = load double, double* %52
%86 = tail call double @llvm.fmuladd.f64(double %84, double %85, double %83)
%87 = getelementptr inbounds double, double* %0, i64 %41
store double %86, double* %87
%88 = load double, double* %19
%89 = load double, double* %32
%90 = tail call double @llvm.fmuladd.f64(double %88, double %89, double 0.000000e+00)
%91 = load double, double* %20
%92 = load double, double* %37
%93 = tail call double @llvm.fmuladd.f64(double %91, double %92, double %90)
%94 = load double, double* %21
%95 = load double, double* %42
%96 = tail call double @llvm.fmuladd.f64(double %94, double %95, double %93)
%97 = load double, double* %22
%98 = load double, double* %47
%99 = tail call double @llvm.fmuladd.f64(double %97, double %98, double %96)
%100 = load double, double* %23
%101 = load double, double* %52
%102 = tail call double @llvm.fmuladd.f64(double %100, double %101, double %99)
%103 = getelementptr inbounds double, double* %0, i64 %46
store double %102, double* %103
%104 = load double, double* %4
%105 = load double, double* %32
%106 = tail call double @llvm.fmuladd.f64(double %104, double %105, double 0.000000e+00)
%107 = load double, double* %24
%108 = load double, double* %37
%109 = tail call double @llvm.fmuladd.f64(double %107, double %108, double %106)
%110 = load double, double* %25
%111 = load double, double* %42
%112 = tail call double @llvm.fmuladd.f64(double %110, double %111, double %109)
%113 = load double, double* %26
%114 = load double, double* %47
%115 = tail call double @llvm.fmuladd.f64(double %113, double %114, double %112)
%116 = load double, double* %27
%117 = load double, double* %52
%118 = tail call double @llvm.fmuladd.f64(double %116, double %117, double %115)
%119 = getelementptr inbounds double, double* %0, i64 %51
store double %118, double* %119
%120 = add nuw nsw i64 %29, 1
%121 = icmp eq i64 %120, 5
br i1 %121, label %122, label %28
122: ; preds = %28
ret void
}