int triad(int len, double xx, double *a, double *b, double *c) {
  int i, bytes = 24;
#pragma vector aligned
#pragma vector nontemporal
  for (i = 0; i < len; i++)
    a[i] = b[i] + xx * c[i];
  return bytes;
}


x86 assembly (clang, -O0):
<triad>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x18,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1174 <triad+0x74>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1126 <triad+0x26>
mov    -0x30(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<triad>:
test   %edi,%edi
jle    129f <triad+0x19f>
mov    %edi,%r8d
cmp    $0x4,%edi
jae    1177 <triad+0x77>
xor    %edi,%edi
mov    %rdi,%rax
not    %rax
test   $0x1,%r8b
je     1135 <triad+0x35>
movsd  (%rcx,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdx,%rdi,8),%xmm1
movsd  %xmm1,(%rsi,%rdi,8)
or     $0x1,%rdi
add    %r8,%rax
je     129f <triad+0x19f>
xchg   %ax,%ax
movsd  (%rcx,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdx,%rdi,8),%xmm1
movsd  %xmm1,(%rsi,%rdi,8)
movsd  0x8(%rcx,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rdx,%rdi,8),%xmm1
movsd  %xmm1,0x8(%rsi,%rdi,8)
add    $0x2,%rdi
cmp    %rdi,%r8
jne    1140 <triad+0x40>
jmp    129f <triad+0x19f>
lea    (%rsi,%r8,8),%rdi
lea    (%rdx,%r8,8),%rax
cmp    %rsi,%rax
seta   %r10b
lea    (%rcx,%r8,8),%rax
cmp    %rdx,%rdi
seta   %r11b
cmp    %rsi,%rax
seta   %al
cmp    %rcx,%rdi
seta   %r9b
xor    %edi,%edi
test   %r11b,%r10b
jne    1112 <triad+0x12>
and    %r9b,%al
jne    1112 <triad+0x12>
mov    %r8d,%edi
and    $0xfffffffc,%edi
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rdi),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12a5 <triad+0x1a5>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%rdx,%rax,8),%xmm2
movupd 0x10(%rdx,%rax,8),%xmm3
movupd (%rcx,%rax,8),%xmm4
movupd 0x10(%rcx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rsi,%rax,8)
movupd %xmm5,0x10(%rsi,%rax,8)
movupd 0x20(%rdx,%rax,8),%xmm2
movupd 0x30(%rdx,%rax,8),%xmm3
movupd 0x20(%rcx,%rax,8),%xmm4
movupd 0x30(%rcx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,0x20(%rsi,%rax,8)
movupd %xmm5,0x30(%rsi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    11f0 <triad+0xf0>
test   $0x1,%r9b
je     1296 <triad+0x196>
movupd (%rdx,%rax,8),%xmm2
movupd 0x10(%rdx,%rax,8),%xmm3
movupd (%rcx,%rax,8),%xmm4
movupd 0x10(%rcx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rsi,%rax,8)
movupd %xmm5,0x10(%rsi,%rax,8)
cmp    %r8,%rdi
jne    1112 <triad+0x12>
mov    $0x18,%eax
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1265 <triad+0x165>
jmp    1296 <triad+0x196>

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

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