void glmGenerateInertiaMatrixForTorus4d(double m[16], double a, double c,
                                        double mass) {
  m[0] = 0.125 * (5 * a * a + 4 * c * c) * mass;
  m[4] = 0;
  m[8] = 0;
  m[12] = 0;
  m[1] = 0;
  m[5] = 0.125 * (5 * a * a + 4 * c * c) * mass;
  m[9] = 0;
  m[13] = 0;
  m[2] = 0;
  m[6] = 0;
  m[10] = (0.75 * a * a + c * c) * mass;
  m[14] = 0;
  m[3] = 0;
  m[7] = 0;
  m[11] = 0;
  m[15] = 1;
}


x86 assembly (clang, -O0):
<glmGenerateInertiaMatrixForTorus4d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  0xf01(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xee7(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xec5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x40(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x60(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  0xe8c(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xe72(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe50(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x48(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x68(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
movsd  0xdfe(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x50(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x70(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x58(%rax)
mov    -0x8(%rbp),%rax
movsd  0xd90(%rip),%xmm0
movsd  %xmm0,0x78(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmGenerateInertiaMatrixForTorus4d>:
movsd  0xef8(%rip),%xmm3
mulsd  %xmm0,%xmm3
movsd  0xef4(%rip),%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm0,%xmm3
addsd  %xmm4,%xmm3
mulsd  0xee4(%rip),%xmm3
mulsd  %xmm2,%xmm3
movsd  %xmm3,(%rdi)
movsd  %xmm3,0x28(%rdi)
xorpd  %xmm3,%xmm3
movupd %xmm3,0x40(%rdi)
movupd %xmm3,0x8(%rdi)
movsd  0xec9(%rip),%xmm4
mulsd  %xmm0,%xmm4
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm4
addsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
movsd  %xmm4,0x50(%rdi)
movupd %xmm3,0x68(%rdi)
movupd %xmm3,0x18(%rdi)
movupd %xmm3,0x30(%rdi)
movupd %xmm3,0x58(%rdi)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x78(%rdi)
ret

LLVM IR (-O0):
define void @glmGenerateInertiaMatrixForTorus4d(double* %0, double %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %6
%10 = fmul double 5.000000e+00, %9
%11 = load double, double* %6
%12 = load double, double* %7
%13 = fmul double 4.000000e+00, %12
%14 = load double, double* %7
%15 = fmul double %13, %14
%16 = call double @llvm.fmuladd.f64(double %10, double %11, double %15)
%17 = fmul double 1.250000e-01, %16
%18 = load double, double* %8
%19 = fmul double %17, %18
%20 = load double*, double** %5
%21 = getelementptr inbounds double, double* %20, i64 0
store double %19, double* %21
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 4
store double 0.000000e+00, double* %23
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i64 8
store double 0.000000e+00, double* %25
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 12
store double 0.000000e+00, double* %27
%28 = load double*, double** %5
%29 = getelementptr inbounds double, double* %28, i64 1
store double 0.000000e+00, double* %29
%30 = load double, double* %6
%31 = fmul double 5.000000e+00, %30
%32 = load double, double* %6
%33 = load double, double* %7
%34 = fmul double 4.000000e+00, %33
%35 = load double, double* %7
%36 = fmul double %34, %35
%37 = call double @llvm.fmuladd.f64(double %31, double %32, double %36)
%38 = fmul double 1.250000e-01, %37
%39 = load double, double* %8
%40 = fmul double %38, %39
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 5
store double %40, double* %42
%43 = load double*, double** %5
%44 = getelementptr inbounds double, double* %43, i64 9
store double 0.000000e+00, double* %44
%45 = load double*, double** %5
%46 = getelementptr inbounds double, double* %45, i64 13
store double 0.000000e+00, double* %46
%47 = load double*, double** %5
%48 = getelementptr inbounds double, double* %47, i64 2
store double 0.000000e+00, double* %48
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 6
store double 0.000000e+00, double* %50
%51 = load double, double* %6
%52 = fmul double 7.500000e-01, %51
%53 = load double, double* %6
%54 = load double, double* %7
%55 = load double, double* %7
%56 = fmul double %54, %55
%57 = call double @llvm.fmuladd.f64(double %52, double %53, double %56)
%58 = load double, double* %8
%59 = fmul double %57, %58
%60 = load double*, double** %5
%61 = getelementptr inbounds double, double* %60, i64 10
store double %59, double* %61
%62 = load double*, double** %5
%63 = getelementptr inbounds double, double* %62, i64 14
store double 0.000000e+00, double* %63
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 3
store double 0.000000e+00, double* %65
%66 = load double*, double** %5
%67 = getelementptr inbounds double, double* %66, i64 7
store double 0.000000e+00, double* %67
%68 = load double*, double** %5
%69 = getelementptr inbounds double, double* %68, i64 11
store double 0.000000e+00, double* %69
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 15
store double 1.000000e+00, double* %71
ret void
}

LLVM IR (-O2):
define void @glmGenerateInertiaMatrixForTorus4d(double* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = fmul double %1, 5.000000e+00
%6 = fmul double %2, 4.000000e+00
%7 = fmul double %6, %2
%8 = tail call double @llvm.fmuladd.f64(double %5, double %1, double %7)
%9 = fmul double %8, 1.250000e-01
%10 = fmul double %9, %3
store double %10, double* %0
%11 = getelementptr inbounds double, double* %0, i64 8
%12 = getelementptr inbounds double, double* %0, i64 1
%13 = getelementptr inbounds double, double* %0, i64 5
store double %10, double* %13
%14 = bitcast double* %11 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %14
%15 = getelementptr inbounds double, double* %0, i64 13
%16 = bitcast double* %12 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %16
%17 = getelementptr inbounds double, double* %0, i64 6
%18 = fmul double %1, 7.500000e-01
%19 = fmul double %2, %2
%20 = tail call double @llvm.fmuladd.f64(double %18, double %1, double %19)
%21 = fmul double %20, %3
%22 = getelementptr inbounds double, double* %0, i64 10
store double %21, double* %22
%23 = bitcast double* %15 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %23
%24 = getelementptr inbounds double, double* %0, i64 3
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %25
%26 = bitcast double* %17 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %26
%27 = getelementptr inbounds double, double* %0, i64 11
%28 = bitcast double* %27 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %28
%29 = getelementptr inbounds double, double* %0, i64 15
store double 1.000000e+00, double* %29
ret void
}