#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 */
typedef int /*<<< orphan*/ c;
typedef int /*<<< orphan*/ b;

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


x86 assembly (clang, -O0):
<fn2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %rax,-0x70(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %rax,-0x60(%rbp)
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,-0x50(%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,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edx
call   1030 <fn1@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x4(%rbp),%edx
call   1030 <fn1@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    129f <fn2+0x18f>
mov    -0x60(%rbp),%rax
mov    -0x70(%rbp),%rcx
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%rsi
mov    -0x68(%rbp),%r9
movslq -0x3c(%rbp),%r8
mov    %r8d,%edi
movsd  (%r9,%r8,8),%xmm0
movsd  (%rsi,%r8,8),%xmm2
mov    -0x4(%rbp),%esi
add    %edi,%esi
movslq %esi,%rsi
movsd  (%rdx,%rsi,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
shl    $0x3,%rcx
movq   %rcx,%xmm1
movaps 0xdb8(%rip),%xmm3
punpckldq %xmm3,%xmm1
movapd 0xdbc(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm4
unpckhpd %xmm1,%xmm1
addsd  %xmm4,%xmm1
addsd  %xmm1,%xmm0
shl    $0x3,%rax
movq   %rax,%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11f0 <fn2+0xe0>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn2>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r12d
lea    (%r12,%r12,2),%eax
mov    %rax,-0x30(%rbp)
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <fn1@plt>
mov    %r12,-0x38(%rbp)
movslq %r12d,%r12
mov    %r15,-0x40(%rbp)
lea    (%r15,%r12,8),%rsi
mov    %r13,%rdi
mov    %r12d,%edx
call   1030 <fn1@plt>
test   %r12d,%r12d
jle    11ad <fn2+0x9d>
mov    -0x30(%rbp),%rax
shl    $0x3,%rax
cvtsi2sd %rax,%xmm1
mov    -0x38(%rbp),%rcx
mov    %ecx,%eax
cmp    $0x1,%ecx
mov    -0x40(%rbp),%rdi
jne    11b6 <fn2+0xa6>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    1218 <fn2+0x108>
xorpd  %xmm0,%xmm0
jmp    123c <fn2+0x12c>
mov    %eax,%edx
and    $0xfffffffe,%edx
lea    (%rdi,%r12,8),%rsi
add    $0x8,%rsi
xorpd  %xmm2,%xmm2
xor    %ecx,%ecx
nopl   0x0(%rax)
movsd  (%r14,%rcx,8),%xmm3
movsd  0x8(%r14,%rcx,8),%xmm0
mulsd  (%rbx,%rcx,8),%xmm3
addsd  -0x8(%rsi,%rcx,8),%xmm3
addsd  %xmm1,%xmm3
subsd  %xmm1,%xmm3
mulsd  0x8(%rbx,%rcx,8),%xmm0
addsd  %xmm2,%xmm3
addsd  (%rsi,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
add    $0x2,%rcx
movapd %xmm0,%xmm2
cmp    %rcx,%rdx
jne    11d0 <fn2+0xc0>
test   $0x1,%al
je     123c <fn2+0x12c>
movsd  (%r14,%rcx,8),%xmm2
add    %rcx,%r12
mulsd  (%rbx,%rcx,8),%xmm2
addsd  (%rdi,%r12,8),%xmm2
addsd  %xmm1,%xmm2
subsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @fn2(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 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %22, i64 %30
%32 = load i32, i32* %2
%33 = call i32 @fn1(double* %26, double* %31, i32 %32)
store i32 0, i32* %9
br label %34
34: ; preds = %62, %1
%35 = load i32, i32* %9
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %65
38: ; preds = %34
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %14, i64 %40
%42 = load double, double* %41
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %18, i64 %44
%46 = load double, double* %45
%47 = load i32, i32* %2
%48 = load i32, i32* %9
%49 = add nsw i32 %47, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %22, i64 %50
%52 = load double, double* %51
%53 = call double @llvm.fmuladd.f64(double %42, double %46, double %52)
%54 = mul nuw i64 8, %12
%55 = uitofp i64 %54 to double
%56 = fadd double %53, %55
%57 = mul nuw i64 8, %17
%58 = uitofp i64 %57 to double
%59 = fsub double %56, %58
%60 = load double, double* %3
%61 = fadd double %60, %59
store double %61, double* %3
br label %62
62: ; preds = %38
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %34
65: ; preds = %34
%66 = load double, double* %3
%67 = load i8*, i8** %4
ret double %66
}

LLVM IR (-O2):
define double @fn2(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 = sext i32 %0 to i64
%10 = getelementptr inbounds double, double* %6, i64 %9
%11 = call i32 @fn1(double* %7, double* %10, i32 %0)
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %68
13: ; preds = %1
%14 = shl nuw nsw i64 %3, 3
%15 = uitofp i64 %14 to double
%16 = zext i32 %0 to i64
%17 = and i64 %16, 1
%18 = icmp eq i32 %0, 1
br i1 %18, label %51, label %19
19: ; preds = %13
%20 = and i64 %16, 4294967294
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %48, %21 ]
%23 = phi double [ 0.000000e+00, %19 ], [ %47, %21 ]
%24 = phi i64 [ 0, %19 ], [ %49, %21 ]
%25 = getelementptr inbounds double, double* %4, i64 %22
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %5, i64 %22
%28 = load double, double* %27
%29 = add nsw i64 %22, %9
%30 = getelementptr inbounds double, double* %6, i64 %29
%31 = load double, double* %30
%32 = call double @llvm.fmuladd.f64(double %26, double %28, double %31)
%33 = fadd double %32, %15
%34 = fsub double %33, %15
%35 = fadd double %23, %34
%36 = or i64 %22, 1
%37 = getelementptr inbounds double, double* %4, i64 %36
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %5, i64 %36
%40 = load double, double* %39
%41 = add nsw i64 %36, %9
%42 = getelementptr inbounds double, double* %6, i64 %41
%43 = load double, double* %42
%44 = call double @llvm.fmuladd.f64(double %38, double %40, double %43)
%45 = fadd double %44, %15
%46 = fsub double %45, %15
%47 = fadd double %35, %46
%48 = add nuw nsw i64 %22, 2
%49 = add i64 %24, 2
%50 = icmp eq i64 %49, %20
br i1 %50, label %51, label %21
51: ; preds = %21, %13
%52 = phi double [ undef, %13 ], [ %47, %21 ]
%53 = phi i64 [ 0, %13 ], [ %48, %21 ]
%54 = phi double [ 0.000000e+00, %13 ], [ %47, %21 ]
%55 = icmp eq i64 %17, 0
br i1 %55, label %68, label %56
56: ; preds = %51
%57 = getelementptr inbounds double, double* %4, i64 %53
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %5, i64 %53
%60 = load double, double* %59
%61 = add nsw i64 %53, %9
%62 = getelementptr inbounds double, double* %6, i64 %61
%63 = load double, double* %62
%64 = call double @llvm.fmuladd.f64(double %58, double %60, double %63)
%65 = fadd double %64, %15
%66 = fsub double %65, %15
%67 = fadd double %54, %66
br label %68
68: ; preds = %56, %51, %1
%69 = phi double [ 0.000000e+00, %1 ], [ %52, %51 ], [ %67, %56 ]
ret double %69
}