void glmGenerateQuaternionMatrix4d(double m[16], 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[4] = 2 * (xy - zw);
  m[5] = 1 - 2 * (xx + zz);
  m[6] = 2 * (yz + xw);
  m[8] = 2 * (xz + yw);
  m[9] = 2 * (yz - xw);
  m[10] = 1 - 2 * (xx + yy);
  m[3] = m[7] = m[11] = m[12] = m[13] = m[14] = 0;
  m[15] = 1;
}


x86 assembly (clang, -O0):
<glmGenerateQuaternionMatrix4d>:
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,0x20(%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,0x28(%rax)
movsd  -0x40(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xd7c(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x28(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xd5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  -0x40(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  0xd3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x48(%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,0x50(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x70(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x68(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x60(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x58(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  0xcb2(%rip),%xmm0
movsd  %xmm0,0x78(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmGenerateQuaternionMatrix4d>:
movsd  (%rsi),%xmm2
movsd  0x8(%rsi),%xmm11
movapd %xmm11,%xmm8
mulsd  %xmm11,%xmm8
movsd  0x10(%rsi),%xmm3
movapd %xmm11,%xmm7
mulsd  %xmm3,%xmm7
movsd  0x18(%rsi),%xmm5
movapd %xmm11,%xmm9
mulsd  %xmm5,%xmm9
mulsd  %xmm2,%xmm11
movapd %xmm3,%xmm6
mulsd  %xmm3,%xmm6
movapd %xmm3,%xmm4
mulsd  %xmm5,%xmm4
mulsd  %xmm2,%xmm3
movapd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm2,%xmm5
movapd %xmm6,%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm2,%xmm2
movsd  0xe95(%rip),%xmm10
movapd %xmm10,%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,(%rdi)
movapd %xmm7,%xmm1
addsd  %xmm5,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rdi)
movapd %xmm9,%xmm1
subsd  %xmm3,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rdi)
subsd  %xmm5,%xmm7
addsd  %xmm7,%xmm7
movsd  %xmm7,0x20(%rdi)
addsd  %xmm8,%xmm0
addsd  %xmm0,%xmm0
movapd %xmm10,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rdi)
movapd %xmm4,%xmm0
addsd  %xmm11,%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x30(%rdi)
addsd  %xmm9,%xmm3
addsd  %xmm3,%xmm3
movsd  %xmm3,0x40(%rdi)
subsd  %xmm11,%xmm4
addsd  %xmm4,%xmm4
movsd  %xmm4,0x48(%rdi)
addsd  %xmm8,%xmm6
addsd  %xmm6,%xmm6
subsd  %xmm6,%xmm10
movsd  %xmm10,0x50(%rdi)
movq   $0x0,0x38(%rdi)
movq   $0x0,0x18(%rdi)
xorpd  %xmm0,%xmm0
movupd %xmm0,0x58(%rdi)
movupd %xmm0,0x68(%rdi)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x78(%rdi)
ret

LLVM IR (-O0):
define void @glmGenerateQuaternionMatrix4d(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 4
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 5
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 6
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 8
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 9
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 10
store double %128, double* %130
%131 = load double*, double** %3
%132 = getelementptr inbounds double, double* %131, i64 14
store double 0.000000e+00, double* %132
%133 = load double*, double** %3
%134 = getelementptr inbounds double, double* %133, i64 13
store double 0.000000e+00, double* %134
%135 = load double*, double** %3
%136 = getelementptr inbounds double, double* %135, i64 12
store double 0.000000e+00, double* %136
%137 = load double*, double** %3
%138 = getelementptr inbounds double, double* %137, i64 11
store double 0.000000e+00, double* %138
%139 = load double*, double** %3
%140 = getelementptr inbounds double, double* %139, i64 7
store double 0.000000e+00, double* %140
%141 = load double*, double** %3
%142 = getelementptr inbounds double, double* %141, i64 3
store double 0.000000e+00, double* %142
%143 = load double*, double** %3
%144 = getelementptr inbounds double, double* %143, i64 15
store double 1.000000e+00, double* %144
ret void
}

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