int triad(int len, double xx, double *a, double *b, double *c) {
  int i, bytes = 24;
  a = __builtin_assume_aligned(a, 64);
  b = __builtin_assume_aligned(b, 64);
  c = __builtin_assume_aligned(c, 64);
  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)
mov    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118c <triad+0x8c>
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    113e <triad+0x3e>
mov    -0x30(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<triad>:
test   %edi,%edi
jle    1293 <triad+0x193>
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     1293 <triad+0x193>
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    1293 <triad+0x193>
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     1299 <triad+0x199>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd (%rcx,%rax,8),%xmm2
mulpd  %xmm1,%xmm2
addpd  (%rdx,%rax,8),%xmm2
movapd 0x10(%rcx,%rax,8),%xmm3
mulpd  %xmm1,%xmm3
addpd  0x10(%rdx,%rax,8),%xmm3
movapd %xmm2,(%rsi,%rax,8)
movapd %xmm3,0x10(%rsi,%rax,8)
movupd 0x30(%rdx,%rax,8),%xmm2
movupd 0x30(%rcx,%rax,8),%xmm3
movapd 0x20(%rcx,%rax,8),%xmm4
mulpd  %xmm1,%xmm4
addpd  0x20(%rdx,%rax,8),%xmm4
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movapd %xmm4,0x20(%rsi,%rax,8)
movupd %xmm3,0x30(%rsi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    11f0 <triad+0xf0>
test   $0x1,%r9b
je     128a <triad+0x18a>
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    1259 <triad+0x159>
jmp    128a <triad+0x18a>

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
%13 = load double*, double** %8
%14 = bitcast double* %13 to i8*
%15 = bitcast i8* %14 to double*
store double* %15, double** %8
%16 = load double*, double** %9
%17 = bitcast double* %16 to i8*
%18 = bitcast i8* %17 to double*
store double* %18, double** %9
%19 = load double*, double** %10
%20 = bitcast double* %19 to i8*
%21 = bitcast i8* %20 to double*
store double* %21, double** %10
store i32 0, i32* %11
br label %22
22: ; preds = %43, %5
%23 = load i32, i32* %11
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %46
26: ; preds = %22
%27 = load double*, double** %9
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = load double, double* %7
%33 = load double*, double** %10
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = call double @llvm.fmuladd.f64(double %32, double %37, double %31)
%39 = load double*, double** %8
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double %38, double* %42
br label %43
43: ; preds = %26
%44 = load i32, i32* %11
%45 = add nsw i32 %44, 1
store i32 %45, i32* %11
br label %22
46: ; preds = %22
%47 = load i32, i32* %12
ret i32 %47
}

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