#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 *, double);
int main() {
  int i;
  double x, area = 0;
  for (i = 0; i < 1000000; i++) {
    x = (i + .5) / 1000000;
    area += 4 / (1 + x * x);
  }
  printf("%.10lf\n", area / 1000000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    119b <main+0x8b>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xed0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xeac(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112e <main+0x1e>
movsd  -0x18(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm0,%xmm0
mov    $0xf4240,%eax
movsd  0xede(%rip),%xmm1
movsd  0xede(%rip),%xmm2
movsd  0xede(%rip),%xmm3
movsd  0xede(%rip),%xmm4
xorpd  %xmm5,%xmm5
xchg   %ax,%ax
movapd %xmm5,%xmm6
addsd  %xmm1,%xmm6
divsd  %xmm2,%xmm6
mulsd  %xmm6,%xmm6
addsd  %xmm3,%xmm6
movapd %xmm4,%xmm7
divsd  %xmm6,%xmm7
addsd  %xmm7,%xmm0
addsd  %xmm3,%xmm5
add    $0xffffffff,%eax
jne    1140 <main+0x30>
divsd  0xe97(%rip),%xmm0
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%.10lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
store i32 0, i32* %2
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1000000
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sitofp i32 %9 to double
%11 = fadd double %10, 5.000000e-01
%12 = fdiv double %11, 1.000000e+06
store double %12, double* %3
%13 = load double, double* %3
%14 = load double, double* %3
%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* %4
%18 = fadd double %17, %16
store double %18, double* %4
br label %19
19: ; preds = %8
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %5
22: ; preds = %5
%23 = load double, double* %4
%24 = fdiv double %23, 1.000000e+06
%25 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%.10lf\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 0.000000e+00, %0 ], [ %9, %1 ]
%3 = phi i32 [ 0, %0 ], [ %10, %1 ]
%4 = sitofp i32 %3 to double
%5 = fadd double %4, 5.000000e-01
%6 = fdiv double %5, 1.000000e+06
%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 %2, %8
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 1000000
br i1 %11, label %12, label %1
12: ; preds = %1
%13 = fdiv double %9, 1.000000e+06
%14 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %13)
ret i32 0
}