int triad(int len, double xx, double *a, double *b, double *c) {
  int i, bytes = 24;
  for (i = 0; i < len; i++)
    a[i] = 10;
  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    1155 <triad+0x55>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xebe(%rip),%xmm0
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    121d <triad+0x11d>
mov    %edi,%eax
cmp    $0x4,%edi
jae    1116 <triad+0x16>
xor    %ecx,%ecx
jmp    11f7 <triad+0xf7>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%r8d
and    $0x7,%r8d
cmp    $0x1c,%rdx
jae    113e <triad+0x3e>
xor    %edx,%edx
jmp    11c1 <triad+0xc1>
and    $0xfffffffffffffff8,%rdi
xor    %edx,%edx
movaps 0xeb5(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,(%rsi,%rdx,8)
movups %xmm0,0x10(%rsi,%rdx,8)
movups %xmm0,0x20(%rsi,%rdx,8)
movups %xmm0,0x30(%rsi,%rdx,8)
movups %xmm0,0x40(%rsi,%rdx,8)
movups %xmm0,0x50(%rsi,%rdx,8)
movups %xmm0,0x60(%rsi,%rdx,8)
movups %xmm0,0x70(%rsi,%rdx,8)
movups %xmm0,0x80(%rsi,%rdx,8)
movups %xmm0,0x90(%rsi,%rdx,8)
movups %xmm0,0xa0(%rsi,%rdx,8)
movups %xmm0,0xb0(%rsi,%rdx,8)
movups %xmm0,0xc0(%rsi,%rdx,8)
movups %xmm0,0xd0(%rsi,%rdx,8)
movups %xmm0,0xe0(%rsi,%rdx,8)
movups %xmm0,0xf0(%rsi,%rdx,8)
add    $0x20,%rdx
add    $0xfffffffffffffff8,%rdi
jne    1150 <triad+0x50>
test   %r8,%r8
je     11f2 <triad+0xf2>
lea    (%rsi,%rdx,8),%rdx
add    $0x10,%rdx
shl    $0x5,%r8
xor    %edi,%edi
movaps 0xe25(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,-0x10(%rdx,%rdi,1)
movups %xmm0,(%rdx,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%r8
jne    11e0 <triad+0xe0>
cmp    %rax,%rcx
je     121d <triad+0x11d>
movabs $0x4024000000000000,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdx,(%rsi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1210 <triad+0x110>
mov    $0x18,%eax
ret

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 = %22, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load double*, double** %8
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
store double 1.000000e+01, double* %21
br label %22
22: ; preds = %17
%23 = load i32, i32* %11
%24 = add nsw i32 %23, 1
store i32 %24, i32* %11
br label %13
25: ; preds = %13
%26 = load i32, i32* %12
ret i32 %26
}

LLVM IR (-O2):
define i32 @triad(i32 %0, double %1, double* nocapture writeonly %2, double* nocapture readnone %3, double* nocapture readnone %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %86
7: ; preds = %5
%8 = zext i32 %0 to i64
%9 = icmp ult i32 %0, 4
br i1 %9, label %79, label %10
10: ; preds = %7
%11 = and i64 %8, 4294967292
%12 = add nsw i64 %11, -4
%13 = lshr exact i64 %12, 2
%14 = add nuw nsw i64 %13, 1
%15 = and i64 %14, 7
%16 = icmp ult i64 %12, 28
br i1 %16, label %64, label %17
17: ; preds = %10
%18 = and i64 %14, 9223372036854775800
br label %19
19: ; preds = %19, %17
%20 = phi i64 [ 0, %17 ], [ %61, %19 ]
%21 = phi i64 [ 0, %17 ], [ %62, %19 ]
%22 = getelementptr inbounds double, double* %2, i64 %20
%23 = bitcast double* %22 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %23
%24 = getelementptr inbounds double, double* %22, i64 2
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %25
%26 = or i64 %20, 4
%27 = getelementptr inbounds double, double* %2, i64 %26
%28 = bitcast double* %27 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %28
%29 = getelementptr inbounds double, double* %27, i64 2
%30 = bitcast double* %29 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %30
%31 = or i64 %20, 8
%32 = getelementptr inbounds double, double* %2, i64 %31
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %33
%34 = getelementptr inbounds double, double* %32, i64 2
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %35
%36 = or i64 %20, 12
%37 = getelementptr inbounds double, double* %2, i64 %36
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %38
%39 = getelementptr inbounds double, double* %37, i64 2
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %40
%41 = or i64 %20, 16
%42 = getelementptr inbounds double, double* %2, i64 %41
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %43
%44 = getelementptr inbounds double, double* %42, i64 2
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %45
%46 = or i64 %20, 20
%47 = getelementptr inbounds double, double* %2, i64 %46
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %48
%49 = getelementptr inbounds double, double* %47, i64 2
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %50
%51 = or i64 %20, 24
%52 = getelementptr inbounds double, double* %2, i64 %51
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %55
%56 = or i64 %20, 28
%57 = getelementptr inbounds double, double* %2, i64 %56
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %60
%61 = add nuw i64 %20, 32
%62 = add i64 %21, 8
%63 = icmp eq i64 %62, %18
br i1 %63, label %64, label %19
64: ; preds = %19, %10
%65 = phi i64 [ 0, %10 ], [ %61, %19 ]
%66 = icmp eq i64 %15, 0
br i1 %66, label %77, label %67
67: ; preds = %64, %67
%68 = phi i64 [ %74, %67 ], [ %65, %64 ]
%69 = phi i64 [ %75, %67 ], [ 0, %64 ]
%70 = getelementptr inbounds double, double* %2, i64 %68
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %71
%72 = getelementptr inbounds double, double* %70, i64 2
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %73
%74 = add nuw i64 %68, 4
%75 = add i64 %69, 1
%76 = icmp eq i64 %75, %15
br i1 %76, label %77, label %67
77: ; preds = %67, %64
%78 = icmp eq i64 %11, %8
br i1 %78, label %86, label %79
79: ; preds = %7, %77
%80 = phi i64 [ 0, %7 ], [ %11, %77 ]
br label %81
81: ; preds = %79, %81
%82 = phi i64 [ %84, %81 ], [ %80, %79 ]
%83 = getelementptr inbounds double, double* %2, i64 %82
store double 1.000000e+01, double* %83
%84 = add nuw nsw i64 %82, 1
%85 = icmp eq i64 %84, %8
br i1 %85, label %86, label %81
86: ; preds = %81, %77, %5
ret i32 24
}