// File: /workspace/github_cpp_makefile_star2_O3/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 0x25bf9
movzbl %al, %edi
leaq 0x2c62a(%rip), %rsi     # 0x35712
movq %rbx, %rdx
callq 0x2510e
movsd 0x2a308(%rip), %xmm1    # 0x33400
movaps 0x10(%rsp), %xmm0
callq 0x25bd9
testb %al, %al
je 0x9221
movapd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
movapd %xmm1, %xmm4
mulsd %xmm1, %xmm0
addsd 0x2a2ec(%rip), %xmm0    # 0x33410
movsd 0x2afac(%rip), %xmm1    # 0x340d8
mulsd %xmm0, %xmm1
addsd 0x2afa8(%rip), %xmm1    # 0x340e0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd 0x2afa0(%rip), %xmm2    # 0x340e8
addsd 0x2afa0(%rip), %xmm2    # 0x340f0
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2af94(%rip), %xmm3    # 0x340f8
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2af88(%rip), %xmm1    # 0x34100
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2af7c(%rip), %xmm2    # 0x34108
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2af70(%rip), %xmm3    # 0x34110
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2af64(%rip), %xmm1    # 0x34118
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2af58(%rip), %xmm2    # 0x34120
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
addsd 0x2af50(%rip), %xmm2    # 0x34128
subsd %xmm1, %xmm2
movsd 0x2a2a4(%rip), %xmm0    # 0x33488
mulsd %xmm0, %xmm2
movapd %xmm2, (%rsp)
mulsd %xmm4, %xmm0
movq %rbx, %rdi
callq 0x25f91
movsd %xmm0, 0x28(%rsp)
movapd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x8537
mulsd 0x28(%rsp), %xmm0
movapd (%rsp), %xmm1
subsd %xmm0, %xmm1
jmp 0x9465
movsd 0x2a44f(%rip), %xmm0    # 0x33678
movapd 0x10(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm1, %xmm4
addsd 0x2a1d1(%rip), %xmm0    # 0x33410
movsd 0x2adc1(%rip), %xmm1    # 0x34008
mulsd %xmm0, %xmm1
addsd 0x2adbd(%rip), %xmm1    # 0x34010
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd 0x2adb5(%rip), %xmm2    # 0x34018
addsd 0x2adb5(%rip), %xmm2    # 0x34020
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2ada9(%rip), %xmm3    # 0x34028
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2ad9d(%rip), %xmm1    # 0x34030
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2ad91(%rip), %xmm2    # 0x34038
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2ad85(%rip), %xmm3    # 0x34040
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2ad79(%rip), %xmm1    # 0x34048
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2ad6d(%rip), %xmm2    # 0x34050
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2ad61(%rip), %xmm3    # 0x34058
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2ad55(%rip), %xmm1    # 0x34060
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2ad49(%rip), %xmm2    # 0x34068
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2ad3d(%rip), %xmm3    # 0x34070
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2ad31(%rip), %xmm1    # 0x34078
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2ad25(%rip), %xmm2    # 0x34080
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2ad19(%rip), %xmm3    # 0x34088
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2ad0d(%rip), %xmm1    # 0x34090
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2ad01(%rip), %xmm2    # 0x34098
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2acf5(%rip), %xmm3    # 0x340a0
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2ace9(%rip), %xmm1    # 0x340a8
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2acdd(%rip), %xmm2    # 0x340b0
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm1, %xmm3
addsd 0x2acd1(%rip), %xmm3    # 0x340b8
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm2, %xmm1
addsd 0x2acc5(%rip), %xmm1    # 0x340c0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
addsd 0x2acb9(%rip), %xmm2    # 0x340c8
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
addsd 0x2acb1(%rip), %xmm2    # 0x340d0
subsd %xmm1, %xmm2
mulsd 0x2a05d(%rip), %xmm2    # 0x33488
movsd %xmm2, (%rsp)
movapd 0x29d78(%rip), %xmm0    # 0x331b0
xorpd %xmm4, %xmm0
movq %rbx, %rdi
callq 0x25f9b
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e48
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x30, %rsp
popq %rbx
retq