#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 */
int /*<<< orphan*/ fn1(double *, double *, int);
double fn3(int x) {
  double s = 0;
  double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
  int i;
  fn1(b, c, x);
  fn1(e, d, x);
#pragma omp target map(tofrom : s)
#pragma omp parallel for reduction(+ : s)
  for (i = 0; i < x; i++)
    s += b[i] * c[i] + d[i];
  return s;
}


x86 assembly (clang, -O0):
<fn3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x58(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edx
call   1030 <fn1@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1030 <fn1@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1230 <fn3+0x120>
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    -0x60(%rbp),%rdx
movslq -0x3c(%rbp),%rsi
movsd  (%rdx,%rsi,8),%xmm0
movslq -0x3c(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm2
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11dd <fn3+0xcd>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn3>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
lea    (%r12,%r12,2),%eax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <fn1@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <fn1@plt>
test   %r12d,%r12d
jle    1187 <fn3+0x77>
mov    %r12d,%eax
cmp    $0x1,%r12d
jne    118d <fn3+0x7d>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    11da <fn3+0xca>
xorpd  %xmm0,%xmm0
jmp    11f3 <fn3+0xe3>
mov    %eax,%edx
and    $0xfffffffe,%edx
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movsd  (%r14,%rcx,8),%xmm2
movsd  0x8(%r14,%rcx,8),%xmm0
mulsd  (%r15,%rcx,8),%xmm2
addsd  (%rbx,%rcx,8),%xmm2
mulsd  0x8(%r15,%rcx,8),%xmm0
addsd  0x8(%rbx,%rcx,8),%xmm0
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
add    $0x2,%rcx
movapd %xmm0,%xmm1
cmp    %rcx,%rdx
jne    11a0 <fn3+0x90>
test   $0x1,%al
je     11f3 <fn3+0xe3>
movsd  (%r14,%rcx,8),%xmm1
mulsd  (%r15,%rcx,8),%xmm1
addsd  (%rbx,%rcx,8),%xmm1
addsd  %xmm1,%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @fn3(i32 %0) {
%2 = mul nsw i32 %0, 3
%3 = zext i32 %2 to i64
%4 = alloca double, i64 %3
%5 = alloca double, i64 %3
%6 = alloca double, i64 %3
%7 = alloca double, i64 %3
%8 = call i32 @fn1(double* %4, double* %5, i32 %0)
%9 = call i32 @fn1(double* %7, double* %6, i32 %0)
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %55
11: ; preds = %1
%12 = zext i32 %0 to i64
%13 = and i64 %12, 1
%14 = icmp eq i32 %0, 1
br i1 %14, label %41, label %15
15: ; preds = %11
%16 = and i64 %12, 4294967294
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %38, %17 ]
%19 = phi double [ 0.000000e+00, %15 ], [ %37, %17 ]
%20 = phi i64 [ 0, %15 ], [ %39, %17 ]
%21 = getelementptr inbounds double, double* %4, i64 %18
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %5, i64 %18
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %6, i64 %18
%26 = load double, double* %25
%27 = call double @llvm.fmuladd.f64(double %22, double %24, double %26)
%28 = fadd double %19, %27
%29 = or i64 %18, 1
%30 = getelementptr inbounds double, double* %4, i64 %29
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %5, i64 %29
%33 = load double, double* %32
%34 = getelementptr inbounds double, double* %6, i64 %29
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double %31, double %33, double %35)
%37 = fadd double %28, %36
%38 = add nuw nsw i64 %18, 2
%39 = add i64 %20, 2
%40 = icmp eq i64 %39, %16
br i1 %40, label %41, label %17
41: ; preds = %17, %11
%42 = phi double [ undef, %11 ], [ %37, %17 ]
%43 = phi i64 [ 0, %11 ], [ %38, %17 ]
%44 = phi double [ 0.000000e+00, %11 ], [ %37, %17 ]
%45 = icmp eq i64 %13, 0
br i1 %45, label %55, label %46
46: ; preds = %41
%47 = getelementptr inbounds double, double* %4, i64 %43
%48 = load double, double* %47
%49 = getelementptr inbounds double, double* %5, i64 %43
%50 = load double, double* %49
%51 = getelementptr inbounds double, double* %6, i64 %43
%52 = load double, double* %51
%53 = call double @llvm.fmuladd.f64(double %48, double %50, double %52)
%54 = fadd double %44, %53
br label %55
55: ; preds = %46, %41, %1
%56 = phi double [ 0.000000e+00, %1 ], [ %42, %41 ], [ %54, %46 ]
ret double %56
}