#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() {
  unsigned long long steps = 100000000;
  double ans = 0.0;
  double top = 1.0;
  double segment = top / (double)steps;
  for (unsigned long long i = 0; i < steps; i++) {
    double x = segment * ((double)i + 0.5);
    double height = 4.0 / (1.0 + x * x);
    ans += height * segment;
  }
  printf("%lf", ans);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x5f5e100,-0x10(%rbp)
05
movq   $0x0,-0x18(%rbp)
movabs $0x3ff0000000000000,%rax
mov    %rax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movaps 0xeb7(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xeb6(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1221 <main+0x111>
movsd  -0x28(%rbp),%xmm0
movaps 0xe6c(%rip),%xmm2
movq   -0x30(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xe6b(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe74(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe35(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    117a <main+0x6a>
movsd  -0x18(%rbp),%xmm0
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm0,%xmm0
xor    %eax,%eax
movdqa 0xee0(%rip),%xmm8
movapd 0xee8(%rip),%xmm2
movsd  0xef0(%rip),%xmm3
movsd  0xef0(%rip),%xmm4
movsd  0xef0(%rip),%xmm5
movsd  0xef0(%rip),%xmm6
nopl   0x0(%rax,%rax,1)
movq   %rax,%xmm1
punpckldq %xmm8,%xmm1
subpd  %xmm2,%xmm1
movapd %xmm1,%xmm7
unpckhpd %xmm1,%xmm7
addsd  %xmm1,%xmm7
addsd  %xmm3,%xmm7
mulsd  %xmm4,%xmm7
mulsd  %xmm7,%xmm7
addsd  %xmm5,%xmm7
movapd %xmm6,%xmm1
divsd  %xmm7,%xmm1
mulsd  %xmm4,%xmm1
addsd  %xmm0,%xmm1
lea    0x1(%rax),%rcx
movq   %rcx,%xmm0
punpckldq %xmm8,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm7
unpckhpd %xmm0,%xmm7
addsd  %xmm0,%xmm7
addsd  %xmm3,%xmm7
mulsd  %xmm4,%xmm7
mulsd  %xmm7,%xmm7
addsd  %xmm5,%xmm7
movapd %xmm6,%xmm0
divsd  %xmm7,%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
add    $0x2,%rax
cmp    $0x5f5e100,%rax
jne    1150 <main+0x40>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define i32 @main() {
br label %3
1: ; preds = %3
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %18)
ret i32 0
3: ; preds = %3, %0
%4 = phi double [ 0.000000e+00, %0 ], [ %18, %3 ]
%5 = phi i64 [ 0, %0 ], [ %19, %3 ]
%6 = uitofp i64 %5 to double
%7 = fadd double %6, 5.000000e-01
%8 = fmul double %7, 1.000000e-08
%9 = tail call double @llvm.fmuladd.f64(double %8, double %8, double 1.000000e+00)
%10 = fdiv double 4.000000e+00, %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double 1.000000e-08, double %4)
%12 = or i64 %5, 1
%13 = uitofp i64 %12 to double
%14 = fadd double %13, 5.000000e-01
%15 = fmul double %14, 1.000000e-08
%16 = tail call double @llvm.fmuladd.f64(double %15, double %15, double 1.000000e+00)
%17 = fdiv double 4.000000e+00, %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double 1.000000e-08, double %11)
%19 = add nuw nsw i64 %5, 2
%20 = icmp eq i64 %19, 100000000
br i1 %20, label %1, label %3
}