double pi_bbp(int n) {
  double coden = 1, t1den = 1, t2den = 4, t3den = 5, t4den = 6;
  double sum = 1 / coden * (4 / t1den - 2 / t2den - 1 / t3den - 1 / t4den);
  int i;
  for (i = 0; i < (n - 1); i++) {
    t1den += 8;
    t2den += 8;
    t3den += 8;
    t4den += 8;
    coden *= 16;
    sum += 1 / coden * (4 / t1den - 2 / t2den - 1 / t3den - 1 / t4den);
  }
  return (sum);
}


x86 assembly (clang, -O0):
<pi_bbp>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  0xef1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xee4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee7(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeea(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xed5(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeb0(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xeb3(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xe9e(%rip),%xmm2
divsd  -0x20(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0xe85(%rip),%xmm2
divsd  -0x28(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0xe74(%rip),%xmm2
divsd  -0x30(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    127d <pi_bbp+0x17d>
movsd  0xe72(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe60(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe4e(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe3c(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe22(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xde8(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xdeb(%rip),%xmm2
divsd  -0x18(%rbp),%xmm2
movsd  0xdd6(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm2
movsd  0xdbd(%rip),%xmm1
divsd  -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm2
movsd  0xdac(%rip),%xmm1
divsd  -0x30(%rbp),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a5 <pi_bbp+0xa5>
movsd  -0x38(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<pi_bbp>:
cmp    $0x2,%edi
jl     11b0 <pi_bbp+0xb0>
add    $0xffffffff,%edi
movapd 0xf0c(%rip),%xmm1
movapd 0xf14(%rip),%xmm2
movsd  0xee3(%rip),%xmm9
movsd  0xed3(%rip),%xmm0
movapd 0xf0a(%rip),%xmm12
movsd  0xed1(%rip),%xmm8
movapd 0xf08(%rip),%xmm10
movapd 0xf0f(%rip),%xmm11
movapd %xmm9,%xmm3
cs nopw 0x0(%rax,%rax,1)
addpd  %xmm12,%xmm1
addpd  %xmm12,%xmm2
mulsd  %xmm8,%xmm3
movapd %xmm9,%xmm5
divsd  %xmm3,%xmm5
movapd %xmm10,%xmm4
divpd  %xmm1,%xmm4
movapd %xmm11,%xmm7
divpd  %xmm2,%xmm7
movapd %xmm4,%xmm6
unpckhpd %xmm4,%xmm6
subsd  %xmm6,%xmm4
subsd  %xmm7,%xmm4
unpckhpd %xmm7,%xmm7
subsd  %xmm7,%xmm4
mulsd  %xmm5,%xmm4
addsd  %xmm4,%xmm0
add    $0xffffffff,%edi
jne    1160 <pi_bbp+0x60>
ret
movsd  0xe48(%rip),%xmm0
ret

LLVM IR (-O0):
define double @pi_bbp(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 1.000000e+00, double* %3
store double 1.000000e+00, double* %4
store double 4.000000e+00, double* %5
store double 5.000000e+00, double* %6
store double 6.000000e+00, double* %7
%10 = load double, double* %3
%11 = fdiv double 1.000000e+00, %10
%12 = load double, double* %4
%13 = fdiv double 4.000000e+00, %12
%14 = load double, double* %5
%15 = fdiv double 2.000000e+00, %14
%16 = fsub double %13, %15
%17 = load double, double* %6
%18 = fdiv double 1.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 = fmul double %11, %22
store double %23, double* %8
store i32 0, i32* %9
br label %24
24: ; preds = %55, %1
%25 = load i32, i32* %9
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %58
29: ; preds = %24
%30 = load double, double* %4
%31 = fadd double %30, 8.000000e+00
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* %3
%39 = fmul double %38, 1.600000e+01
store double %39, double* %3
%40 = load double, double* %3
%41 = fdiv double 1.000000e+00, %40
%42 = load double, double* %4
%43 = fdiv double 4.000000e+00, %42
%44 = load double, double* %5
%45 = fdiv double 2.000000e+00, %44
%46 = fsub double %43, %45
%47 = load double, double* %6
%48 = fdiv double 1.000000e+00, %47
%49 = fsub double %46, %48
%50 = load double, double* %7
%51 = fdiv double 1.000000e+00, %50
%52 = fsub double %49, %51
%53 = load double, double* %8
%54 = call double @llvm.fmuladd.f64(double %41, double %52, double %53)
store double %54, double* %8
br label %55
55: ; preds = %29
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %24
58: ; preds = %24
%59 = load double, double* %8
ret double %59
}

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