// File: /workspace/github_cpp_makefile_star2_O2/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::besselk0(double, alglib_impl::ae_state*)
double besselk0(double x, ae_state *_state)
{
    double y;
    double z;
    double v;
    double b0;
    double b1;
    double b2;
    double result;


    ae_assert(ae_fp_greater(x,0), "Domain error in BesselK0: x<=0", _state);
    if( ae_fp_less_eq(x,2) )
    {
        y = x*x-2.0;
        bessel_besselmfirstcheb(1.37446543561352307156E-16, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 4.25981614279661018399E-14, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 1.03496952576338420167E-11, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 1.90451637722020886025E-9, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 2.53479107902614945675E-7, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 2.28621210311945178607E-5, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 1.26461541144692592338E-3, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 3.59799365153615016266E-2, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, 3.44289899924628486886E-1, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(y, -5.35327393233902768720E-1, &b0, &b1, &b2, _state);
        v = 0.5*(b0-b2);
        v = v-ae_log(0.5*x, _state)*besseli0(x, _state);
    }
    else
    {
        z = 8.0/x-2.0;
        bessel_besselmfirstcheb(5.30043377268626276149E-18, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -1.64758043015242134646E-17, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 5.21039150503902756861E-17, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -1.67823109680541210385E-16, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 5.51205597852431940784E-16, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -1.84859337734377901440E-15, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 6.34007647740507060557E-15, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -2.22751332699166985548E-14, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 8.03289077536357521100E-14, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -2.98009692317273043925E-13, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 1.14034058820847496303E-12, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -4.51459788337394416547E-12, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 1.85594911495471785253E-11, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -7.95748924447710747776E-11, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 3.57739728140030116597E-10, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -1.69753450938905987466E-9, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 8.57403401741422608519E-9, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -4.66048989768794782956E-8, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 2.76681363944501510342E-7, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -1.83175552271911948767E-6, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 1.39498137188764993662E-5, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -1.28495495816278026384E-4, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 1.56988388573005337491E-3, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, -3.14481013119645005427E-2, &b0, &b1, &b2, _state);
        bessel_besselmnextcheb(z, 2.44030308206595545468E0, &b0, &b1, &b2, _state);
        v = 0.5*(b0-b2);
        v = v*ae_exp(-x, _state)/ae_sqrt(x, _state);
    }
    result = v;
    return result;
}

// Assembly:
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movaps %xmm0, 0x10(%rsp)
xorps %xmm1, %xmm1
callq 0x24279
movzbl %al, %edi
leaq 0x29d56(%rip), %rsi     # 0x32702
movq %rbx, %rdx
callq 0x238ca
movsd 0x27a3c(%rip), %xmm1    # 0x303f8
movaps 0x10(%rsp), %xmm0
callq 0x24259
testb %al, %al
je 0x8ae5
movapd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
movapd %xmm1, %xmm4
mulsd %xmm1, %xmm0
addsd 0x27a18(%rip), %xmm0    # 0x30400
movsd 0x286e8(%rip), %xmm1    # 0x310d8
mulsd %xmm0, %xmm1
addsd 0x286e4(%rip), %xmm1    # 0x310e0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd 0x286dc(%rip), %xmm2    # 0x310e8
addsd 0x286dc(%rip), %xmm2    # 0x310f0
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x286d0(%rip), %xmm3    # 0x310f8
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x286c4(%rip), %xmm1    # 0x31100
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x286b8(%rip), %xmm2    # 0x31108
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x286ac(%rip), %xmm3    # 0x31110
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x286a0(%rip), %xmm1    # 0x31118
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x28694(%rip), %xmm2    # 0x31120
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
addsd 0x2868c(%rip), %xmm2    # 0x31128
subsd %xmm1, %xmm2
movsd 0x279e0(%rip), %xmm0    # 0x30488
mulsd %xmm0, %xmm2
movapd %xmm2, (%rsp)
mulsd %xmm4, %xmm0
movq %rbx, %rdi
callq 0x2455f
movsd %xmm0, 0x28(%rsp)
movapd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x7dff
mulsd 0x28(%rsp), %xmm0
movapd (%rsp), %xmm1
subsd %xmm0, %xmm1
jmp 0x8d29
movsd 0x27b8b(%rip), %xmm0    # 0x30678
movapd 0x10(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm1, %xmm4
addsd 0x278fd(%rip), %xmm0    # 0x30400
movsd 0x284fd(%rip), %xmm1    # 0x31008
mulsd %xmm0, %xmm1
addsd 0x284f9(%rip), %xmm1    # 0x31010
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd 0x284f1(%rip), %xmm2    # 0x31018
addsd 0x284f1(%rip), %xmm2    # 0x31020
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x284e5(%rip), %xmm3    # 0x31028
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x284d9(%rip), %xmm1    # 0x31030
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x284cd(%rip), %xmm2    # 0x31038
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x284c1(%rip), %xmm3    # 0x31040
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x284b5(%rip), %xmm1    # 0x31048
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x284a9(%rip), %xmm2    # 0x31050
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2849d(%rip), %xmm3    # 0x31058
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x28491(%rip), %xmm1    # 0x31060
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x28485(%rip), %xmm2    # 0x31068
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x28479(%rip), %xmm3    # 0x31070
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2846d(%rip), %xmm1    # 0x31078
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x28461(%rip), %xmm2    # 0x31080
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x28455(%rip), %xmm3    # 0x31088
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x28449(%rip), %xmm1    # 0x31090
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2843d(%rip), %xmm2    # 0x31098
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x28431(%rip), %xmm3    # 0x310a0
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x28425(%rip), %xmm1    # 0x310a8
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x28419(%rip), %xmm2    # 0x310b0
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2840d(%rip), %xmm3    # 0x310b8
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x28401(%rip), %xmm1    # 0x310c0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x283f5(%rip), %xmm2    # 0x310c8
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
addsd 0x283ed(%rip), %xmm2    # 0x310d0
subsd %xmm1, %xmm2
mulsd 0x27799(%rip), %xmm2    # 0x30488
movsd %xmm2, (%rsp)
movapd 0x274b4(%rip), %xmm0    # 0x301b0
xorpd %xmm4, %xmm0
movq %rbx, %rdi
callq 0x24569
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24424
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x30, %rsp
popq %rbx
retq