// File: /workspace/github_cpp_makefile_star2_O3/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 0x25bf9
movl %eax, %ecx
movb $0x1, %bpl
movb $0x1, %al
testb %cl, %cl
jne 0xa1a7
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e8e
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd 0x18(%rsp), %xmm0
callq 0x25b97
movzbl %al, %edi
leaq 0x2b5c1(%rip), %rsi     # 0x35772
movq %rbx, %rdx
callq 0x2510e
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x25bf9
testb %al, %al
jne 0xa1ef
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e8e
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x25b97
movl %eax, %ebp
movzbl %bpl, %edi
leaq 0x2b578(%rip), %rsi     # 0x35772
movq %rbx, %rdx
callq 0x2510e
movsd 0x18(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0x25e30
movsd 0x2a044(%rip), %xmm1    # 0x34268
callq 0x25bf9
testb %al, %al
je 0xa2fd
leaq 0x28(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e80
movsd %xmm0, 0x20(%rsp)
movsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e80
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 0x4e80
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x293a4(%rip), %xmm0    # 0x33660
movq %rbx, %rdi
callq 0x25f91
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x25bd9
movzbl %al, %edi
leaq 0x2b496(%rip), %rsi     # 0x35772
movq %rbx, %rdx
callq 0x2510e
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f9b
mulsd 0x10(%rsp), %xmm0
jmp 0xa39e
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
xorps %xmm1, %xmm1
movsd %xmm0, 0x10(%rsp)
callq 0x25b97
movzbl %al, %edi
leaq 0x2b44f(%rip), %rsi     # 0x35772
movq %rbx, %rdx
callq 0x2510e
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x25bf9
testb %al, %al
je 0xa370
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
mulsd 0x18(%rsp), %xmm0
jmp 0xa39e
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
mulsd 0x8(%rsp), %xmm0
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq