// File: /workspace/github_cpp_makefile_star2_O1/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 0x1748(%rip), %rsi      # 0x5004
leaq 0x1744(%rip), %rdx      # 0x5007
leaq -0x48(%rbp), %rdi
callq 0x2d52
leaq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x38f2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x78(%rbp), %rdi
callq 0x2dec
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x16f7(%rip), %rsi      # 0x5004
leaq 0x16f3(%rip), %rdx      # 0x5007
callq 0x2d52
leaq -0x50(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x3684
leaq -0x50(%rbp), %rdi
callq 0x3048
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3958
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x50(%rbp), %rdi
callq 0x2dec
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x178a(%rip), %rsi      # 0x50fd
leaq 0x1787(%rip), %rdx      # 0x5101
callq 0x2d52
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x39a8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xa8(%rbp), %rdi
callq 0x2dec
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x163e(%rip), %rsi      # 0x5004
leaq 0x163a(%rip), %rdx      # 0x5007
callq 0x2d52
leaq -0x88(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x39fb
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xa0(%rbp), %rdi
callq 0x2dec
leaq -0x80(%rbp), %rdi
callq 0x2dec
leaq -0x98(%rbp), %rdi
callq 0x2dec
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x16d4(%rip), %rsi      # 0x5102
leaq 0x16d0(%rip), %rdx      # 0x5105
callq 0x2d52
leaq -0xb8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3a63
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x15ee(%rip), %rsi      # 0x5063
leaq 0x15ea(%rip), %rdx      # 0x5066
callq 0x2d52
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3aaa
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0xc0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3c4a
xorl %ebx, %ebx
leaq -0x58(%rbp), %r12
leaq -0x48(%rbp), %r14
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x34d8
movq %r14, %rdi
movq %r12, %rsi
leaq -0xb8(%rbp), %rdx
callq 0x35c2
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x31b0
movq %r14, %rdi
callq 0x3048
movq %r12, %rdi
callq 0x3048
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x35c2
movq %r14, %rdi
movq %r12, %rsi
leaq -0x78(%rbp), %rdx
movq -0xd0(%rbp), %rcx
callq 0x3728
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x31b0
movq %r14, %rdi
callq 0x3048
movq %r12, %rdi
callq 0x3048
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x3546
leaq -0x80(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x31b0
movq %r14, %rdi
callq 0x3048
leaq -0x68(%rbp), %r15
movq %r15, %rdi
leaq -0x88(%rbp), %rsi
movq %r13, %rdx
callq 0x35c2
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x35c2
movq %r14, %rdi
leaq -0x90(%rbp), %rsi
movq %r12, %rdx
callq 0x3546
leaq -0xa8(%rbp), %rdi
movq %r14, %rsi
callq 0x31b0
movq %r14, %rdi
callq 0x3048
movq %r12, %rdi
callq 0x3048
leaq -0x68(%rbp), %rdi
callq 0x3048
movq %r14, %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x35c2
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x31b0
movq %r14, %rdi
callq 0x3048
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x31b0
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x31b0
leaq -0x90(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x31b0
leaq -0x88(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x31b0
incq %rbx
movq -0xc0(%rbp), %rax
cmpq (%rax), %rbx
jb 0x3ac5
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x34d8
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x31b0
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x3048
leaq -0x38(%rbp), %rax
movq %rax, (%rbx)
leaq 0x1484(%rip), %rsi      # 0x5106
leaq 0x1480(%rip), %rdx      # 0x5109
leaq -0x48(%rbp), %rdi
callq 0x2d52
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e4c
movq -0xc8(%rbp), %rbx
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x35c2
leaq -0x98(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x31b0
leaq -0x58(%rbp), %rdi
callq 0x3048
leaq -0x68(%rbp), %rdi
callq 0x3048
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3cf5
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movq %rdx, %rsi
callq 0x35c2
leaq -0x48(%rbp), %rsi
leaq -0x98(%rbp), %rdx
movq %rbx, %rdi
callq 0x3684
leaq -0x48(%rbp), %rdi
callq 0x3048
leaq -0xb0(%rbp), %rdi
callq 0x3048
leaq -0xb8(%rbp), %rdi
callq 0x3048
leaq -0x98(%rbp), %rdi
callq 0x3048
leaq -0x80(%rbp), %rdi
callq 0x3048
leaq -0xa0(%rbp), %rdi
callq 0x3048
leaq -0x88(%rbp), %rdi
callq 0x3048
leaq -0xa8(%rbp), %rdi
callq 0x3048
leaq -0x90(%rbp), %rdi
callq 0x3048
leaq -0x50(%rbp), %rdi
callq 0x3048
leaq -0x70(%rbp), %rdi
callq 0x3048
leaq -0x78(%rbp), %rdi
callq 0x3048
leaq -0x60(%rbp), %rdi
callq 0x3048
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3fa9
jmp 0x3fb7
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x3048
jmp 0x3dd2
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x3048
jmp 0x3de0
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fba
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3fba
jmp 0x3fb7
jmp 0x3fa9
jmp 0x3fb7
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fc6
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3fc6
movq %rax, %rbx
jmp 0x3fc6
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fd2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3fd2
movq %rax, %rbx
jmp 0x3fd2
movq %rax, %rbx
jmp 0x3fde
movq %rax, %rbx
jmp 0x3fe7
movq %rax, %rbx
jmp 0x3ff3
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fff
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3fff
movq %rax, %rbx
jmp 0x3fff
movq %rax, %rbx
jmp 0x400b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4017
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x4017
movq %rax, %rbx
jmp 0x4017
movq %rax, %rbx
jmp 0x4020
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3048
jmp 0x3efe
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4029
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x4029
movq %rax, %rbx
jmp 0x4029
movq %rax, %rbx
jmp 0x4032
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x403b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x403b
movq %rax, %rbx
jmp 0x403b
jmp 0x3fb7
jmp 0x3f65
jmp 0x3f6a
jmp 0x3fb7
movq %rax, %rbx
jmp 0x3f76
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3048
leaq -0x58(%rbp), %rdi
jmp 0x3fb0
jmp 0x3fb7
jmp 0x3fa9
jmp 0x3fb7
movq %rax, %rbx
jmp 0x3fa1
movq %rax, %rbx
jmp 0x3f98
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3048
leaq -0x58(%rbp), %rdi
callq 0x3048
leaq -0x68(%rbp), %rdi
jmp 0x3fb0
jmp 0x3fb7
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3048
jmp 0x3fba
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x3048
leaq -0xb8(%rbp), %rdi
callq 0x3048
leaq -0x98(%rbp), %rdi
callq 0x3048
leaq -0x80(%rbp), %rdi
callq 0x3048
leaq -0xa0(%rbp), %rdi
callq 0x3048
leaq -0x88(%rbp), %rdi
callq 0x3048
leaq -0xa8(%rbp), %rdi
callq 0x3048
leaq -0x90(%rbp), %rdi
callq 0x3048
leaq -0x50(%rbp), %rdi
callq 0x3048
leaq -0x70(%rbp), %rdi
callq 0x3048
leaq -0x78(%rbp), %rdi
callq 0x3048
leaq -0x60(%rbp), %rdi
callq 0x3048
movq %rbx, %rdi
callq 0x2210
nop