#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__ M_PI;
int fabs(scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  double pi = 0.0;
  long long i;
#pragma acc parallel
#pragma acc loop reduction(+ : pi)
  for (i = 0; i < 2000000000; i++) {
    double t = ((double)i + 0.5) / 2000000000;
    pi += 4.0 / (1.0 + t * t);
  }
  pi /= 2000000000;
  if (fabs(pi - M_PI) > 1e-10) {
    printf("error. result = %lf\n", pi);
    return 1;
  }
  printf("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x77359400,-0x18(%rbp)
77
jge    11b1 <main+0x91>
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xec5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xea1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe92(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe7e(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113f <main+0x1f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    0x2e15(%rip),%rax
cvtsi2sdq (%rax),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe0e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121b <main+0xfb>
movsd  -0x10(%rbp),%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1230 <main+0x110>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm6,%xmm6
xor    %eax,%eax
movsd  0xec1(%rip),%xmm0
movsd  0xec1(%rip),%xmm1
movsd  0xec1(%rip),%xmm2
movsd  0xec1(%rip),%xmm3
nopw   0x0(%rax,%rax,1)
xorps  %xmm4,%xmm4
cvtsi2sd %rax,%xmm4
addsd  %xmm0,%xmm4
divsd  %xmm1,%xmm4
mulsd  %xmm4,%xmm4
addsd  %xmm2,%xmm4
movapd %xmm3,%xmm5
divsd  %xmm4,%xmm5
addsd  %xmm5,%xmm6
add    $0x1,%rax
cmp    $0x77359400,%rax
jne    1160 <main+0x30>
divsd  0xe70(%rip),%xmm6
mov    0x2e49(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdq (%rax),%xmm0
movsd  %xmm6,(%rsp)
movapd %xmm6,%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1050 <fabs@plt>
test   %eax,%eax
jle    11dc <main+0xac>
lea    0xe57(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@M_PI = global i64 0
@.str = [21 x i8] c"error. result = %lf\0A\00"
@.str.1 = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i64
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store i64 0, i64* %3
br label %5
5: ; preds = %19, %0
%6 = load i64, i64* %3
%7 = icmp slt i64 %6, 2000000000
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i64, i64* %3
%10 = sitofp i64 %9 to double
%11 = fadd double %10, 5.000000e-01
%12 = fdiv double %11, 2.000000e+09
store double %12, double* %4
%13 = load double, double* %4
%14 = load double, double* %4
%15 = call double @llvm.fmuladd.f64(double %13, double %14, double 1.000000e+00)
%16 = fdiv double 4.000000e+00, %15
%17 = load double, double* %2
%18 = fadd double %17, %16
store double %18, double* %2
br label %19
19: ; preds = %8
%20 = load i64, i64* %3
%21 = add nsw i64 %20, 1
store i64 %21, i64* %3
br label %5
22: ; preds = %5
%23 = load double, double* %2
%24 = fdiv double %23, 2.000000e+09
store double %24, double* %2
%25 = load double, double* %2
%26 = load i64, i64* @M_PI
%27 = sitofp i64 %26 to double
%28 = fsub double %25, %27
%29 = fptosi double %28 to i64
%30 = call i32 @fabs(i64 %29)
%31 = sitofp i32 %30 to double
%32 = fcmp ogt double %31, 1.000000e-10
br i1 %32, label %33, label %36
33: ; preds = %22
%34 = load double, double* %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %34)
store i32 1, i32* %1
br label %38
36: ; preds = %22
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@M_PI = global i64 0
@.str = [21 x i8] c"error. result = %lf\0A\00"
@str = [5 x i8] c"PASS\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %10, %1 ]
%3 = phi double [ 0.000000e+00, %0 ], [ %9, %1 ]
%4 = sitofp i64 %2 to double
%5 = fadd double %4, 5.000000e-01
%6 = fdiv double %5, 2.000000e+09
%7 = tail call double @llvm.fmuladd.f64(double %6, double %6, double 1.000000e+00)
%8 = fdiv double 4.000000e+00, %7
%9 = fadd double %3, %8
%10 = add nuw nsw i64 %2, 1
%11 = icmp eq i64 %10, 2000000000
br i1 %11, label %12, label %1
12: ; preds = %1
%13 = fdiv double %9, 2.000000e+09
%14 = load i64, i64* @M_PI
%15 = sitofp i64 %14 to double
%16 = fsub double %13, %15
%17 = fptosi double %16 to i64
%18 = tail call i32 @fabs(i64 %17)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %13)
br label %24
22: ; preds = %12
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ 1, %20 ], [ 0, %22 ]
ret i32 %25
}