int main() {
  double e = compute_e(1);
  printf("     e = %.15f or %a\n", e, e);
  if (e != 0x1.5bf0a8b145769p+1)
    printf(" --- ERROR!\n\n");
  double pi_machin = compute_pi_machin(1.0 / 5, 1.0 / 239);
  double pi_gauss = compute_pi_gauss(1.0 / 18, 1.0 / 57, 1.0 / 239);
  double pi_brent = compute_pi_brent(1.0, 1 / sqrt(2), 0.25, 1.0);
  printf("    pi = %.15f or %a (Machin)\n", pi_machin, pi_machin);
  if (pi_machin != 0x1.921fb54442d15p+1)
    printf(" --- ERROR!\n\n");
  printf("    pi = %.15f or %a (Gauss)\n", pi_gauss, pi_gauss);
  if (pi_gauss != 0x1.921fb54442d17p+1)
    printf(" --- ERROR!\n\n");
  printf("    pi = %.15f or %a (Brent-Salamin)\n", pi_brent, pi_brent);
  if (pi_brent != 0x1.921fb54442d1ap+1)
    printf(" --- ERROR!\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <compute_e@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xec3(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11be <main+0x5e>
jp     11be <main+0x5e>
jmp    11cc <main+0x6c>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  0xe6c(%rip),%xmm0
movsd  0xe5c(%rip),%xmm1
mov    $0x2,%al
call   1070 <compute_pi_machin@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe34(%rip),%xmm0
movsd  0xe34(%rip),%xmm1
movsd  0xe34(%rip),%xmm2
mov    $0x3,%al
call   1060 <compute_pi_gauss@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe04(%rip),%xmm0
call   1080 <sqrt@plt>
movsd  0xde7(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xddb(%rip),%xmm3
movsd  0xddb(%rip),%xmm2
movaps %xmm3,%xmm0
mov    $0x4,%al
call   1030 <compute_pi_brent@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe1b(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xd93(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    128a <main+0x12a>
jp     128a <main+0x12a>
jmp    1298 <main+0x138>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xdf2(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xd8b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12d2 <main+0x172>
jp     12d2 <main+0x172>
jmp    12e0 <main+0x180>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xdc8(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xd4b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    131a <main+0x1ba>
jp     131a <main+0x1ba>
jmp    1328 <main+0x1c8>
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <compute_e@plt>
cvtsi2sd %eax,%xmm0
lea    0xebc(%rip),%rdi
movapd %xmm0,%xmm1
mov    $0x2,%al
call   1060 <printf@plt>
lea    0xf23(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
movsd  0xe62(%rip),%xmm0
movsd  0xe62(%rip),%xmm1
mov    $0x2,%al
call   1080 <compute_pi_machin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0xe4e(%rip),%xmm0
movsd  0xe4e(%rip),%xmm1
movsd  0xe36(%rip),%xmm2
mov    $0x3,%al
call   1070 <compute_pi_gauss@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe32(%rip),%xmm1
movsd  0xe32(%rip),%xmm2
movsd  0xe32(%rip),%xmm0
movaps %xmm0,%xmm3
mov    $0x4,%al
call   1040 <compute_pi_brent@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe32(%rip),%rdi
movsd  0x18(%rsp),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe32(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe31(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c" e = %.15f or %a\0A\00"
@.str.1 = [14 x i8] c" --- ERROR!\0A\0A\00"
@.str.2 = [31 x i8] c" pi = %.15f or %a (Machin)\0A\00"
@.str.3 = [30 x i8] c" pi = %.15f or %a (Gauss)\0A\00"
@.str.4 = [38 x i8] c" pi = %.15f or %a (Brent-Salamin)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i32, ...) bitcast (i32 (...)* @compute_e to i32 (i32, ...)*)(i32 1)
%7 = sitofp i32 %6 to double
store double %7, double* %2
%8 = load double, double* %2
%9 = load double, double* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %8, double %9)
%11 = load double, double* %2
%12 = fcmp une double %11, 0x4005BF0A8B145769
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
%16 = call i32 (double, double, ...) bitcast (i32 (...)* @compute_pi_machin to i32 (double, double, ...)*)(double 2.000000e-01, double 0x3F712358E75D3033)
%17 = sitofp i32 %16 to double
store double %17, double* %3
%18 = call i32 (double, double, double, ...) bitcast (i32 (...)* @compute_pi_gauss to i32 (double, double, double, ...)*)(double 0x3FAC71C71C71C71C, double 0x3F91F7047DC11F70, double 0x3F712358E75D3033)
%19 = sitofp i32 %18 to double
store double %19, double* %4
%20 = call double @sqrt(double 2.000000e+00)
%21 = fdiv double 1.000000e+00, %20
%22 = call i32 (double, double, double, double, ...) bitcast (i32 (...)* @compute_pi_brent to i32 (double, double, double, double, ...)*)(double 1.000000e+00, double %21, double 2.500000e-01, double 1.000000e+00)
%23 = sitofp i32 %22 to double
store double %23, double* %5
%24 = load double, double* %3
%25 = load double, double* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), double %24, double %25)
%27 = load double, double* %3
%28 = fcmp une double %27, 0x400921FB54442D15
br i1 %28, label %29, label %31
29: ; preds = %15
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %15
%32 = load double, double* %4
%33 = load double, double* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), double %32, double %33)
%35 = load double, double* %4
%36 = fcmp une double %35, 0x400921FB54442D17
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %31
%40 = load double, double* %5
%41 = load double, double* %5
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), double %40, double %41)
%43 = load double, double* %5
%44 = fcmp une double %43, 0x400921FB54442D1A
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %45, %39
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c" e = %.15f or %a\0A\00"
@.str.2 = [31 x i8] c" pi = %.15f or %a (Machin)\0A\00"
@.str.3 = [30 x i8] c" pi = %.15f or %a (Gauss)\0A\00"
@.str.4 = [38 x i8] c" pi = %.15f or %a (Brent-Salamin)\0A\00"
@str.7 = [13 x i8] c" --- ERROR!\0A\00"
define i32 @main() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @compute_e to i32 (i32, ...)*)(i32 1)
%2 = sitofp i32 %1 to double
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %2, double %2)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 (double, double, ...) bitcast (i32 (...)* @compute_pi_machin to i32 (double, double, ...)*)(double 2.000000e-01, double 0x3F712358E75D3033)
%6 = sitofp i32 %5 to double
%7 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @compute_pi_gauss to i32 (double, double, double, ...)*)(double 0x3FAC71C71C71C71C, double 0x3F91F7047DC11F70, double 0x3F712358E75D3033)
%8 = sitofp i32 %7 to double
%9 = tail call i32 (double, double, double, double, ...) bitcast (i32 (...)* @compute_pi_brent to i32 (double, double, double, double, ...)*)(double 1.000000e+00, double 0x3FE6A09E667F3BCC, double 2.500000e-01, double 1.000000e+00)
%10 = sitofp i32 %9 to double
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), double %6, double %6)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), double %8, double %8)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), double %10, double %10)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}