void glmGenerateInertiaMatrixForBox3d(double m[9], double x, double y, double z,
                                      double mass) {
  mass /= 12.0f;
  m[0] = mass * (y * y + z * z);
  m[3] = 0;
  m[6] = 0;
  m[1] = 0;
  m[4] = mass * (x * x + z * z);
  m[7] = 0;
  m[2] = 0;
  m[5] = 0;
  m[8] = mass * (x * x + y * y);
}


x86 assembly (clang, -O0):
<glmGenerateInertiaMatrixForBox3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xed7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
mulsd  -0x20(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
mulsd  -0x20(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmGenerateInertiaMatrixForBox3d>:
divsd  0xef8(%rip),%xmm3
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
movapd %xmm1,%xmm4
addsd  %xmm2,%xmm4
mulsd  %xmm3,%xmm4
movsd  %xmm4,(%rdi)
movq   $0x0,0x18(%rdi)
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm2
movsd  %xmm2,0x20(%rdi)
movq   $0x0,0x38(%rdi)
xorpd  %xmm2,%xmm2
movupd %xmm2,0x8(%rdi)
movupd %xmm2,0x28(%rdi)
addsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x40(%rdi)
ret

LLVM IR (-O0):
define void @glmGenerateInertiaMatrixForBox3d(double* %0, double %1, double %2, double %3, double %4) {
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%11 = load double, double* %10
%12 = fdiv double %11, 1.200000e+01
store double %12, double* %10
%13 = load double, double* %10
%14 = load double, double* %8
%15 = load double, double* %8
%16 = load double, double* %9
%17 = load double, double* %9
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = fmul double %13, %19
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 0
store double %20, double* %22
%23 = load double*, double** %6
%24 = getelementptr inbounds double, double* %23, i64 3
store double 0.000000e+00, double* %24
%25 = load double*, double** %6
%26 = getelementptr inbounds double, double* %25, i64 6
store double 0.000000e+00, double* %26
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 1
store double 0.000000e+00, double* %28
%29 = load double, double* %10
%30 = load double, double* %7
%31 = load double, double* %7
%32 = load double, double* %9
%33 = load double, double* %9
%34 = fmul double %32, %33
%35 = call double @llvm.fmuladd.f64(double %30, double %31, double %34)
%36 = fmul double %29, %35
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 4
store double %36, double* %38
%39 = load double*, double** %6
%40 = getelementptr inbounds double, double* %39, i64 7
store double 0.000000e+00, double* %40
%41 = load double*, double** %6
%42 = getelementptr inbounds double, double* %41, i64 2
store double 0.000000e+00, double* %42
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 5
store double 0.000000e+00, double* %44
%45 = load double, double* %10
%46 = load double, double* %7
%47 = load double, double* %7
%48 = load double, double* %8
%49 = load double, double* %8
%50 = fmul double %48, %49
%51 = call double @llvm.fmuladd.f64(double %46, double %47, double %50)
%52 = fmul double %45, %51
%53 = load double*, double** %6
%54 = getelementptr inbounds double, double* %53, i64 8
store double %52, double* %54
ret void
}

LLVM IR (-O2):
define void @glmGenerateInertiaMatrixForBox3d(double* nocapture writeonly %0, double %1, double %2, double %3, double %4) {
%6 = fdiv double %4, 1.200000e+01
%7 = fmul double %3, %3
%8 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %7)
%9 = fmul double %6, %8
store double %9, double* %0
%10 = getelementptr inbounds double, double* %0, i64 3
store double 0.000000e+00, double* %10
%11 = getelementptr inbounds double, double* %0, i64 1
%12 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %7)
%13 = fmul double %6, %12
%14 = getelementptr inbounds double, double* %0, i64 4
store double %13, double* %14
%15 = getelementptr inbounds double, double* %0, i64 7
store double 0.000000e+00, double* %15
%16 = bitcast double* %11 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %16
%17 = getelementptr inbounds double, double* %0, i64 5
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %18
%19 = fmul double %2, %2
%20 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %19)
%21 = fmul double %20, %6
%22 = getelementptr inbounds double, double* %0, i64 8
store double %21, double* %22
ret void
}