double piBBP(int n) {
  double sum = 0;
  double a = 1., b = 1., c = 4., d = 5., e = 6.;
  for (int j = 0; j < n; j++) {
    sum += ((4 / b) - (2 / c) - (1 / d) - (1 / e)) / a;
    a *= 16;
    b += 8;
    c += 8;
    d += 8;
    e += 8;
  }
  return sum;
}


x86 assembly (clang, -O0):
<piBBP>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xf01(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xef4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xedf(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeca(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121a <piBBP+0x11a>
movsd  0xea5(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe8f(%rip),%xmm1
divsd  -0x30(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe7e(%rip),%xmm1
divsd  -0x38(%rbp),%xmm1
subsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe6e(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe54(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe42(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe30(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe1e(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1157 <piBBP+0x57>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<piBBP>:
test   %edi,%edi
jle    1195 <piBBP+0x95>
movapd 0xef0(%rip),%xmm1
movapd 0xef8(%rip),%xmm2
xorpd  %xmm0,%xmm0
movsd  0xf2c(%rip),%xmm3
movapd 0xef3(%rip),%xmm8
movapd 0xefa(%rip),%xmm9
movsd  0xf19(%rip),%xmm10
movapd 0xef9(%rip),%xmm7
nopw   0x0(%rax,%rax,1)
movapd %xmm8,%xmm6
divpd  %xmm1,%xmm6
movapd %xmm9,%xmm5
divpd  %xmm2,%xmm5
movapd %xmm6,%xmm4
unpckhpd %xmm6,%xmm4
subsd  %xmm4,%xmm6
subsd  %xmm5,%xmm6
unpckhpd %xmm5,%xmm5
subsd  %xmm5,%xmm6
divsd  %xmm3,%xmm6
addsd  %xmm6,%xmm0
mulsd  %xmm10,%xmm3
addpd  %xmm7,%xmm1
addpd  %xmm7,%xmm2
add    $0xffffffff,%edi
jne    1150 <piBBP+0x50>
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @piBBP(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %2
store double 0.000000e+00, double* %3
store double 1.000000e+00, double* %4
store double 1.000000e+00, double* %5
store double 4.000000e+00, double* %6
store double 5.000000e+00, double* %7
store double 6.000000e+00, double* %8
store i32 0, i32* %9
br label %10
10: ; preds = %40, %1
%11 = load i32, i32* %9
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %43
14: ; preds = %10
%15 = load double, double* %5
%16 = fdiv double 4.000000e+00, %15
%17 = load double, double* %6
%18 = fdiv double 2.000000e+00, %17
%19 = fsub double %16, %18
%20 = load double, double* %7
%21 = fdiv double 1.000000e+00, %20
%22 = fsub double %19, %21
%23 = load double, double* %8
%24 = fdiv double 1.000000e+00, %23
%25 = fsub double %22, %24
%26 = load double, double* %4
%27 = fdiv double %25, %26
%28 = load double, double* %3
%29 = fadd double %28, %27
store double %29, double* %3
%30 = load double, double* %4
%31 = fmul double %30, 1.600000e+01
store double %31, double* %4
%32 = load double, double* %5
%33 = fadd double %32, 8.000000e+00
store double %33, double* %5
%34 = load double, double* %6
%35 = fadd double %34, 8.000000e+00
store double %35, double* %6
%36 = load double, double* %7
%37 = fadd double %36, 8.000000e+00
store double %37, double* %7
%38 = load double, double* %8
%39 = fadd double %38, 8.000000e+00
store double %39, double* %8
br label %40
40: ; preds = %14
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %10
43: ; preds = %10
%44 = load double, double* %3
ret double %44
}

LLVM IR (-O2):
define double @piBBP(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %5, %1
%4 = phi double [ 0.000000e+00, %1 ], [ %20, %5 ]
ret double %4
5: ; preds = %1, %5
%6 = phi i32 [ %24, %5 ], [ 0, %1 ]
%7 = phi double [ %21, %5 ], [ 1.000000e+00, %1 ]
%8 = phi double [ %20, %5 ], [ 0.000000e+00, %1 ]
%9 = phi <2 x double> [ %23, %5 ], [ <double 5.000000e+00, double 6.000000e+00>, %1 ]
%10 = phi <2 x double> [ %22, %5 ], [ <double 1.000000e+00, double 4.000000e+00>, %1 ]
%11 = fdiv <2 x double> <double 4.000000e+00, double 2.000000e+00>, %10
%12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%13 = fsub <2 x double> %11, %12
%14 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %9
%15 = fsub <2 x double> %13, %14
%16 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%17 = fsub <2 x double> %15, %16
%18 = extractelement <2 x double> %17, i64 0
%19 = fdiv double %18, %7
%20 = fadd double %8, %19
%21 = fmul double %7, 1.600000e+01
%22 = fadd <2 x double> %10, <double 8.000000e+00, double 8.000000e+00>
%23 = fadd <2 x double> %9, <double 8.000000e+00, double 8.000000e+00>
%24 = add nuw nsw i32 %6, 1
%25 = icmp eq i32 %24, %0
br i1 %25, label %3, label %5
}