// File: /workspace/github_cpp_makefile_star2_O3/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 0x25055
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 0x251ec
leaq 0x70(%rsp), %rdi
movl $0x3, %edx
xorl %esi, %esi
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x251ec
xorps %xmm1, %xmm1
movsd (%rsp), %xmm0
callq 0x25c15
testb %al, %al
je 0x103e2
movsd 0x22e0a(%rip), %xmm1    # 0x331e0
movsd (%rsp), %xmm0
callq 0x25bd9
movl %eax, %ebp
movzbl %bpl, %edi
leaq 0x2554c(%rip), %rsi     # 0x35939
movq %rbx, %rdx
callq 0x2510e
leaq 0x40(%rsp), %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x25326
leaq 0x70(%rsp), %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x25326
movsd 0x22fe7(%rip), %xmm1    # 0x33408
movsd (%rsp), %xmm0
callq 0x25bb9
testb %al, %al
je 0x104d5
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f5f
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f64
movsd 0x23dfb(%rip), %xmm1    # 0x34258
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 0x22fed(%rip), %xmm4    # 0x334a8
mulsd %xmm5, %xmm4
mulsd %xmm5, %xmm4
addsd 0x22d15(%rip), %xmm4    # 0x331e0
movsd %xmm4, (%r14)
jmp 0x10867
movsd 0x243cb(%rip), %xmm1    # 0x348a8
movsd (%rsp), %xmm0
callq 0x25c15
testb %al, %al
je 0x10625
movsd 0x22ce9(%rip), %xmm0    # 0x331e0
movsd %xmm0, 0x8(%rsp)
subsd (%rsp), %xmm0
mulsd 0x23d4e(%rip), %xmm0    # 0x34258
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f73
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f78
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f6e
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 0x25f9b
movq %rbx, %rdi
callq 0x25f87
addsd %xmm0, %xmm0
addsd 0x23f87(%rip), %xmm0    # 0x34548
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 0x10867
movq %r14, 0x28(%rsp)
movq 0x68(%rsp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movsd 0x22b9c(%rip), %xmm0    # 0x331e0
movsd %xmm0, 0x8(%rsp)
subsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e48
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e48
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 0x25e30
movsd 0x23155(%rip), %xmm1    # 0x337f0
callq 0x25bf9
testb %al, %al
je 0x1078e
movsd 0x22b30(%rip), %xmm0    # 0x331e0
movsd %xmm0, 0x8(%rsp)
xorl %r14d, %r14d
movsd 0x18(%rsp), %xmm1
cmpq $0x8, %r14
je 0x10792
movq 0x68(%rsp), %rax
movsd (%rax,%r14,8), %xmm3
movsd %xmm3, 0x20(%rsp)
leaq 0x1(%r14), %rbp
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
movsd 0x22d9a(%rip), %xmm2    # 0x33488
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 0x25e48
movsd %xmm0, (%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
mulsd 0x22d58(%rip), %xmm0    # 0x33488
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 0x25e30
movsd 0x23079(%rip), %xmm1    # 0x337f0
callq 0x25bf9
movq %rbp, %r14
movsd (%rsp), %xmm1
testb %al, %al
jne 0x106bf
jmp 0x107a8
xorl %ebp, %ebp
jmp 0x107a8
leaq 0x251d6(%rip), %rsi     # 0x3596f
xorl %edi, %edi
movq %rbx, %rdx
callq 0x2510e
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 0x25f5f
mulsd 0x8(%rsp), %xmm0
movq 0x68(%rsp), %rax
divsd (%rax,%rbp,8), %xmm0
movq %rbx, %rdi
callq 0x25f7d
addsd (%rsp), %xmm0
mulsd 0x22c85(%rip), %xmm0    # 0x33488
decq %rbp
jne 0x107be
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x25f5f
movsd %xmm0, (%r13)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f64
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, (%r12)
movsd 0x8(%rsp), %xmm0
subsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f64
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 0x24ff2
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq