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


x86 assembly (clang, -O0):
<glmReflectVector4d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe8a(%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)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x18(%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,0x18(%rax)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @glmReflectVector4d(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 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 3
%31 = load double, double* %30
%32 = load double*, double** %6
%33 = getelementptr inbounds double, double* %32, i64 3
%34 = load double, double* %33
%35 = call double @llvm.fmuladd.f64(double %31, double %34, double %28)
%36 = fmul double 2.000000e+00, %35
store double %36, double* %7
%37 = load double*, double** %5
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load double*, double** %6
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = load double, double* %7
%44 = fneg double %42
%45 = call double @llvm.fmuladd.f64(double %44, double %43, double %39)
%46 = load double*, double** %4
%47 = getelementptr inbounds double, double* %46, i64 0
store double %45, double* %47
%48 = load double*, double** %5
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
%51 = load double*, double** %6
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = load double, double* %7
%55 = fneg double %53
%56 = call double @llvm.fmuladd.f64(double %55, double %54, double %50)
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 1
store double %56, double* %58
%59 = load double*, double** %5
%60 = getelementptr inbounds double, double* %59, i64 2
%61 = load double, double* %60
%62 = load double*, double** %6
%63 = getelementptr inbounds double, double* %62, i64 2
%64 = load double, double* %63
%65 = load double, double* %7
%66 = fneg double %64
%67 = call double @llvm.fmuladd.f64(double %66, double %65, double %61)
%68 = load double*, double** %4
%69 = getelementptr inbounds double, double* %68, i64 2
store double %67, double* %69
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 3
%72 = load double, double* %71
%73 = load double*, double** %6
%74 = getelementptr inbounds double, double* %73, i64 3
%75 = load double, double* %74
%76 = load double, double* %7
%77 = fneg double %75
%78 = call double @llvm.fmuladd.f64(double %77, double %76, double %72)
%79 = load double*, double** %4
%80 = getelementptr inbounds double, double* %79, i64 3
store double %78, double* %80
ret void
}

LLVM IR (-O2):
define void @glmReflectVector4d(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 = getelementptr inbounds double, double* %1, i64 3
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %2, i64 3
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %16)
%22 = fmul double %21, 2.000000e+00
%23 = fneg double %5
%24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %4)
store double %24, double* %0
%25 = load double, double* %6
%26 = load double, double* %8
%27 = fneg double %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %22, double %25)
%29 = getelementptr inbounds double, double* %0, i64 1
store double %28, double* %29
%30 = load double, double* %12
%31 = load double, double* %14
%32 = fneg double %31
%33 = tail call double @llvm.fmuladd.f64(double %32, double %22, double %30)
%34 = getelementptr inbounds double, double* %0, i64 2
store double %33, double* %34
%35 = load double, double* %17
%36 = load double, double* %19
%37 = fneg double %36
%38 = tail call double @llvm.fmuladd.f64(double %37, double %22, double %35)
%39 = getelementptr inbounds double, double* %0, i64 3
store double %38, double* %39
ret void
}