void PT_mac(double *sum, double *p1, double *p2, int n) {
  int i;
  for (i = 0; i < n; i++) {
    sum[i] += p1[i] * p2[i];
  }
}


x86 assembly (clang, -O0):
<PT_mac>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1168 <PT_mac+0x68>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <PT_mac+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<PT_mac>:
test   %ecx,%ecx
jle    12b5 <PT_mac+0x1b5>
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    117a <PT_mac+0x7a>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r8b
je     1136 <PT_mac+0x36>
movsd  (%rsi,%rcx,8),%xmm0
mulsd  (%rdx,%rcx,8),%xmm0
addsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
or     $0x1,%rcx
add    %r8,%rax
je     12b5 <PT_mac+0x1b5>
nop
movsd  (%rsi,%rcx,8),%xmm0
mulsd  (%rdx,%rcx,8),%xmm0
addsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm0
mulsd  0x8(%rdx,%rcx,8),%xmm0
addsd  0x8(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r8
jne    1140 <PT_mac+0x40>
jmp    12b5 <PT_mac+0x1b5>
lea    (%rdi,%r8,8),%rcx
lea    (%rsi,%r8,8),%rax
cmp    %rdi,%rax
seta   %r10b
lea    (%rdx,%r8,8),%rax
cmp    %rsi,%rcx
seta   %r11b
cmp    %rdi,%rax
seta   %al
cmp    %rdx,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    1112 <PT_mac+0x12>
and    %r9b,%al
jne    1112 <PT_mac+0x12>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12b6 <PT_mac+0x1b6>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
nopl   0x0(%rax)
movupd (%rsi,%rax,8),%xmm0
movupd 0x10(%rsi,%rax,8),%xmm1
movupd (%rdx,%rax,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x10(%rdx,%rax,8),%xmm0
mulpd  %xmm1,%xmm0
movupd (%rdi,%rax,8),%xmm1
addpd  %xmm2,%xmm1
movupd 0x10(%rdi,%rax,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x20(%rdi,%rax,8),%xmm0
movupd 0x30(%rdi,%rax,8),%xmm3
movupd %xmm1,(%rdi,%rax,8)
movupd %xmm2,0x10(%rdi,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm1
movupd 0x30(%rsi,%rax,8),%xmm2
movupd 0x20(%rdx,%rax,8),%xmm4
mulpd  %xmm1,%xmm4
addpd  %xmm0,%xmm4
movupd 0x30(%rdx,%rax,8),%xmm0
mulpd  %xmm2,%xmm0
addpd  %xmm3,%xmm0
movupd %xmm4,0x20(%rdi,%rax,8)
movupd %xmm0,0x30(%rdi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    11e0 <PT_mac+0xe0>
test   $0x1,%r9b
je     12ac <PT_mac+0x1ac>
movupd (%rsi,%rax,8),%xmm0
movupd 0x10(%rsi,%rax,8),%xmm1
movupd (%rdx,%rax,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x10(%rdx,%rax,8),%xmm0
mulpd  %xmm1,%xmm0
movupd (%rdi,%rax,8),%xmm1
addpd  %xmm2,%xmm1
movupd 0x10(%rdi,%rax,8),%xmm2
addpd  %xmm0,%xmm2
movupd %xmm1,(%rdi,%rax,8)
movupd %xmm2,0x10(%rdi,%rax,8)
cmp    %r8,%rcx
jne    1112 <PT_mac+0x12>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1270 <PT_mac+0x170>
jmp    12ac <PT_mac+0x1ac>

LLVM IR (-O0):
define void @PT_mac(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %31, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load double*, double** %6
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %7
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %5
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = call double @llvm.fmuladd.f64(double %19, double %24, double %29)
store double %30, double* %28
br label %31
31: ; preds = %14
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %10
34: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @PT_mac(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %145
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = icmp ult i32 %3, 4
br i1 %8, label %108, label %9
9: ; preds = %6
%10 = getelementptr double, double* %0, i64 %7
%11 = getelementptr double, double* %1, i64 %7
%12 = getelementptr double, double* %2, i64 %7
%13 = icmp ugt double* %11, %0
%14 = icmp ugt double* %10, %1
%15 = and i1 %13, %14
%16 = icmp ugt double* %12, %0
%17 = icmp ugt double* %10, %2
%18 = and i1 %16, %17
%19 = or i1 %15, %18
br i1 %19, label %108, label %20
20: ; preds = %9
%21 = and i64 %7, 4294967292
%22 = add nsw i64 %21, -4
%23 = lshr exact i64 %22, 2
%24 = add nuw nsw i64 %23, 1
%25 = and i64 %24, 1
%26 = icmp eq i64 %22, 0
br i1 %26, label %80, label %27
27: ; preds = %20
%28 = and i64 %24, 9223372036854775806
br label %29
29: ; preds = %29, %27
%30 = phi i64 [ 0, %27 ], [ %77, %29 ]
%31 = phi i64 [ 0, %27 ], [ %78, %29 ]
%32 = getelementptr inbounds double, double* %1, i64 %30
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = getelementptr inbounds double, double* %32, i64 2
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds double, double* %2, i64 %30
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %0, i64 %30
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %34, <2 x double> %40, <2 x double> %46)
%51 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %43, <2 x double> %49)
%52 = bitcast double* %44 to <2 x double>*
store <2 x double> %50, <2 x double>* %52
%53 = bitcast double* %47 to <2 x double>*
store <2 x double> %51, <2 x double>* %53
%54 = or i64 %30, 4
%55 = getelementptr inbounds double, double* %1, i64 %54
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr inbounds double, double* %55, i64 2
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %2, i64 %54
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %0, i64 %54
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %67, i64 2
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> %63, <2 x double> %69)
%74 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %60, <2 x double> %66, <2 x double> %72)
%75 = bitcast double* %67 to <2 x double>*
store <2 x double> %73, <2 x double>* %75
%76 = bitcast double* %70 to <2 x double>*
store <2 x double> %74, <2 x double>* %76
%77 = add nuw i64 %30, 8
%78 = add i64 %31, 2
%79 = icmp eq i64 %78, %28
br i1 %79, label %80, label %29
80: ; preds = %29, %20
%81 = phi i64 [ 0, %20 ], [ %77, %29 ]
%82 = icmp eq i64 %25, 0
br i1 %82, label %106, label %83
83: ; preds = %80
%84 = getelementptr inbounds double, double* %1, i64 %81
%85 = bitcast double* %84 to <2 x double>*
%86 = load <2 x double>, <2 x double>* %85
%87 = getelementptr inbounds double, double* %84, i64 2
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = getelementptr inbounds double, double* %2, i64 %81
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %90, i64 2
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = getelementptr inbounds double, double* %0, i64 %81
%97 = bitcast double* %96 to <2 x double>*
%98 = load <2 x double>, <2 x double>* %97
%99 = getelementptr inbounds double, double* %96, i64 2
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %86, <2 x double> %92, <2 x double> %98)
%103 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %89, <2 x double> %95, <2 x double> %101)
%104 = bitcast double* %96 to <2 x double>*
store <2 x double> %102, <2 x double>* %104
%105 = bitcast double* %99 to <2 x double>*
store <2 x double> %103, <2 x double>* %105
br label %106
106: ; preds = %80, %83
%107 = icmp eq i64 %21, %7
br i1 %107, label %145, label %108
108: ; preds = %9, %6, %106
%109 = phi i64 [ 0, %9 ], [ 0, %6 ], [ %21, %106 ]
%110 = xor i64 %109, -1
%111 = and i64 %7, 1
%112 = icmp eq i64 %111, 0
br i1 %112, label %122, label %113
113: ; preds = %108
%114 = getelementptr inbounds double, double* %1, i64 %109
%115 = load double, double* %114
%116 = getelementptr inbounds double, double* %2, i64 %109
%117 = load double, double* %116
%118 = getelementptr inbounds double, double* %0, i64 %109
%119 = load double, double* %118
%120 = tail call double @llvm.fmuladd.f64(double %115, double %117, double %119)
store double %120, double* %118
%121 = or i64 %109, 1
br label %122
122: ; preds = %113, %108
%123 = phi i64 [ %109, %108 ], [ %121, %113 ]
%124 = sub nsw i64 0, %7
%125 = icmp eq i64 %110, %124
br i1 %125, label %145, label %126
126: ; preds = %122, %126
%127 = phi i64 [ %143, %126 ], [ %123, %122 ]
%128 = getelementptr inbounds double, double* %1, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %2, i64 %127
%131 = load double, double* %130
%132 = getelementptr inbounds double, double* %0, i64 %127
%133 = load double, double* %132
%134 = tail call double @llvm.fmuladd.f64(double %129, double %131, double %133)
store double %134, double* %132
%135 = add nuw nsw i64 %127, 1
%136 = getelementptr inbounds double, double* %1, i64 %135
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %2, i64 %135
%139 = load double, double* %138
%140 = getelementptr inbounds double, double* %0, i64 %135
%141 = load double, double* %140
%142 = tail call double @llvm.fmuladd.f64(double %137, double %139, double %141)
store double %142, double* %140
%143 = add nuw nsw i64 %127, 2
%144 = icmp eq i64 %143, %7
br i1 %144, label %145, label %126
145: ; preds = %122, %126, %106, %4
ret void
}