#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*/ printf(char *, float);
double sqrt(int);
int main() {
  double pi;
  int i = 0;
  double s = 0.0;
  double x[10000], y[10000];
#pragma omp parallel for
  for (i = 0; i < 9999; i++) {
    x[i] = (double)i / 10000.0f;
    x[i + 1] = (double)(i + 1) / 10000.0f;
    y[i] = sqrt(1 - x[i] * x[i]);
    y[i + 1] = sqrt(1 - x[i + 1] * x[i + 1]);
#pragma omp critical
    s += (y[i] + y[i + 1]) / 2.0f / 10000.0f;
  }
  printf("%10.9f\n", 4.0f * s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x270f,-0x14(%rbp)
jge    12a2 <main+0x182>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x138a0(%rbp,%rax,8)
fe ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x138a0(%rbp,%rax,8)
fe ff
movslq -0x14(%rbp),%rax
movsd  -0x138a0(%rbp,%rax,8),%xmm0
fe ff
movslq -0x14(%rbp),%rax
movsd  -0x138a0(%rbp,%rax,8),%xmm1
fe ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe41(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x27120(%rbp,%rax,8)
fd ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
movsd  -0x138a0(%rbp,%rax,8),%xmm0
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
movsd  -0x138a0(%rbp,%rax,8),%xmm1
fe ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xde2(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x27120(%rbp,%rax,8)
fd ff
movslq -0x14(%rbp),%rax
movsd  -0x27120(%rbp,%rax,8),%xmm0
fd ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
addsd  -0x27120(%rbp,%rax,8),%xmm0
fd ff
movsd  0xd96(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd82(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <main+0x28>
movsd  0xd56(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xd66(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x27120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
xorpd  %xmm2,%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
movsd  0xeaf(%rip),%xmm3
divsd  %xmm3,%xmm0
movsd  0xeab(%rip),%xmm4
addsd  %xmm4,%xmm2
movsd  %xmm2,0x18(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm3,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm0,%xmm0
movapd %xmm4,%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe63(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  0x18(%rsp),%xmm2
addsd  0x10(%rsp),%xmm0
mulsd  0xe4a(%rip),%xmm0
divsd  0xe32(%rip),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%ebx
cmp    $0x2710,%ebx
jne    1140 <main+0x20>
mulsd  0xe20(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%10.9f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca [10000 x double]
%6 = alloca [10000 x double]
store i32 0, i32* %1
store i32 0, i32* %3
store double 0.000000e+00, double* %4
store i32 0, i32* %3
br label %7
7: ; preds = %72, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 9999
br i1 %9, label %10, label %75
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 1.000000e+04
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10000 x double], [10000 x double]* %5, i64 0, i64 %15
store double %13, double* %16
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 1.000000e+04
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10000 x double], [10000 x double]* %5, i64 0, i64 %23
store double %20, double* %24
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10000 x double], [10000 x double]* %5, i64 0, i64 %26
%28 = load double, double* %27
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10000 x double], [10000 x double]* %5, i64 0, i64 %30
%32 = load double, double* %31
%33 = fneg double %28
%34 = call double @llvm.fmuladd.f64(double %33, double %32, double 1.000000e+00)
%35 = fptosi double %34 to i32
%36 = call double @sqrt(i32 %35)
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10000 x double], [10000 x double]* %6, i64 0, i64 %38
store double %36, double* %39
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10000 x double], [10000 x double]* %5, i64 0, i64 %42
%44 = load double, double* %43
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [10000 x double], [10000 x double]* %5, i64 0, i64 %47
%49 = load double, double* %48
%50 = fneg double %44
%51 = call double @llvm.fmuladd.f64(double %50, double %49, double 1.000000e+00)
%52 = fptosi double %51 to i32
%53 = call double @sqrt(i32 %52)
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [10000 x double], [10000 x double]* %6, i64 0, i64 %56
store double %53, double* %57
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10000 x double], [10000 x double]* %6, i64 0, i64 %59
%61 = load double, double* %60
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [10000 x double], [10000 x double]* %6, i64 0, i64 %64
%66 = load double, double* %65
%67 = fadd double %61, %66
%68 = fdiv double %67, 2.000000e+00
%69 = fdiv double %68, 1.000000e+04
%70 = load double, double* %4
%71 = fadd double %70, %69
store double %71, double* %4
br label %72
72: ; preds = %10
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 1
store i32 %74, i32* %3
br label %7
75: ; preds = %7
%76 = load double, double* %4
%77 = fmul double 4.000000e+00, %76
%78 = fptrunc double %77 to float
%79 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), float %78)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%10.9f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 0.000000e+00, %0 ], [ %20, %1 ]
%3 = phi i32 [ 0, %0 ], [ %6, %1 ]
%4 = sitofp i32 %3 to double
%5 = fdiv double %4, 1.000000e+04
%6 = add nuw nsw i32 %3, 1
%7 = sitofp i32 %6 to double
%8 = fdiv double %7, 1.000000e+04
%9 = fneg double %5
%10 = tail call double @llvm.fmuladd.f64(double %9, double %5, double 1.000000e+00)
%11 = fptosi double %10 to i32
%12 = tail call double @sqrt(i32 %11)
%13 = fneg double %8
%14 = tail call double @llvm.fmuladd.f64(double %13, double %8, double 1.000000e+00)
%15 = fptosi double %14 to i32
%16 = tail call double @sqrt(i32 %15)
%17 = fadd double %12, %16
%18 = fmul double %17, 5.000000e-01
%19 = fdiv double %18, 1.000000e+04
%20 = fadd double %2, %19
%21 = icmp eq i32 %6, 9999
br i1 %21, label %22, label %1
22: ; preds = %1
%23 = fmul double %20, 4.000000e+00
%24 = fptrunc double %23 to float
%25 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), float %24)
ret i32 0
}