#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 add1(double, double, double);
double add2(double *, double *, int, double);
double add3(double *, double *, double);
void work(double *a, double *b, int n) {
  int i;
  double tmp;
#pragma omp simd private(tmp)
  for (i = 0; i < n; i++) {
    tmp = add1(a[i], b[i], 1.0);
    a[i] = add2(a, b, i, 1.0) + tmp;
    a[i] = add3(&a[i], &b[i], 1.0);
  }
}


x86 assembly (clang, -O0):
<work>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f2 <work+0xc2>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  0xe88(%rip),%xmm2
call   1040 <add1@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
movsd  0xe6b(%rip),%xmm0
call   1050 <add2@plt>
addsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
movsd  0xe2e(%rip),%xmm0
call   1030 <add3@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <work+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<work>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    11cf <work+0x9f>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%eax
shl    $0x3,%rax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    (%rbx,%r13,1),%r15
movsd  (%rbx,%r13,1),%xmm0
lea    (%r14,%r13,1),%r12
movsd  (%r14,%r13,1),%xmm1
movsd  0xe84(%rip),%xmm2
call   1040 <add1@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
movsd  0xe69(%rip),%xmm0
call   1050 <add2@plt>
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx,%r13,1)
mov    %r15,%rdi
mov    %r12,%rsi
movsd  0xe4a(%rip),%xmm0
call   1030 <add3@plt>
movsd  %xmm0,(%rbx,%r13,1)
add    $0x1,%ebp
add    $0x8,%r13
cmp    %r13,0x8(%rsp)
jne    1160 <work+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @work(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %48, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %51
13: ; preds = %9
%14 = load double*, double** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = load double*, double** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = call double @add1(double %18, double %23, double 1.000000e+00)
store double %24, double* %8
%25 = load double*, double** %4
%26 = load double*, double** %5
%27 = load i32, i32* %7
%28 = call double @add2(double* %25, double* %26, i32 %27, double 1.000000e+00)
%29 = load double, double* %8
%30 = fadd double %28, %29
%31 = load double*, double** %4
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double %30, double* %34
%35 = load double*, double** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double*, double** %5
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = call double @add3(double* %38, double* %42, double 1.000000e+00)
%44 = load double*, double** %4
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %48
48: ; preds = %13
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %9
51: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @work(double* %0, double* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %18, %7 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %1, i64 %8
%12 = load double, double* %11
%13 = tail call double @add1(double %10, double %12, double 1.000000e+00)
%14 = trunc i64 %8 to i32
%15 = tail call double @add2(double* %0, double* %1, i32 %14, double 1.000000e+00)
%16 = fadd double %13, %15
store double %16, double* %9
%17 = tail call double @add3(double* %9, double* %11, double 1.000000e+00)
store double %17, double* %9
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %7, %3
ret void
}