// File: /workspace/github_cpp_makefile_star2_O3/aisthesis[P]realnumber/src/convergent_series.cpp
// Function: ConvergentSeries::gauss_legendre_pi(unsigned long const&, unsigned long const&, RealNumber const&)
RealNumber ConvergentSeries::gauss_legendre_pi(const std::size_t& pi_iterations,
                                               const std::size_t& sqrt_iterations, const RealNumber& sqrt_two) {
    RealNumber a("1.0");
    RealNumber a_next;
    RealNumber b = RealNumber("1.0") / sqrt_two;
    RealNumber b_next;
    RealNumber t("0.25");
    RealNumber t_next;
    RealNumber p("1.0");
    RealNumber p_next;
    RealNumber tmp1, tmp2;
    
    const RealNumber one_half("0.5");
    const RealNumber two("2.0");
    for (std::size_t i = 0; i < pi_iterations; ++i) {
        a_next = (a + b) * one_half;
        b_next = babylonian_sqrt(a * b, a_next, sqrt_iterations);
        tmp1 = a - a_next;
        t_next = t - p * tmp1 * tmp1;
        p_next = two * p;
        a = a_next;
        b = b_next;
        t = t_next;
        p = p_next;
    }
    tmp1 = a + b;
    tmp2 = RealNumber("4.0") * t;
    return tmp1 * tmp1 / tmp2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %rbx
movq %rdx, -0xd0(%rbp)
movq %rsi, -0xc0(%rbp)
movq %rdi, -0xc8(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1764(%rip), %rsi      # 0x5004
leaq 0x1760(%rip), %rdx      # 0x5007
leaq -0x48(%rbp), %rdi
callq 0x2d52
leaq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x38d6
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x78(%rbp), %rdi
callq 0x2df0
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x1713(%rip), %rsi      # 0x5004
leaq 0x170f(%rip), %rdx      # 0x5007
callq 0x2d52
leaq -0x50(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x366a
leaq -0x50(%rbp), %rdi
callq 0x304c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x393c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x50(%rbp), %rdi
callq 0x2df0
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x17a6(%rip), %rsi      # 0x50fd
leaq 0x17a3(%rip), %rdx      # 0x5101
callq 0x2d52
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x398c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xa8(%rbp), %rdi
callq 0x2df0
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x165a(%rip), %rsi      # 0x5004
leaq 0x1656(%rip), %rdx      # 0x5007
callq 0x2d52
leaq -0x88(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x39df
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xa0(%rbp), %rdi
callq 0x2df0
leaq -0x80(%rbp), %rdi
callq 0x2df0
leaq -0x98(%rbp), %rdi
callq 0x2df0
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x16f0(%rip), %rsi      # 0x5102
leaq 0x16ec(%rip), %rdx      # 0x5105
callq 0x2d52
leaq -0xb8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3a47
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x160a(%rip), %rsi      # 0x5063
leaq 0x1606(%rip), %rdx      # 0x5066
callq 0x2d52
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3a8e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0xc0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3c2e
xorl %ebx, %ebx
leaq -0x58(%rbp), %r12
leaq -0x48(%rbp), %r14
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x34be
movq %r14, %rdi
movq %r12, %rsi
leaq -0xb8(%rbp), %rdx
callq 0x35a8
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x31b4
movq %r14, %rdi
callq 0x304c
movq %r12, %rdi
callq 0x304c
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x35a8
movq %r14, %rdi
movq %r12, %rsi
leaq -0x78(%rbp), %rdx
movq -0xd0(%rbp), %rcx
callq 0x370c
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x31b4
movq %r14, %rdi
callq 0x304c
movq %r12, %rdi
callq 0x304c
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x352c
leaq -0x80(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x31b4
movq %r14, %rdi
callq 0x304c
leaq -0x68(%rbp), %r15
movq %r15, %rdi
leaq -0x88(%rbp), %rsi
movq %r13, %rdx
callq 0x35a8
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x35a8
movq %r14, %rdi
leaq -0x90(%rbp), %rsi
movq %r12, %rdx
callq 0x352c
leaq -0xa8(%rbp), %rdi
movq %r14, %rsi
callq 0x31b4
movq %r14, %rdi
callq 0x304c
movq %r12, %rdi
callq 0x304c
leaq -0x68(%rbp), %rdi
callq 0x304c
movq %r14, %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x35a8
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x31b4
movq %r14, %rdi
callq 0x304c
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x31b4
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x31b4
leaq -0x90(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x31b4
leaq -0x88(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x31b4
incq %rbx
movq -0xc0(%rbp), %rax
cmpq (%rax), %rbx
jb 0x3aa9
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x34be
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x31b4
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x304c
leaq -0x38(%rbp), %rax
movq %rax, (%rbx)
leaq 0x14a0(%rip), %rsi      # 0x5106
leaq 0x149c(%rip), %rdx      # 0x5109
leaq -0x48(%rbp), %rdi
callq 0x2d52
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e50
movq -0xc8(%rbp), %rbx
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x35a8
leaq -0x98(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x31b4
leaq -0x58(%rbp), %rdi
callq 0x304c
leaq -0x68(%rbp), %rdi
callq 0x304c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3cd9
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movq %rdx, %rsi
callq 0x35a8
leaq -0x48(%rbp), %rsi
leaq -0x98(%rbp), %rdx
movq %rbx, %rdi
callq 0x366a
leaq -0x48(%rbp), %rdi
callq 0x304c
leaq -0xb0(%rbp), %rdi
callq 0x304c
leaq -0xb8(%rbp), %rdi
callq 0x304c
leaq -0x98(%rbp), %rdi
callq 0x304c
leaq -0x80(%rbp), %rdi
callq 0x304c
leaq -0xa0(%rbp), %rdi
callq 0x304c
leaq -0x88(%rbp), %rdi
callq 0x304c
leaq -0xa8(%rbp), %rdi
callq 0x304c
leaq -0x90(%rbp), %rdi
callq 0x304c
leaq -0x50(%rbp), %rdi
callq 0x304c
leaq -0x70(%rbp), %rdi
callq 0x304c
leaq -0x78(%rbp), %rdi
callq 0x304c
leaq -0x60(%rbp), %rdi
callq 0x304c
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f8d
jmp 0x3f9b
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x304c
jmp 0x3db6
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x304c
jmp 0x3dc4
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3f9e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3f9e
jmp 0x3f9b
jmp 0x3f8d
jmp 0x3f9b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3faa
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3faa
movq %rax, %rbx
jmp 0x3faa
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fb6
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3fb6
movq %rax, %rbx
jmp 0x3fb6
movq %rax, %rbx
jmp 0x3fc2
movq %rax, %rbx
jmp 0x3fcb
movq %rax, %rbx
jmp 0x3fd7
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fe3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3fe3
movq %rax, %rbx
jmp 0x3fe3
movq %rax, %rbx
jmp 0x3fef
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3ffb
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3ffb
movq %rax, %rbx
jmp 0x3ffb
movq %rax, %rbx
jmp 0x4004
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x304c
jmp 0x3ee2
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x400d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x400d
movq %rax, %rbx
jmp 0x400d
movq %rax, %rbx
jmp 0x4016
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x401f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x401f
movq %rax, %rbx
jmp 0x401f
jmp 0x3f9b
jmp 0x3f49
jmp 0x3f4e
jmp 0x3f9b
movq %rax, %rbx
jmp 0x3f5a
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x304c
leaq -0x58(%rbp), %rdi
jmp 0x3f94
jmp 0x3f9b
jmp 0x3f8d
jmp 0x3f9b
movq %rax, %rbx
jmp 0x3f85
movq %rax, %rbx
jmp 0x3f7c
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x304c
leaq -0x58(%rbp), %rdi
callq 0x304c
leaq -0x68(%rbp), %rdi
jmp 0x3f94
jmp 0x3f9b
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x304c
jmp 0x3f9e
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x304c
leaq -0xb8(%rbp), %rdi
callq 0x304c
leaq -0x98(%rbp), %rdi
callq 0x304c
leaq -0x80(%rbp), %rdi
callq 0x304c
leaq -0xa0(%rbp), %rdi
callq 0x304c
leaq -0x88(%rbp), %rdi
callq 0x304c
leaq -0xa8(%rbp), %rdi
callq 0x304c
leaq -0x90(%rbp), %rdi
callq 0x304c
leaq -0x50(%rbp), %rdi
callq 0x304c
leaq -0x70(%rbp), %rdi
callq 0x304c
leaq -0x78(%rbp), %rdi
callq 0x304c
leaq -0x60(%rbp), %rdi
callq 0x304c
movq %rbx, %rdi
callq 0x2210
nop