void glmGenerateQuaternionMatrix3d(double m[9], const double q[4]) {
  double xx = q[1] * q[1];
  double xy = q[1] * q[2];
  double xz = q[1] * q[3];
  double xw = q[1] * q[0];
  double yy = q[2] * q[2];
  double yz = q[2] * q[3];
  double yw = q[2] * q[0];
  double zz = q[3] * q[3];
  double zw = q[3] * q[0];
  m[0] = 1 - 2 * (yy + zz);
  m[1] = 2 * (xy + zw);
  m[2] = 2 * (xz - yw);
  m[3] = 2 * (xy - zw);
  m[4] = 1 - 2 * (xx + zz);
  m[5] = 2 * (yz + xw);
  m[6] = 2 * (xz + yw);
  m[7] = 2 * (yz - xw);
  m[8] = 1 - 2 * (xx + yy);
}


x86 assembly (clang, -O0):
<glmGenerateQuaternionMatrix3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm1
addsd  -0x50(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe12(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm1
addsd  -0x58(%rbp),%xmm1
movsd  0xdfc(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  0xddd(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x20(%rbp),%xmm1
subsd  -0x58(%rbp),%xmm1
movsd  0xdbe(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x18(%rbp),%xmm1
addsd  -0x50(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xd93(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x40(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xd7c(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x28(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xd5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x40(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  0xd3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x18(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xd13(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmGenerateQuaternionMatrix3d>:
movupd 0x8(%rsi),%xmm7
movapd %xmm7,%xmm8
mulsd  %xmm7,%xmm8
movsd  0x18(%rsi),%xmm5
movapd %xmm5,%xmm6
unpcklpd %xmm7,%xmm6
mulpd  %xmm7,%xmm6
movsd  (%rsi),%xmm4
movapd %xmm7,%xmm9
mulsd  %xmm4,%xmm9
movapd %xmm7,%xmm2
unpckhpd %xmm7,%xmm2
movapd %xmm2,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm5,%xmm2
movsd  %xmm5,%xmm7
mulsd  %xmm5,%xmm5
unpcklpd %xmm4,%xmm4
mulpd  %xmm7,%xmm4
movapd %xmm4,%xmm0
shufpd $0x1,%xmm4,%xmm0
movapd %xmm3,%xmm1
addsd  %xmm5,%xmm1
addsd  %xmm1,%xmm1
movsd  0xe90(%rip),%xmm10
movapd %xmm10,%xmm7
subsd  %xmm1,%xmm7
movsd  %xmm7,(%rdi)
movapd %xmm6,%xmm1
addpd  %xmm0,%xmm1
unpckhpd %xmm1,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rdi)
movapd %xmm2,%xmm1
unpcklpd %xmm6,%xmm1
subpd  %xmm0,%xmm6
addpd  %xmm6,%xmm6
movupd %xmm6,0x10(%rdi)
addsd  %xmm8,%xmm5
addsd  %xmm5,%xmm5
movapd %xmm10,%xmm0
subsd  %xmm5,%xmm0
movsd  %xmm0,0x20(%rdi)
movsd  %xmm9,%xmm4
addpd  %xmm1,%xmm4
addpd  %xmm4,%xmm4
movupd %xmm4,0x28(%rdi)
subsd  %xmm9,%xmm2
addsd  %xmm2,%xmm2
movsd  %xmm2,0x38(%rdi)
addsd  %xmm8,%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm10
movsd  %xmm10,0x40(%rdi)
ret

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

LLVM IR (-O2):
define void @glmGenerateQuaternionMatrix3d(double* nocapture writeonly %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %1, i64 1
%4 = bitcast double* %3 to <2 x double>*
%5 = load <2 x double>, <2 x double>* %4
%6 = extractelement <2 x double> %5, i64 0
%7 = fmul <2 x double> %5, %5
%8 = extractelement <2 x double> %7, i64 0
%9 = getelementptr inbounds double, double* %1, i64 3
%10 = load double, double* %9
%11 = insertelement <2 x double> poison, double %10, i64 0
%12 = shufflevector <2 x double> %11, <2 x double> %5, <2 x i32> <i32 0, i32 2>
%13 = fmul <2 x double> %12, %5
%14 = load double, double* %1
%15 = fmul double %6, %14
%16 = extractelement <2 x double> %5, i64 1
%17 = fmul double %16, %16
%18 = fmul double %16, %10
%19 = fmul double %10, %10
%20 = insertelement <2 x double> %5, double %10, i64 0
%21 = insertelement <2 x double> poison, double %14, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fmul <2 x double> %20, %22
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%25 = fadd double %17, %19
%26 = tail call double @llvm.fmuladd.f64(double %25, double -2.000000e+00, double 1.000000e+00)
store double %26, double* %0
%27 = fadd <2 x double> %13, %24
%28 = extractelement <2 x double> %27, i64 1
%29 = fmul double %28, 2.000000e+00
%30 = getelementptr inbounds double, double* %0, i64 1
store double %29, double* %30
%31 = getelementptr inbounds double, double* %0, i64 2
%32 = fsub <2 x double> %13, %24
%33 = fmul <2 x double> %32, <double 2.000000e+00, double 2.000000e+00>
%34 = bitcast double* %31 to <2 x double>*
store <2 x double> %33, <2 x double>* %34
%35 = fadd double %8, %19
%36 = tail call double @llvm.fmuladd.f64(double %35, double -2.000000e+00, double 1.000000e+00)
%37 = getelementptr inbounds double, double* %0, i64 4
store double %36, double* %37
%38 = getelementptr inbounds double, double* %0, i64 5
%39 = insertelement <2 x double> poison, double %18, i64 0
%40 = shufflevector <2 x double> %39, <2 x double> %13, <2 x i32> <i32 0, i32 2>
%41 = insertelement <2 x double> %23, double %15, i64 0
%42 = fadd <2 x double> %40, %41
%43 = fmul <2 x double> %42, <double 2.000000e+00, double 2.000000e+00>
%44 = bitcast double* %38 to <2 x double>*
store <2 x double> %43, <2 x double>* %44
%45 = fsub double %18, %15
%46 = fmul double %45, 2.000000e+00
%47 = getelementptr inbounds double, double* %0, i64 7
store double %46, double* %47
%48 = fadd double %8, %17
%49 = tail call double @llvm.fmuladd.f64(double %48, double -2.000000e+00, double 1.000000e+00)
%50 = getelementptr inbounds double, double* %0, i64 8
store double %49, double* %50
ret void
}