// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::jacobianellipticfunctions(double, double, double*, double*, double*, double*, alglib_impl::ae_state*)
void jacobianellipticfunctions(double u,
     double m,
     double* sn,
     double* cn,
     double* dn,
     double* ph,
     ae_state *_state)
{
    ae_frame _frame_block;
    double ai;
    double b;
    double phi;
    double t;
    double twon;
    ae_vector a;
    ae_vector c;
    ae_int_t i;

    ae_frame_make(_state, &_frame_block);
    *sn = 0;
    *cn = 0;
    *dn = 0;
    *ph = 0;
    ae_vector_init(&a, 0, DT_REAL, _state, ae_true);
    ae_vector_init(&c, 0, DT_REAL, _state, ae_true);

    ae_assert(ae_fp_greater_eq(m,0)&&ae_fp_less_eq(m,1), "Domain error in JacobianEllipticFunctions: m<0 or m>1", _state);
    ae_vector_set_length(&a, 8+1, _state);
    ae_vector_set_length(&c, 8+1, _state);
    if( ae_fp_less(m,1.0e-9) )
    {
        t = ae_sin(u, _state);
        b = ae_cos(u, _state);
        ai = 0.25*m*(u-t*b);
        *sn = t-ai*b;
        *cn = b+ai*t;
        *ph = u-ai;
        *dn = 1.0-0.5*m*t*t;
        ae_frame_leave(_state);
        return;
    }
    if( ae_fp_greater_eq(m,0.9999999999) )
    {
        ai = 0.25*(1.0-m);
        b = ae_cosh(u, _state);
        t = ae_tanh(u, _state);
        phi = 1.0/b;
        twon = b*ae_sinh(u, _state);
        *sn = t+ai*(twon-u)/(b*b);
        *ph = 2.0*ae_atan(ae_exp(u, _state), _state)-1.57079632679489661923+ai*(twon-u)/b;
        ai = ai*t*phi;
        *cn = phi-ai*(twon-u);
        *dn = phi+ai*(twon+u);
        ae_frame_leave(_state);
        return;
    }
    a.ptr.p_double[0] = 1.0;
    b = ae_sqrt(1.0-m, _state);
    c.ptr.p_double[0] = ae_sqrt(m, _state);
    twon = 1.0;
    i = 0;
    while(ae_fp_greater(ae_fabs(c.ptr.p_double[i]/a.ptr.p_double[i], _state),ae_machineepsilon))
    {
        if( i>7 )
        {
            ae_assert(ae_false, "Overflow in JacobianEllipticFunctions", _state);
            break;
        }
        ai = a.ptr.p_double[i];
        i = i+1;
        c.ptr.p_double[i] = 0.5*(ai-b);
        t = ae_sqrt(ai*b, _state);
        a.ptr.p_double[i] = 0.5*(ai+b);
        b = t;
        twon = twon*2.0;
    }
    phi = twon*a.ptr.p_double[i]*u;
    do
    {
        t = c.ptr.p_double[i]*ae_sin(phi, _state)/a.ptr.p_double[i];
        b = phi;
        phi = (ae_asin(t, _state)+phi)/2.0;
        i = i-1;
    }
    while(i!=0);
    *sn = ae_sin(phi, _state);
    t = ae_cos(phi, _state);
    *cn = t;
    *dn = t/ae_cos(phi-b, _state);
    *ph = phi;
    ae_frame_leave(_state);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
movsd %xmm1, (%rsp)
movsd %xmm0, 0x10(%rsp)
leaq 0xa0(%rsp), %rsi
movq %r8, %rdi
callq 0x2575d
xorl %ebp, %ebp
movq %rbp, (%r13)
movq %rbp, (%r12)
movq %rbp, (%r14)
movq %rbp, (%r15)
leaq 0x40(%rsp), %rdi
movl $0x3, %edx
xorl %esi, %esi
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x25900
leaq 0x70(%rsp), %rdi
movl $0x3, %edx
xorl %esi, %esi
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x25900
xorps %xmm1, %xmm1
movsd (%rsp), %xmm0
callq 0x2635a
testb %al, %al
je 0x10661
movsd 0x23b4b(%rip), %xmm1    # 0x341a0
movsd (%rsp), %xmm0
callq 0x2631e
movl %eax, %ebp
movzbl %bpl, %edi
leaq 0x2612d(%rip), %rsi     # 0x36799
movq %rbx, %rdx
callq 0x2581c
leaq 0x40(%rsp), %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x25a42
leaq 0x70(%rsp), %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x25a42
movsd 0x23d48(%rip), %xmm1    # 0x343e8
movsd (%rsp), %xmm0
callq 0x262fe
testb %al, %al
je 0x10754
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266a4
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266a9
movsd 0x24d84(%rip), %xmm1    # 0x35460
movsd (%rsp), %xmm4
mulsd %xmm4, %xmm1
movsd 0x8(%rsp), %xmm5
movapd %xmm5, %xmm2
mulsd %xmm0, %xmm2
movsd 0x10(%rsp), %xmm6
movapd %xmm6, %xmm3
subsd %xmm2, %xmm3
mulsd %xmm1, %xmm3
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm5, %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, (%r13)
subsd %xmm3, %xmm6
mulsd %xmm5, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, (%r12)
movsd %xmm6, (%r15)
mulsd 0x23d4e(%rip), %xmm4    # 0x34488
mulsd %xmm5, %xmm4
mulsd %xmm5, %xmm4
addsd 0x23a56(%rip), %xmm4    # 0x341a0
movsd %xmm4, (%r14)
jmp 0x10ae6
movsd 0x25634(%rip), %xmm1    # 0x35d90
movsd (%rsp), %xmm0
callq 0x2635a
testb %al, %al
je 0x108a4
movsd 0x23a2a(%rip), %xmm0    # 0x341a0
movsd %xmm0, 0x8(%rsp)
subsd (%rsp), %xmm0
mulsd 0x24cd7(%rip), %xmm0    # 0x35460
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266b8
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266bd
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266b3
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movapd %xmm0, %xmm2
movsd 0x10(%rsp), %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, 0x38(%rsp)
movsd 0x18(%rsp), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x30(%rsp)
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm3, %xmm1
divsd %xmm2, %xmm1
addsd 0x20(%rsp), %xmm1
movsd %xmm1, (%r13)
movq %rbx, %rdi
callq 0x266e0
movq %rbx, %rdi
callq 0x266cc
addsd %xmm0, %xmm0
addsd 0x24f10(%rip), %xmm0    # 0x35750
movsd 0x30(%rsp), %xmm1
divsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r15)
movsd 0x18(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x38(%rsp), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm0, %xmm2
movapd %xmm1, %xmm0
subsd %xmm3, %xmm0
movsd %xmm0, (%r12)
movsd 0x28(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%r14)
jmp 0x10ae6
movq %r14, 0x28(%rsp)
movq 0x68(%rsp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movsd 0x238dd(%rip), %xmm0    # 0x341a0
movsd %xmm0, 0x8(%rsp)
subsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x2658d
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x2658d
movq 0x98(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x98(%rsp), %rax
movsd (%rax), %xmm0
movq 0x68(%rsp), %rax
divsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x26575
movsd 0x24006(%rip), %xmm1    # 0x34920
callq 0x2633e
testb %al, %al
je 0x10a0d
movsd 0x23871(%rip), %xmm0    # 0x341a0
movsd %xmm0, 0x8(%rsp)
xorl %r14d, %r14d
movsd 0x18(%rsp), %xmm1
cmpq $0x8, %r14
je 0x10a11
movq 0x68(%rsp), %rax
movsd (%rax,%r14,8), %xmm3
movsd %xmm3, 0x20(%rsp)
leaq 0x1(%r14), %rbp
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
movsd 0x23afb(%rip), %xmm2    # 0x34468
mulsd %xmm2, %xmm0
movq 0x98(%rsp), %rax
movsd %xmm0, 0x8(%rax,%r14,8)
movapd %xmm1, %xmm0
mulsd %xmm3, %xmm0
movq %rbx, %rdi
movsd %xmm1, 0x18(%rsp)
callq 0x2658d
movsd %xmm0, (%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
mulsd 0x23ab9(%rip), %xmm0    # 0x34468
movq 0x68(%rsp), %rax
movsd %xmm0, 0x8(%rax,%r14,8)
movsd 0x8(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x98(%rsp), %rax
movsd 0x8(%rax,%r14,8), %xmm0
movq 0x68(%rsp), %rax
divsd 0x8(%rax,%r14,8), %xmm0
movq %rbx, %rdi
callq 0x26575
movsd 0x23f2a(%rip), %xmm1    # 0x34920
callq 0x2633e
movq %rbp, %r14
movsd (%rsp), %xmm1
testb %al, %al
jne 0x1093e
jmp 0x10a27
xorl %ebp, %ebp
jmp 0x10a27
leaq 0x25db7(%rip), %rsi     # 0x367cf
xorl %edi, %edi
movq %rbx, %rdx
callq 0x2581c
movl $0x8, %ebp
movq 0x68(%rsp), %rax
movsd 0x8(%rsp), %xmm0
mulsd (%rax,%rbp,8), %xmm0
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq 0x98(%rsp), %rax
movsd (%rax,%rbp,8), %xmm1
movsd %xmm1, 0x8(%rsp)
movq %rbx, %rdi
callq 0x266a4
mulsd 0x8(%rsp), %xmm0
movq 0x68(%rsp), %rax
divsd (%rax,%rbp,8), %xmm0
movq %rbx, %rdi
callq 0x266c2
addsd (%rsp), %xmm0
mulsd 0x239e6(%rip), %xmm0    # 0x34468
decq %rbp
jne 0x10a3d
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x266a4
movsd %xmm0, (%r13)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266a9
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, (%r12)
movsd 0x8(%rsp), %xmm0
subsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x266a9
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
movq 0x28(%rsp), %rax
movsd %xmm1, (%rax)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r15)
movq %rbx, %rdi
callq 0x256fa
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq