// File: /workspace/github_cpp_makefile_star2_O1/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 0x2633e
movzbl %al, %edi
leaq 0x2d316(%rip), %rsi     # 0x36572
movq %rbx, %rdx
callq 0x2581c
movsd 0x2b174(%rip), %xmm1    # 0x343e0
movaps 0x10(%rsp), %xmm0
callq 0x2631e
testb %al, %al
je 0x9395
movapd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
movapd %xmm1, %xmm4
mulsd %xmm1, %xmm0
addsd 0x2b158(%rip), %xmm0    # 0x343f0
movsd 0x2c040(%rip), %xmm1    # 0x352e0
mulsd %xmm0, %xmm1
addsd 0x2c03c(%rip), %xmm1    # 0x352e8
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd 0x2c034(%rip), %xmm2    # 0x352f0
addsd 0x2c034(%rip), %xmm2    # 0x352f8
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2c028(%rip), %xmm3    # 0x35300
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2c01c(%rip), %xmm1    # 0x35308
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2c010(%rip), %xmm2    # 0x35310
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2c004(%rip), %xmm3    # 0x35318
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2bff8(%rip), %xmm1    # 0x35320
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2bfec(%rip), %xmm2    # 0x35328
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
addsd 0x2bfe4(%rip), %xmm2    # 0x35330
subsd %xmm1, %xmm2
movsd 0x2b110(%rip), %xmm0    # 0x34468
mulsd %xmm0, %xmm2
movapd %xmm2, (%rsp)
mulsd %xmm4, %xmm0
movq %rbx, %rdi
callq 0x266d6
movsd %xmm0, 0x28(%rsp)
movapd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x86ab
mulsd 0x28(%rsp), %xmm0
movapd (%rsp), %xmm1
subsd %xmm0, %xmm1
jmp 0x95d9
movsd 0x2b2b3(%rip), %xmm0    # 0x34650
movapd 0x10(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm1, %xmm4
addsd 0x2b03d(%rip), %xmm0    # 0x343f0
movsd 0x2be55(%rip), %xmm1    # 0x35210
mulsd %xmm0, %xmm1
addsd 0x2be51(%rip), %xmm1    # 0x35218
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd 0x2be49(%rip), %xmm2    # 0x35220
addsd 0x2be49(%rip), %xmm2    # 0x35228
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2be3d(%rip), %xmm3    # 0x35230
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2be31(%rip), %xmm1    # 0x35238
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2be25(%rip), %xmm2    # 0x35240
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2be19(%rip), %xmm3    # 0x35248
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2be0d(%rip), %xmm1    # 0x35250
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2be01(%rip), %xmm2    # 0x35258
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2bdf5(%rip), %xmm3    # 0x35260
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2bde9(%rip), %xmm1    # 0x35268
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2bddd(%rip), %xmm2    # 0x35270
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2bdd1(%rip), %xmm3    # 0x35278
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2bdc5(%rip), %xmm1    # 0x35280
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2bdb9(%rip), %xmm2    # 0x35288
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2bdad(%rip), %xmm3    # 0x35290
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2bda1(%rip), %xmm1    # 0x35298
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2bd95(%rip), %xmm2    # 0x352a0
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2bd89(%rip), %xmm3    # 0x352a8
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2bd7d(%rip), %xmm1    # 0x352b0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2bd71(%rip), %xmm2    # 0x352b8
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2bd65(%rip), %xmm3    # 0x352c0
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2bd59(%rip), %xmm1    # 0x352c8
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2bd4d(%rip), %xmm2    # 0x352d0
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
addsd 0x2bd45(%rip), %xmm2    # 0x352d8
subsd %xmm1, %xmm2
mulsd 0x2aec9(%rip), %xmm2    # 0x34468
movsd %xmm2, (%rsp)
movapd 0x2ac34(%rip), %xmm0    # 0x341e0
xorpd %xmm4, %xmm0
movq %rbx, %rdi
callq 0x266e0
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2658d
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x30, %rsp
popq %rbx
retq