// File: mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::besselk1(double, alglib_impl::ae_state*)
double besselk1(double x, ae_state *_state)
{
    double y;
    double z;
    double v;
    double b0;
    double b1;
    double b2;
    double result;


    z = 0.5*x;
    ae_assert(ae_fp_greater(z,0), "Domain error in K1", _state);
    if( ae_fp_less_eq(x,2) )
    {
        y = x*x-2.0;
        bessel_besselm1firstcheb(-7.02386347938628759343E-18, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -2.42744985051936593393E-15, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -6.66690169419932900609E-13, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -1.41148839263352776110E-10, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -2.21338763073472585583E-8, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -2.43340614156596823496E-6, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -1.73028895751305206302E-4, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -6.97572385963986435018E-3, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -1.22611180822657148235E-1, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -3.53155960776544875667E-1, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 1.52530022733894777053E0, &b0, &b1, &b2, _state);
        v = 0.5*(b0-b2);
        result = ae_log(z, _state)*besseli1(x, _state)+v/x;
    }
    else
    {
        y = 8.0/x-2.0;
        bessel_besselm1firstcheb(-5.75674448366501715755E-18, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 1.79405087314755922667E-17, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -5.68946255844285935196E-17, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 1.83809354436663880070E-16, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -6.05704724837331885336E-16, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 2.03870316562433424052E-15, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -7.01983709041831346144E-15, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 2.47715442448130437068E-14, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -8.97670518232499435011E-14, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 3.34841966607842919884E-13, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -1.28917396095102890680E-12, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 5.13963967348173025100E-12, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -2.12996783842756842877E-11, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 9.21831518760500529508E-11, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -4.19035475934189648750E-10, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 2.01504975519703286596E-9, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -1.03457624656780970260E-8, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 5.74108412545004946722E-8, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -3.50196060308781257119E-7, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 2.40648494783721712015E-6, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -1.93619797416608296024E-5, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 1.95215518471351631108E-4, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, -2.85781685962277938680E-3, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 1.03923736576817238437E-1, &b0, &b1, &b2, _state);
        bessel_besselm1nextcheb(y, 2.72062619048444266945E0, &b0, &b1, &b2, _state);
        v = 0.5*(b0-b2);
        result = ae_exp(-x, _state)*v/ae_sqrt(x, _state);
    }
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movsd %xmm0, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movsd 0x47f57(%rip), %xmm0    # 0x55450
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c4c0
movq -0x10(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x49ff0(%rip), %rsi     # 0x57511
callq 0x3b240
movsd -0x8(%rbp), %xmm0
movsd 0x47e95(%rip), %xmm1    # 0x553c8
callq 0x3c480
testb $0x1, %al
jne 0xd541
jmp 0xd731
movsd -0x8(%rbp), %xmm0
movsd -0x8(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x480d1(%rip), %xmm1    # 0x55628
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movsd 0x48e9c(%rip), %xmm0    # 0x56408
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c8f0
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48e72(%rip), %xmm1    # 0x56400
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48e48(%rip), %xmm1    # 0x563f8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48e1e(%rip), %xmm1    # 0x563f0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48df4(%rip), %xmm1    # 0x563e8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48dca(%rip), %xmm1    # 0x563e0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48da0(%rip), %xmm1    # 0x563d8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48d76(%rip), %xmm1    # 0x563d0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48d4c(%rip), %xmm1    # 0x563c8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48d22(%rip), %xmm1    # 0x563c0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48cf8(%rip), %xmm1    # 0x563b8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x30(%rbp), %xmm1
subsd -0x40(%rbp), %xmm1
movsd 0x47d6d(%rip), %xmm0    # 0x55450
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rdi
callq 0x3cd70
movsd %xmm0, -0x50(%rbp)
movsd -0x8(%rbp), %xmm0
movq -0x10(%rbp), %rdi
callq 0xc3c0
movaps %xmm0, %xmm2
movsd -0x50(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
divsd -0x8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0xdb05
movsd 0x47ee7(%rip), %xmm0    # 0x55620
divsd -0x8(%rbp), %xmm0
movsd 0x47c82(%rip), %xmm1    # 0x553c8
subsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movsd 0x48c55(%rip), %xmm0    # 0x563b0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c8f0
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48c2b(%rip), %xmm1    # 0x563a8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48c01(%rip), %xmm1    # 0x563a0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48bd7(%rip), %xmm1    # 0x56398
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48bad(%rip), %xmm1    # 0x56390
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48b83(%rip), %xmm1    # 0x56388
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48b59(%rip), %xmm1    # 0x56380
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48b2f(%rip), %xmm1    # 0x56378
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48b05(%rip), %xmm1    # 0x56370
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48adb(%rip), %xmm1    # 0x56368
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48ab1(%rip), %xmm1    # 0x56360
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48a87(%rip), %xmm1    # 0x56358
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48a5d(%rip), %xmm1    # 0x56350
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48a33(%rip), %xmm1    # 0x56348
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48a09(%rip), %xmm1    # 0x56340
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x489df(%rip), %xmm1    # 0x56338
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x489b5(%rip), %xmm1    # 0x56330
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x4898b(%rip), %xmm1    # 0x56328
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48961(%rip), %xmm1    # 0x56320
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48937(%rip), %xmm1    # 0x56318
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x4890d(%rip), %xmm1    # 0x56310
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x488e3(%rip), %xmm1    # 0x56308
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x488b9(%rip), %xmm1    # 0x56300
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x4888f(%rip), %xmm1    # 0x562f8
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movsd 0x48865(%rip), %xmm1    # 0x562f0
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x1c930
movsd -0x30(%rbp), %xmm1
subsd -0x40(%rbp), %xmm1
movsd 0x479a2(%rip), %xmm0    # 0x55450
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x10(%rbp), %rdi
callq 0x3cdd0
mulsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x8(%rbp), %xmm0
movq -0x10(%rbp), %rdi
callq 0x3c890
movaps %xmm0, %xmm1
movsd -0x58(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
addq $0x60, %rsp
popq %rbp
retq