// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::beta(double, double, alglib_impl::ae_state*)
double beta(double a, double b, ae_state *_state)
{
    double y;
    double sg;
    double s;
    double result;


    sg = 1;
    ae_assert(ae_fp_greater(a,0)||ae_fp_neq(a,ae_ifloor(a, _state)), "Overflow in Beta", _state);
    ae_assert(ae_fp_greater(b,0)||ae_fp_neq(b,ae_ifloor(b, _state)), "Overflow in Beta", _state);
    y = a+b;
    if( ae_fp_greater(ae_fabs(y, _state),171.624376956302725) )
    {
        y = lngamma(y, &s, _state);
        sg = sg*s;
        y = lngamma(b, &s, _state)-y;
        sg = sg*s;
        y = lngamma(a, &s, _state)+y;
        sg = sg*s;
        ae_assert(ae_fp_less_eq(y,ae_log(ae_maxrealnumber, _state)), "Overflow in Beta", _state);
        result = sg*ae_exp(y, _state);
        return result;
    }
    y = gammafunction(y, _state);
    ae_assert(ae_fp_neq(y,0), "Overflow in Beta", _state);
    if( ae_fp_greater(a,b) )
    {
        y = gammafunction(a, _state)/y;
        y = y*gammafunction(b, _state);
    }
    else
    {
        y = gammafunction(b, _state)/y;
        y = y*gammafunction(a, _state);
    }
    result = y;
    return result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movsd %xmm1, 0x8(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm0, 0x18(%rsp)
callq 0x2633e
movl %eax, %ecx
movb $0x1, %bpl
movb $0x1, %al
testb %cl, %cl
jne 0xa314
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x265d3
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd 0x18(%rsp), %xmm0
callq 0x262dc
movzbl %al, %edi
leaq 0x2c2b4(%rip), %rsi     # 0x365d2
movq %rbx, %rdx
callq 0x2581c
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x2633e
testb %al, %al
jne 0xa35c
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x265d3
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x262dc
movl %eax, %ebp
movzbl %bpl, %edi
leaq 0x2c26b(%rip), %rsi     # 0x365d2
movq %rbx, %rdx
callq 0x2581c
movsd 0x18(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0x26575
movsd 0x2b0df(%rip), %xmm1    # 0x35470
callq 0x2633e
testb %al, %al
je 0xa46a
leaq 0x28(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e78
movsd %xmm0, 0x20(%rsp)
movsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e78
subsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e78
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x2a20f(%rip), %xmm0    # 0x34638
movq %rbx, %rdi
callq 0x266d6
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x2631e
movzbl %al, %edi
leaq 0x2c189(%rip), %rsi     # 0x365d2
movq %rbx, %rdx
callq 0x2581c
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266e0
mulsd 0x10(%rsp), %xmm0
jmp 0xa50b
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
xorps %xmm1, %xmm1
movsd %xmm0, 0x10(%rsp)
callq 0x262dc
movzbl %al, %edi
leaq 0x2c142(%rip), %rsi     # 0x365d2
movq %rbx, %rdx
callq 0x2581c
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x2633e
testb %al, %al
je 0xa4dd
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
mulsd 0x18(%rsp), %xmm0
jmp 0xa50b
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
mulsd 0x8(%rsp), %xmm0
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq