#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 */
double sqrt(double);
double compute_pi_brent(double a0, double b0, double t0, double p0) {
  double a1 = (a0 + b0) / 2;
  double b1 = sqrt(a0 * b0);
  double t1 = t0 - p0 * (a0 - a1) * (a0 - a1);
  double p1 = p0 + p0;
  double a2 = (a1 + b1) / 2;
  double b2 = sqrt(a1 * b1);
  double t2 = t1 - p1 * (a1 - a2) * (a1 - a2);
  double p2 = p1 + p1;
  double a3 = (a2 + b2) / 2;
  double b3 = sqrt(a2 * b2);
  double t3 = t2 - p2 * (a2 - a3) * (a2 - a3);
  return (a3 + b3) * (a3 + b3) / (4 * t3);
}


x86 assembly (clang, -O0):
<compute_pi_brent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
subsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  -0x8(%rbp),%xmm2
subsd  -0x28(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  0xdbf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
subsd  -0x68(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  -0x48(%rbp),%xmm2
subsd  -0x68(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
addsd  -0x70(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd34(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_pi_brent>:
sub    $0x28,%rsp
movapd %xmm0,%xmm4
movapd %xmm0,%xmm5
addsd  %xmm1,%xmm5
mulsd  0xed8(%rip),%xmm5
mulsd  %xmm0,%xmm1
xorpd  %xmm6,%xmm6
ucomisd %xmm6,%xmm1
movsd  %xmm5,0x18(%rsp)
jb     1145 <compute_pi_brent+0x35>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    117c <compute_pi_brent+0x6c>
movapd %xmm1,%xmm0
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm4,0x20(%rsp)
call   1030 <sqrt@plt>
movsd  0x20(%rsp),%xmm4
xorpd  %xmm6,%xmm6
movsd  0x18(%rsp),%xmm5
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
subsd  %xmm5,%xmm4
movapd %xmm4,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm1,%xmm2
movapd %xmm5,%xmm4
addsd  %xmm0,%xmm4
mulsd  0xe60(%rip),%xmm4
addsd  %xmm3,%xmm3
mulsd  %xmm5,%xmm0
ucomisd %xmm6,%xmm0
movsd  %xmm4,0x20(%rsp)
jb     11ba <compute_pi_brent+0xaa>
sqrtsd %xmm0,%xmm0
jmp    11e3 <compute_pi_brent+0xd3>
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
call   1030 <sqrt@plt>
movsd  0x18(%rsp),%xmm5
movsd  0x20(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
subsd  %xmm4,%xmm5
movapd %xmm5,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm5,%xmm1
subsd  %xmm1,%xmm2
addsd  %xmm3,%xmm3
movapd %xmm0,%xmm5
addsd  %xmm4,%xmm5
mulsd  0xdf5(%rip),%xmm5
mulsd  %xmm4,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     121f <compute_pi_brent+0x10f>
sqrtsd %xmm0,%xmm0
jmp    124e <compute_pi_brent+0x13e>
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm5,0x18(%rsp)
call   1030 <sqrt@plt>
movsd  0x18(%rsp),%xmm5
movsd  0x20(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
subsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm3
subsd  %xmm3,%xmm2
addsd  %xmm5,%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xd9a(%rip),%xmm2
divsd  %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @compute_pi_brent(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%20 = load double, double* %5
%21 = load double, double* %6
%22 = fadd double %20, %21
%23 = fdiv double %22, 2.000000e+00
store double %23, double* %9
%24 = load double, double* %5
%25 = load double, double* %6
%26 = fmul double %24, %25
%27 = call double @sqrt(double %26)
store double %27, double* %10
%28 = load double, double* %7
%29 = load double, double* %8
%30 = load double, double* %5
%31 = load double, double* %9
%32 = fsub double %30, %31
%33 = fmul double %29, %32
%34 = load double, double* %5
%35 = load double, double* %9
%36 = fsub double %34, %35
%37 = fneg double %33
%38 = call double @llvm.fmuladd.f64(double %37, double %36, double %28)
store double %38, double* %11
%39 = load double, double* %8
%40 = load double, double* %8
%41 = fadd double %39, %40
store double %41, double* %12
%42 = load double, double* %9
%43 = load double, double* %10
%44 = fadd double %42, %43
%45 = fdiv double %44, 2.000000e+00
store double %45, double* %13
%46 = load double, double* %9
%47 = load double, double* %10
%48 = fmul double %46, %47
%49 = call double @sqrt(double %48)
store double %49, double* %14
%50 = load double, double* %11
%51 = load double, double* %12
%52 = load double, double* %9
%53 = load double, double* %13
%54 = fsub double %52, %53
%55 = fmul double %51, %54
%56 = load double, double* %9
%57 = load double, double* %13
%58 = fsub double %56, %57
%59 = fneg double %55
%60 = call double @llvm.fmuladd.f64(double %59, double %58, double %50)
store double %60, double* %15
%61 = load double, double* %12
%62 = load double, double* %12
%63 = fadd double %61, %62
store double %63, double* %16
%64 = load double, double* %13
%65 = load double, double* %14
%66 = fadd double %64, %65
%67 = fdiv double %66, 2.000000e+00
store double %67, double* %17
%68 = load double, double* %13
%69 = load double, double* %14
%70 = fmul double %68, %69
%71 = call double @sqrt(double %70)
store double %71, double* %18
%72 = load double, double* %15
%73 = load double, double* %16
%74 = load double, double* %13
%75 = load double, double* %17
%76 = fsub double %74, %75
%77 = fmul double %73, %76
%78 = load double, double* %13
%79 = load double, double* %17
%80 = fsub double %78, %79
%81 = fneg double %77
%82 = call double @llvm.fmuladd.f64(double %81, double %80, double %72)
store double %82, double* %19
%83 = load double, double* %17
%84 = load double, double* %18
%85 = fadd double %83, %84
%86 = load double, double* %17
%87 = load double, double* %18
%88 = fadd double %86, %87
%89 = fmul double %85, %88
%90 = load double, double* %19
%91 = fmul double 4.000000e+00, %90
%92 = fdiv double %89, %91
ret double %92
}

LLVM IR (-O2):
define double @compute_pi_brent(double %0, double %1, double %2, double %3) {
%5 = fadd double %0, %1
%6 = fmul double %5, 5.000000e-01
%7 = fmul double %0, %1
%8 = tail call double @sqrt(double %7)
%9 = fsub double %0, %6
%10 = fneg double %9
%11 = fmul double %10, %3
%12 = tail call double @llvm.fmuladd.f64(double %11, double %9, double %2)
%13 = fadd double %3, %3
%14 = fadd double %6, %8
%15 = fmul double %14, 5.000000e-01
%16 = fmul double %6, %8
%17 = tail call double @sqrt(double %16)
%18 = fsub double %6, %15
%19 = fneg double %13
%20 = fmul double %18, %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %18, double %12)
%22 = fadd double %13, %13
%23 = fadd double %17, %15
%24 = fmul double %23, 5.000000e-01
%25 = fmul double %17, %15
%26 = tail call double @sqrt(double %25)
%27 = fsub double %15, %24
%28 = fneg double %22
%29 = fmul double %27, %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double %27, double %21)
%31 = fadd double %26, %24
%32 = fmul double %31, %31
%33 = fmul double %30, 4.000000e+00
%34 = fdiv double %32, %33
ret double %34
}