void glmReflectVector3d(double result[3], const double v[3],
                        const double normal[3]) {
  double temp;
  temp = 2.0 * (v[0] * normal[0] + v[1] * normal[1] + v[2] * normal[2]);
  result[0] = v[0] - normal[0] * temp;
  result[1] = v[1] - normal[1] * temp;
  result[2] = v[2] - normal[2] * temp;
}


x86 assembly (clang, -O0):
<glmReflectVector3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea4(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmReflectVector3d>:
movsd  (%rdx),%xmm0
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm2
mulsd  0x8(%rdx),%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
movsd  0x10(%rsi),%xmm4
mulsd  0x10(%rdx),%xmm4
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm4
addsd  %xmm4,%xmm4
mulsd  %xmm4,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi)
movsd  0x8(%rsi),%xmm0
movsd  0x8(%rdx),%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rdi)
movsd  0x10(%rsi),%xmm0
mulsd  0x10(%rdx),%xmm4
subsd  %xmm4,%xmm0
movsd  %xmm0,0x10(%rdi)
ret

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

LLVM IR (-O2):
define void @glmReflectVector3d(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %1
%5 = load double, double* %2
%6 = getelementptr inbounds double, double* %1, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %2, i64 1
%9 = load double, double* %8
%10 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %4, double %5, double %10)
%12 = getelementptr inbounds double, double* %1, i64 2
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %2, i64 2
%15 = load double, double* %14
%16 = tail call double @llvm.fmuladd.f64(double %13, double %15, double %11)
%17 = fmul double %16, 2.000000e+00
%18 = fneg double %5
%19 = tail call double @llvm.fmuladd.f64(double %18, double %17, double %4)
store double %19, double* %0
%20 = load double, double* %6
%21 = load double, double* %8
%22 = fneg double %21
%23 = tail call double @llvm.fmuladd.f64(double %22, double %17, double %20)
%24 = getelementptr inbounds double, double* %0, i64 1
store double %23, double* %24
%25 = load double, double* %12
%26 = load double, double* %14
%27 = fneg double %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %17, double %25)
%29 = getelementptr inbounds double, double* %0, i64 2
store double %28, double* %29
ret void
}