#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 fn4(int x, double *p) {
  double b[1024], c[1024], d[1024], s = 0;
  int i;
  fn1(b, c, x);
  fn1(d + x, p + x, x);
#pragma omp target map(to                                                      \
                       : b, c [0:x], d [x:x]) map(to                           \
                                                  : p [x:64 + (x & 31)])       \
    map(tofrom                                                                 \
        : s)
#pragma omp parallel for reduction(+ : s)
  for (i = 0; i < x; i++)
    s += b[i] * c[i] + d[x + i] + p[x + i];
  return s;
}


x86 assembly (clang, -O0):
<fn4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6020,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x6018(%rbp)
ff
lea    -0x2010(%rbp),%rdi
lea    -0x4010(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1030 <fn1@plt>
lea    -0x6010(%rbp),%rdi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x4(%rbp),%edx
call   1030 <fn1@plt>
movl   $0x0,-0x601c(%rbp)
mov    -0x601c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fa <fn4+0xea>
movslq -0x601c(%rbp),%rax
movsd  -0x2010(%rbp,%rax,8),%xmm0
ff ff
movslq -0x601c(%rbp),%rax
movsd  -0x4010(%rbp,%rax,8),%xmm2
ff ff
mov    -0x4(%rbp),%eax
add    -0x601c(%rbp),%eax
cltq
movsd  -0x6010(%rbp,%rax,8),%xmm1
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    -0x601c(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
addsd  -0x6018(%rbp),%xmm0
ff
movsd  %xmm0,-0x6018(%rbp)
ff
mov    -0x601c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x601c(%rbp)
jmp    1176 <fn4+0x66>
movsd  -0x6018(%rbp),%xmm0
ff
add    $0x6020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn4>:
push   %rbp
push   %r14
push   %rbx
sub    $0x6000,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0x2000(%rsp),%rdi
mov    %rsp,%rsi
mov    %ebp,%edx
call   1030 <fn1@plt>
movslq %ebp,%rbx
lea    (%rsp,%rbx,8),%rdi
add    $0x4000,%rdi
lea    (%r14,%rbx,8),%rsi
mov    %ebx,%edx
call   1030 <fn1@plt>
test   %ebx,%ebx
jle    115e <fn4+0x4e>
mov    %ebp,%eax
cmp    $0x1,%ebp
jne    1167 <fn4+0x57>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    11d8 <fn4+0xc8>
xorpd  %xmm0,%xmm0
jmp    1200 <fn4+0xf0>
mov    %eax,%edx
and    $0xfffffffe,%edx
lea    (%r14,%rbx,8),%rsi
add    $0x8,%rsi
lea    (%rsp,%rbx,8),%rdi
add    $0x4008,%rdi
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x2000(%rsp,%rcx,8),%xmm2
movsd  0x2008(%rsp,%rcx,8),%xmm0
mulsd  (%rsp,%rcx,8),%xmm2
addsd  -0x8(%rdi,%rcx,8),%xmm2
addsd  -0x8(%rsi,%rcx,8),%xmm2
mulsd  0x8(%rsp,%rcx,8),%xmm0
addsd  (%rdi,%rcx,8),%xmm0
addsd  (%rsi,%rcx,8),%xmm0
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
add    $0x2,%rcx
movapd %xmm0,%xmm1
cmp    %rcx,%rdx
jne    1190 <fn4+0x80>
test   $0x1,%al
je     1200 <fn4+0xf0>
movsd  0x2000(%rsp,%rcx,8),%xmm1
add    %rcx,%rbx
mulsd  (%rsp,%rcx,8),%xmm1
addsd  0x4000(%rsp,%rbx,8),%xmm1
addsd  (%r14,%rbx,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x6000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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