// File: /workspace/github_cpp_makefile_star2_O2/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 $0xb8, %rsp
movq %rcx, %rbx
movq %rdx, -0xd0(%rbp)
movq %rsi, -0xd8(%rbp)
movq %rdi, -0xc8(%rbp)
leaq 0x1c80(%rip), %rsi      # 0x5004
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x2a28
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x48(%rbp), %rdi
callq 0x2080
leaq -0x60(%rbp), %rdi
callq 0x2b10
leaq 0x1c4d(%rip), %rsi      # 0x5004
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2a28
leaq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x88(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movq %rbx, %rdx
callq 0x31a2
leaq -0x58(%rbp), %rdi
callq 0x2cf8
leaq -0x48(%rbp), %rdi
callq 0x2080
leaq -0x58(%rbp), %rdi
callq 0x2b10
leaq 0x1cf7(%rip), %rsi      # 0x50fd
leaq -0x48(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x2a28
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x48(%rbp), %rdi
callq 0x2080
leaq -0xa8(%rbp), %rdi
callq 0x2b10
leaq 0x1bc5(%rip), %rsi      # 0x5004
leaq -0x48(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x2a28
leaq -0xa0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x48(%rbp), %rdi
callq 0x2080
leaq -0x98(%rbp), %rdi
callq 0x2b10
leaq -0x90(%rbp), %rdi
callq 0x2b10
leaq -0xb8(%rbp), %rdi
callq 0x2b10
leaq 0x1c6f(%rip), %rsi      # 0x5102
leaq -0x48(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x2a28
leaq -0xc0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x48(%rbp), %rdi
callq 0x2080
leaq 0x1ba0(%rip), %rsi      # 0x5063
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x2a28
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x48(%rbp), %r12
movq %r12, %rdi
callq 0x2080
xorl %r14d, %r14d
leaq -0x50(%rbp), %r13
movq -0xd8(%rbp), %rax
cmpq (%rax), %r14
jae 0x3683
movq %r13, %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x306c
movq %r12, %rdi
movq %r13, %rsi
leaq -0xc0(%rbp), %rdx
callq 0x3112
leaq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0x2e20
movq %r12, %rdi
callq 0x2cf8
movq %r13, %rdi
callq 0x2cf8
movq %r13, %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x3112
movq %r12, %rdi
movq %r13, %rsi
leaq -0x60(%rbp), %rdx
movq -0xd0(%rbp), %rcx
callq 0x3224
leaq -0x58(%rbp), %rdi
movq %r12, %rsi
callq 0x2e20
movq %r12, %rdi
callq 0x2cf8
movq %r13, %rdi
callq 0x2cf8
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x30c0
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2e20
movq %r12, %rdi
callq 0x2cf8
leaq -0x78(%rbp), %r15
movq %r15, %rdi
leaq -0xa0(%rbp), %rsi
movq %rbx, %rdx
callq 0x3112
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3112
movq %r12, %rdi
leaq -0x80(%rbp), %rsi
movq %r13, %rdx
callq 0x30c0
leaq -0xa8(%rbp), %rdi
movq %r12, %rsi
callq 0x2e20
movq %r12, %rdi
callq 0x2cf8
movq %r13, %rdi
callq 0x2cf8
leaq -0x78(%rbp), %rdi
callq 0x2cf8
movq %r12, %rdi
leaq -0xb0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x3112
leaq -0x98(%rbp), %rdi
movq %r12, %rsi
callq 0x2e20
movq %r12, %rdi
callq 0x2cf8
leaq -0x68(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2e20
leaq -0x88(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2e20
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x2e20
leaq -0xa0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2e20
incq %r14
jmp 0x34f3
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x306c
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e20
leaq -0x48(%rbp), %rdi
callq 0x2cf8
leaq 0x1a4f(%rip), %rsi      # 0x5106
leaq -0x48(%rbp), %rdi
leaq -0x69(%rbp), %rdx
callq 0x2a28
leaq -0x78(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2b4a
leaq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x3112
leaq -0xb8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2e20
leaq -0x50(%rbp), %rdi
callq 0x2cf8
leaq -0x78(%rbp), %rdi
callq 0x2cf8
leaq -0x48(%rbp), %rdi
callq 0x2080
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rdx
movq %rdx, %rsi
callq 0x3112
leaq -0x48(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
movq -0xc8(%rbp), %rbx
movq %rbx, %rdi
callq 0x31a2
leaq -0x48(%rbp), %rdi
callq 0x2cf8
leaq -0xb0(%rbp), %rdi
callq 0x2cf8
leaq -0xc0(%rbp), %rdi
callq 0x2cf8
leaq -0xb8(%rbp), %rdi
callq 0x2cf8
leaq -0x90(%rbp), %rdi
callq 0x2cf8
leaq -0x98(%rbp), %rdi
callq 0x2cf8
leaq -0xa0(%rbp), %rdi
callq 0x2cf8
leaq -0xa8(%rbp), %rdi
callq 0x2cf8
leaq -0x80(%rbp), %rdi
callq 0x2cf8
leaq -0x58(%rbp), %rdi
callq 0x2cf8
leaq -0x88(%rbp), %rdi
callq 0x2cf8
leaq -0x60(%rbp), %rdi
callq 0x2cf8
leaq -0x68(%rbp), %rdi
callq 0x2cf8
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3903
jmp 0x3950
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2cf8
jmp 0x37f7
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2cf8
jmp 0x3805
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x3953
jmp 0x3950
jmp 0x3903
jmp 0x3950
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x395f
movq %rax, %rbx
jmp 0x395f
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x396b
movq %rax, %rbx
jmp 0x396b
movq %rax, %rbx
jmp 0x3977
movq %rax, %rbx
jmp 0x3983
movq %rax, %rbx
jmp 0x398f
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x399b
movq %rax, %rbx
jmp 0x399b
movq %rax, %rbx
jmp 0x39a7
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x39b0
movq %rax, %rbx
jmp 0x39b0
movq %rax, %rbx
jmp 0x39b9
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2cf8
jmp 0x38bf
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x39c5
movq %rax, %rbx
jmp 0x39c5
movq %rax, %rbx
jmp 0x39ce
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2080
jmp 0x39d7
movq %rax, %rbx
jmp 0x39d7
jmp 0x3932
jmp 0x3939
jmp 0x3903
jmp 0x3950
movq %rax, %rbx
jmp 0x391e
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
jmp 0x3949
jmp 0x3950
jmp 0x3950
jmp 0x3950
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2cf8
leaq -0x50(%rbp), %rdi
callq 0x2cf8
jmp 0x392c
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x3949
movq %rax, %rbx
jmp 0x3945
jmp 0x3950
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2cf8
leaq -0x50(%rbp), %rdi
callq 0x2cf8
jmp 0x3953
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2cf8
leaq -0xc0(%rbp), %rdi
callq 0x2cf8
leaq -0xb8(%rbp), %rdi
callq 0x2cf8
leaq -0x90(%rbp), %rdi
callq 0x2cf8
leaq -0x98(%rbp), %rdi
callq 0x2cf8
leaq -0xa0(%rbp), %rdi
callq 0x2cf8
leaq -0xa8(%rbp), %rdi
callq 0x2cf8
leaq -0x80(%rbp), %rdi
callq 0x2cf8
leaq -0x58(%rbp), %rdi
callq 0x2cf8
leaq -0x88(%rbp), %rdi
callq 0x2cf8
leaq -0x60(%rbp), %rdi
callq 0x2cf8
leaq -0x68(%rbp), %rdi
callq 0x2cf8
movq %rbx, %rdi
callq 0x21d0
nop