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


x86 assembly (clang, -O0):
<glmReflectVector2d>:
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
movsd  0xebe(%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)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @glmReflectVector2d(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 = fmul double 2.000000e+00, %21
store double %22, double* %7
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = load double*, double** %6
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = load double, double* %7
%30 = fneg double %28
%31 = call double @llvm.fmuladd.f64(double %30, double %29, double %25)
%32 = load double*, double** %4
%33 = getelementptr inbounds double, double* %32, i64 0
store double %31, double* %33
%34 = load double*, double** %5
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = load double, double* %7
%41 = fneg double %39
%42 = call double @llvm.fmuladd.f64(double %41, double %40, double %36)
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 1
store double %42, double* %44
ret void
}

LLVM IR (-O2):
define void @glmReflectVector2d(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 = fmul double %11, 2.000000e+00
%13 = fneg double %5
%14 = tail call double @llvm.fmuladd.f64(double %13, double %12, double %4)
store double %14, double* %0
%15 = load double, double* %6
%16 = load double, double* %8
%17 = fneg double %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double %12, double %15)
%19 = getelementptr inbounds double, double* %0, i64 1
store double %18, double* %19
ret void
}