#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double triad_base(double, double, double);
int triad(int len, double xx, double *a, double *b, double *c) {
  int i, bytes = 24;
  for (i = 0; i < len; i++)
    a[i] = triad_base(b[i], c[i], xx);
  return bytes;
}


x86 assembly (clang, -O0):
<triad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    1185 <triad+0x75>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x10(%rbp),%xmm2
call   1030 <triad_base@plt>
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    113a <triad+0x2a>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triad>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1166 <triad+0x56>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
movaps %xmm0,%xmm1
mov    %edi,%r13d
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
movsd  (%r14,%rbx,8),%xmm1
movsd  0x8(%rsp),%xmm2
call   1030 <triad_base@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <triad+0x30>
mov    $0x18,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 = %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** %10
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double, double* %7
%29 = call double @triad_base(double %22, double %27, double %28)
%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 %19
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = getelementptr inbounds double, double* %3, i64 %10
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %4, i64 %10
%14 = load double, double* %13
%15 = tail call double @triad_base(double %12, double %14, double %1)
%16 = getelementptr inbounds double, double* %2, i64 %10
store double %15, double* %16
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %9
19: ; preds = %9, %5
ret i32 24
}