#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ test_comp_unit_1(int const, double *);
int /*<<< orphan*/ test_comp_unit_2(int const, double *);
int main() {
  const int niters = 10;
  double *a = (double *)malloc(sizeof(double) * niters);
#pragma omp target data map(from : a[:niters])
  {
    test_comp_unit_1(niters, a);
    test_comp_unit_2(niters, a);
  }
  double res = 0.0;
  for (int ii = 0; ii < niters; ++ii) {
    res += a[ii];
  }
  printf("--> %s <--\n", (res < 90.001 && res > 89.999) ? "success" : "error");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1060 <test_comp_unit_1@plt>
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1030 <test_comp_unit_2@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11be <main+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <main+0x4f>
xor    %eax,%eax
movsd  0xe38(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x1d(%rbp)
jbe    11ed <main+0xad>
movsd  -0x18(%rbp),%xmm0
movsd  0xe25(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%cl
lea    0xe2d(%rip),%rsi
lea    0xe1e(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0xa,%edi
mov    %rax,%rsi
call   1060 <test_comp_unit_1@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <test_comp_unit_2@plt>
xorpd  %xmm0,%xmm0
addsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
addsd  0x10(%rbx),%xmm0
addsd  0x18(%rbx),%xmm0
addsd  0x20(%rbx),%xmm0
addsd  0x28(%rbx),%xmm0
addsd  0x30(%rbx),%xmm0
addsd  0x38(%rbx),%xmm0
addsd  0x40(%rbx),%xmm0
addsd  0x48(%rbx),%xmm0
ucomisd 0xe5b(%rip),%xmm0
lea    0xe70(%rip),%rsi
lea    0xe71(%rip),%rax
cmovbe %rax,%rsi
movsd  0xe49(%rip),%xmm1
ucomisd %xmm0,%xmm1
cmovbe %rax,%rsi
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"--> %s <--\0A\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double*
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%6 = call i64 @malloc(i32 80)
%7 = inttoptr i64 %6 to double*
store double* %7, double** %3
%8 = load double*, double** %3
%9 = call i32 @test_comp_unit_1(i32 10, double* %8)
%10 = load double*, double** %3
%11 = call i32 @test_comp_unit_2(i32 10, double* %10)
store double 0.000000e+00, double* %4
store i32 0, i32* %5
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load double*, double** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = load double, double* %4
%22 = fadd double %21, %20
store double %22, double* %4
br label %23
23: ; preds = %15
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %12
26: ; preds = %12
%27 = load double, double* %4
%28 = fcmp olt double %27, 9.000100e+01
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %4
%31 = fcmp ogt double %30, 8.999900e+01
br label %32
32: ; preds = %29, %26
%33 = phi i1 [ false, %26 ], [ %31, %29 ]
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"--> %s <--\0A\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [6 x i8] c"error\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 80)
%2 = inttoptr i64 %1 to double*
%3 = tail call i32 @test_comp_unit_1(i32 10, double* %2)
%4 = tail call i32 @test_comp_unit_2(i32 10, double* %2)
%5 = load double, double* %2
%6 = fadd double %5, 0.000000e+00
%7 = getelementptr inbounds double, double* %2, i64 1
%8 = load double, double* %7
%9 = fadd double %6, %8
%10 = getelementptr inbounds double, double* %2, i64 2
%11 = load double, double* %10
%12 = fadd double %9, %11
%13 = getelementptr inbounds double, double* %2, i64 3
%14 = load double, double* %13
%15 = fadd double %12, %14
%16 = getelementptr inbounds double, double* %2, i64 4
%17 = load double, double* %16
%18 = fadd double %15, %17
%19 = getelementptr inbounds double, double* %2, i64 5
%20 = load double, double* %19
%21 = fadd double %18, %20
%22 = getelementptr inbounds double, double* %2, i64 6
%23 = load double, double* %22
%24 = fadd double %21, %23
%25 = getelementptr inbounds double, double* %2, i64 7
%26 = load double, double* %25
%27 = fadd double %24, %26
%28 = getelementptr inbounds double, double* %2, i64 8
%29 = load double, double* %28
%30 = fadd double %27, %29
%31 = getelementptr inbounds double, double* %2, i64 9
%32 = load double, double* %31
%33 = fadd double %30, %32
%34 = fcmp olt double %33, 9.000100e+01
%35 = fcmp ogt double %33, 8.999900e+01
%36 = and i1 %34, %35
%37 = select i1 %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%38 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %37)
ret i32 0
}