void pdot2sym(double *D, double *X, double *Y, int n) {
  double aa = 0.0, bb = 0.0, ab = 0.0;
  const int n2 = n * 2;
#pragma omp parallel for reduction(+ : aa, bb, ab) schedule(static)
  for (int i = 0; i < n2; i += 2) {
    aa += X[i] * Y[i];
    bb += X[i + 1] * Y[i + 1];
    ab += X[i] * Y[i + 1];
  }
  D[0] = aa;
  D[1] = bb;
  D[2] = ab;
}


x86 assembly (clang, -O0):
<pdot2sym>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    11e8 <pdot2sym+0xe8>
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x40(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x40(%rbp)
jmp    113b <pdot2sym+0x3b>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdot2sym>:
test   %ecx,%ecx
jle    1159 <pdot2sym+0x59>
add    %ecx,%ecx
movslq %ecx,%rax
xorpd  %xmm3,%xmm3
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm3,%xmm2
movupd (%rsi,%rcx,8),%xmm4
movupd (%rdx,%rcx,8),%xmm5
movapd %xmm4,%xmm1
mulpd  %xmm5,%xmm1
movapd %xmm1,%xmm3
addpd  %xmm2,%xmm3
unpckhpd %xmm5,%xmm5
mulsd  %xmm4,%xmm5
addsd  %xmm5,%xmm0
add    $0x2,%rcx
cmp    %rax,%rcx
jl     1120 <pdot2sym+0x20>
addpd  %xmm2,%xmm1
jmp    1161 <pdot2sym+0x61>
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movupd %xmm1,(%rdi)
movsd  %xmm0,0x10(%rdi)
ret

LLVM IR (-O0):
define void @pdot2sym(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
%14 = load i32, i32* %8
%15 = mul nsw i32 %14, 2
store i32 %15, i32* %12
store i32 0, i32* %13
br label %16
16: ; preds = %60, %4
%17 = load i32, i32* %13
%18 = load i32, i32* %12
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %63
20: ; preds = %16
%21 = load double*, double** %6
%22 = load i32, i32* %13
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %7
%27 = load i32, i32* %13
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = load double, double* %9
%32 = call double @llvm.fmuladd.f64(double %25, double %30, double %31)
store double %32, double* %9
%33 = load double*, double** %6
%34 = load i32, i32* %13
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %33, i64 %36
%38 = load double, double* %37
%39 = load double*, double** %7
%40 = load i32, i32* %13
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
%44 = load double, double* %43
%45 = load double, double* %10
%46 = call double @llvm.fmuladd.f64(double %38, double %44, double %45)
store double %46, double* %10
%47 = load double*, double** %6
%48 = load i32, i32* %13
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = load double*, double** %7
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %52, i64 %55
%57 = load double, double* %56
%58 = load double, double* %11
%59 = call double @llvm.fmuladd.f64(double %51, double %57, double %58)
store double %59, double* %11
br label %60
60: ; preds = %20
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 2
store i32 %62, i32* %13
br label %16
63: ; preds = %16
%64 = load double, double* %9
%65 = load double*, double** %5
%66 = getelementptr inbounds double, double* %65, i64 0
store double %64, double* %66
%67 = load double, double* %10
%68 = load double*, double** %5
%69 = getelementptr inbounds double, double* %68, i64 1
store double %67, double* %69
%70 = load double, double* %11
%71 = load double*, double** %5
%72 = getelementptr inbounds double, double* %71, i64 2
store double %70, double* %72
ret void
}

LLVM IR (-O2):
define void @pdot2sym(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = shl nuw nsw i32 %3, 1
%8 = sext i32 %7 to i64
br label %16
9: ; preds = %16
%10 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %25, <2 x double> %19)
br label %11
11: ; preds = %9, %4
%12 = phi double [ 0.000000e+00, %4 ], [ %29, %9 ]
%13 = phi <2 x double> [ zeroinitializer, %4 ], [ %10, %9 ]
%14 = bitcast double* %0 to <2 x double>*
store <2 x double> %13, <2 x double>* %14
%15 = getelementptr inbounds double, double* %0, i64 2
store double %12, double* %15
ret void
16: ; preds = %6, %16
%17 = phi i64 [ 0, %6 ], [ %30, %16 ]
%18 = phi double [ 0.000000e+00, %6 ], [ %29, %16 ]
%19 = phi <2 x double> [ zeroinitializer, %6 ], [ %26, %16 ]
%20 = getelementptr inbounds double, double* %1, i64 %17
%21 = getelementptr inbounds double, double* %2, i64 %17
%22 = bitcast double* %20 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = bitcast double* %21 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %25, <2 x double> %19)
%27 = extractelement <2 x double> %23, i64 0
%28 = extractelement <2 x double> %25, i64 1
%29 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %18)
%30 = add nuw nsw i64 %17, 2
%31 = icmp slt i64 %30, %8
br i1 %31, label %16, label %9
}