// File: j-faria[P]kima/src/RVmodel.cpp
// Function: kepler::refine_estimate(double, double, double, double)
inline double refine_estimate(double M, double ecc, double ome, double E)
    {
        double sE = E - sin(E);
        double cE = 1 - cos(E);

        double f_0 = ecc * sE + E * ome - M;
        double f_1 = ecc * cE + ome;
        double f_2 = ecc * (E - sE);
        double f_3 = 1 - f_1;
        double d_3 = -f_0 / (f_1 - 0.5 * f_0 * f_2 / f_1);
        double d_4 = -f_0 / (f_1 + 0.5 * d_3 * f_2 + (d_3 * d_3) * f_3 / 6);
        double d_42 = d_4 * d_4;
        double dE = -f_0 /
                (f_1 + 0.5 * d_4 * f_2 + d_4 * d_4 * f_3 / 6 - d_42 * d_4 * f_2 / 24);

        return E + dE;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movsd %xmm0, -0x8(%rbp)
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
movsd %xmm3, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x60e0
movaps %xmm0, %xmm1
movsd -0x78(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x68e0
movaps %xmm0, %xmm1
movsd 0x8b517(%rip), %xmm0    # 0xb7030
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x28(%rbp), %xmm2
movsd -0x20(%rbp), %xmm1
mulsd -0x18(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
subsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
subsd -0x28(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0x8b4ac(%rip), %xmm0    # 0xb7030
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x38(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x40(%rbp), %xmm1
movsd 0x8b5e1(%rip), %xmm2    # 0xb7198
mulsd -0x38(%rbp), %xmm2
mulsd -0x48(%rbp), %xmm2
divsd -0x40(%rbp), %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x38(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x40(%rbp), %xmm2
movsd 0x8b59c(%rip), %xmm1    # 0xb7198
mulsd -0x58(%rbp), %xmm1
movsd -0x48(%rbp), %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd -0x58(%rbp), %xmm2
mulsd -0x58(%rbp), %xmm2
mulsd -0x50(%rbp), %xmm2
movsd 0x8bafb(%rip), %xmm3    # 0xb7720
divsd %xmm3, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x38(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x40(%rbp), %xmm2
movsd 0x8b52a(%rip), %xmm1    # 0xb7198
mulsd -0x60(%rbp), %xmm1
movsd -0x48(%rbp), %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd -0x60(%rbp), %xmm2
mulsd -0x60(%rbp), %xmm2
mulsd -0x50(%rbp), %xmm2
movsd 0x8ba89(%rip), %xmm3    # 0xb7720
divsd %xmm3, %xmm2
addsd %xmm2, %xmm1
movsd -0x68(%rbp), %xmm2
mulsd -0x60(%rbp), %xmm2
mulsd -0x48(%rbp), %xmm2
movsd 0x8ba62(%rip), %xmm3    # 0xb7718
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x20(%rbp), %xmm0
addsd -0x70(%rbp), %xmm0
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)