// File: /workspace/github_cpp_makefile_star2_O2/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 0x24279
movl %eax, %ecx
movb $0x1, %bpl
movb $0x1, %al
testb %cl, %cl
jne 0x9a2a
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24468
cvtsi2sd %rax, %xmm1
movsd 0x18(%rsp), %xmm0
callq 0x24217
movzbl %al, %edi
leaq 0x28d2e(%rip), %rsi     # 0x32762
movq %rbx, %rdx
callq 0x238ca
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x24279
testb %al, %al
jne 0x9a6f
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24468
cvtsi2sd %rax, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x24217
movl %eax, %ebp
movzbl %bpl, %edi
leaq 0x28ce8(%rip), %rsi     # 0x32762
movq %rbx, %rdx
callq 0x238ca
movsd 0x18(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0x2440c
movsd 0x277c4(%rip), %xmm1    # 0x31268
callq 0x24279
testb %al, %al
je 0x9b7d
leaq 0x28(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x48dc
movsd %xmm0, 0x20(%rsp)
movsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x48dc
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 0x48dc
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x26b24(%rip), %xmm0    # 0x30660
movq %rbx, %rdi
callq 0x2455f
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x24259
movzbl %al, %edi
leaq 0x28c06(%rip), %rsi     # 0x32762
movq %rbx, %rdx
callq 0x238ca
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24569
mulsd 0x10(%rsp), %xmm0
jmp 0x9c1e
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
xorps %xmm1, %xmm1
movsd %xmm0, 0x10(%rsp)
callq 0x24217
movzbl %al, %edi
leaq 0x28bbf(%rip), %rsi     # 0x32762
movq %rbx, %rdx
callq 0x238ca
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x24279
testb %al, %al
je 0x9bf0
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
mulsd 0x18(%rsp), %xmm0
jmp 0x9c1e
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
mulsd 0x8(%rsp), %xmm0
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq