void glmGenerateInertiaMatrixForSphere3d(double m[9], double r, double mass) {
  mass *= 2.0f / 5.0f;
  m[0] = mass * r * r;
  m[3] = 0;
  m[6] = 0;
  m[1] = 0;
  m[4] = mass * r * r;
  m[7] = 0;
  m[2] = 0;
  m[5] = 0;
  m[8] = mass * r * r;
}


x86 assembly (clang, -O0):
<glmGenerateInertiaMatrixForSphere3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xee6(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%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  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%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  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @glmGenerateInertiaMatrixForSphere3d(double* %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store double* %0, double** %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %6
%8 = fmul double %7, 0x3FD99999A0000000
store double %8, double* %6
%9 = load double, double* %6
%10 = load double, double* %5
%11 = fmul double %9, %10
%12 = load double, double* %5
%13 = fmul double %11, %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 0
store double %13, double* %15
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 3
store double 0.000000e+00, double* %17
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 6
store double 0.000000e+00, double* %19
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 1
store double 0.000000e+00, double* %21
%22 = load double, double* %6
%23 = load double, double* %5
%24 = fmul double %22, %23
%25 = load double, double* %5
%26 = fmul double %24, %25
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 4
store double %26, double* %28
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 7
store double 0.000000e+00, double* %30
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 2
store double 0.000000e+00, double* %32
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 5
store double 0.000000e+00, double* %34
%35 = load double, double* %6
%36 = load double, double* %5
%37 = fmul double %35, %36
%38 = load double, double* %5
%39 = fmul double %37, %38
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 8
store double %39, double* %41
ret void
}

LLVM IR (-O2):
define void @glmGenerateInertiaMatrixForSphere3d(double* nocapture writeonly %0, double %1, double %2) {
%4 = fmul double %2, 0x3FD99999A0000000
%5 = fmul double %4, %1
%6 = fmul double %5, %1
store double %6, double* %0
%7 = getelementptr inbounds double, double* %0, i64 3
store double 0.000000e+00, double* %7
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = getelementptr inbounds double, double* %0, i64 4
store double %6, double* %9
%10 = getelementptr inbounds double, double* %0, i64 7
store double 0.000000e+00, double* %10
%11 = bitcast double* %8 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %11
%12 = getelementptr inbounds double, double* %0, i64 5
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %13
%14 = getelementptr inbounds double, double* %0, i64 8
store double %6, double* %14
ret void
}