// File: /workspace/github_cpp_makefile_star2_O2/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 $0xc8, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
movsd %xmm1, (%rsp)
movsd %xmm0, 0x18(%rsp)
leaq 0xb0(%rsp), %rsi
movq %r8, %rdi
callq 0x23815
andq $0x0, (%r13)
andq $0x0, (%r12)
movq %r14, 0x28(%rsp)
andq $0x0, (%r14)
movq %r15, 0x20(%rsp)
andq $0x0, (%r15)
xorl %ebp, %ebp
leaq 0x50(%rsp), %rdi
pushq $0x3
popq %r14
pushq $0x1
popq %r15
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
movl %r15d, %r8d
callq 0x239a5
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
movl %r15d, %r8d
callq 0x239a5
xorps %xmm1, %xmm1
movsd (%rsp), %xmm0
callq 0x24295
testb %al, %al
je 0xf984
movsd 0x20880(%rip), %xmm1    # 0x301f8
movsd (%rsp), %xmm0
callq 0x24259
movl %eax, %ebp
movzbl %bpl, %edi
leaq 0x22f9a(%rip), %rsi     # 0x32929
movq %rbx, %rdx
callq 0x238ca
leaq 0x50(%rsp), %rdi
pushq $0x9
popq %r14
movq %r14, %rsi
movq %rbx, %rdx
callq 0x23add
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x23add
movsd 0x20aaa(%rip), %xmm1    # 0x30470
movsd (%rsp), %xmm0
callq 0x24239
testb %al, %al
je 0xfa82
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2452d
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24532
movsd 0x21856(%rip), %xmm1    # 0x31258
movsd (%rsp), %xmm4
mulsd %xmm4, %xmm1
movsd 0x10(%rsp), %xmm5
movapd %xmm5, %xmm2
mulsd %xmm0, %xmm2
movsd 0x18(%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)
movq 0x20(%rsp), %rax
movsd %xmm6, (%rax)
mulsd 0x20a44(%rip), %xmm4    # 0x304a8
mulsd %xmm5, %xmm4
mulsd %xmm5, %xmm4
addsd 0x20784(%rip), %xmm4    # 0x301f8
movq 0x28(%rsp), %rax
movsd %xmm4, (%rax)
jmp 0xfdc2
movsd 0x21e1e(%rip), %xmm1    # 0x318a8
movsd (%rsp), %xmm0
callq 0x24295
testb %al, %al
je 0xfbd7
movsd 0x20754(%rip), %xmm0    # 0x301f8
movsd %xmm0, 0x10(%rsp)
subsd (%rsp), %xmm0
mulsd 0x217a1(%rip), %xmm0    # 0x31258
movsd %xmm0, (%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24541
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24546
movsd %xmm0, 0x30(%rsp)
movsd 0x10(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2453c
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movapd %xmm0, %xmm2
movsd 0x18(%rsp), %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, 0x40(%rsp)
movsd (%rsp), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x38(%rsp)
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm3, %xmm1
divsd %xmm2, %xmm1
addsd 0x30(%rsp), %xmm1
movsd %xmm1, (%r13)
movq %rbx, %rdi
callq 0x24569
movq %rbx, %rdi
callq 0x24555
addsd %xmm0, %xmm0
addsd 0x219d9(%rip), %xmm0    # 0x31548
movsd 0x38(%rsp), %xmm1
divsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0x20(%rsp), %rax
movsd %xmm1, (%rax)
movsd (%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm3
mulsd %xmm0, %xmm3
movapd %xmm0, %xmm2
movapd %xmm1, %xmm0
subsd %xmm3, %xmm0
movsd %xmm0, (%r12)
movsd 0x48(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x28(%rsp), %rax
jmp 0xfdbe
movq 0x78(%rsp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movsd 0x20607(%rip), %xmm0    # 0x301f8
movsd %xmm0, 0x8(%rsp)
subsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x24424
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x24424
movq 0xa8(%rsp), %rax
movsd %xmm0, (%rax)
xorl %r14d, %r14d
movq 0xa8(%rsp), %rax
movsd (%rax,%r14), %xmm0
movq 0x78(%rsp), %rax
divsd (%rax,%r14), %xmm0
movq %rbx, %rdi
callq 0x2440c
movsd 0x20ba1(%rip), %xmm1    # 0x307f0
callq 0x24279
testb %al, %al
je 0xfcfa
cmpq $0x40, %r14
movsd 0x20820(%rip), %xmm1    # 0x30488
je 0xfce9
movq 0x78(%rsp), %rax
movsd (%rax,%r14), %xmm2
movsd %xmm2, (%rsp)
movapd %xmm2, %xmm0
movsd 0x10(%rsp), %xmm3
subsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
movq 0xa8(%rsp), %rax
movsd %xmm0, 0x8(%rax,%r14)
movapd %xmm3, %xmm0
mulsd %xmm2, %xmm0
movq %rbx, %rdi
callq 0x24424
movsd 0x10(%rsp), %xmm1
addsd (%rsp), %xmm1
mulsd 0x207ca(%rip), %xmm1    # 0x30488
movq 0x78(%rsp), %rax
movsd %xmm1, 0x8(%rax,%r14)
movsd 0x8(%rsp), %xmm1
addsd %xmm1, %xmm1
movsd %xmm1, 0x8(%rsp)
addq $0x8, %r14
movsd %xmm0, 0x10(%rsp)
jmp 0xfc26
leaq 0x22c6f(%rip), %rsi     # 0x3295f
xorl %edi, %edi
movq %rbx, %rdx
callq 0x238ca
movq 0x78(%rsp), %rax
movsd 0x8(%rsp), %xmm0
mulsd (%rax,%r14), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xa8(%rsp), %rax
movsd (%rax,%r14), %xmm1
movsd %xmm1, 0x8(%rsp)
movq %rbx, %rdi
callq 0x2452d
mulsd 0x8(%rsp), %xmm0
movq 0x78(%rsp), %rax
divsd (%rax,%r14), %xmm0
movq %rbx, %rdi
callq 0x2454b
addsd 0x10(%rsp), %xmm0
mulsd 0x2072e(%rip), %xmm0    # 0x30488
addq $-0x8, %r14
jne 0xfd11
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x2452d
movsd %xmm0, (%r13)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24532
movsd %xmm0, (%rsp)
movsd %xmm0, (%r12)
movsd 0x8(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24532
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movq 0x28(%rsp), %rax
movsd %xmm1, (%rax)
movq 0x20(%rsp), %rax
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %rbx, %rdi
callq 0x237b6
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq