// File: 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
movq %rsp, %rbp
subq $0x80, %rsp
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movsd 0x46907(%rip), %xmm0    # 0x55008
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c4c0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x41(%rbp)
jne 0xe749
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c940
movsd -0x50(%rbp), %xmm0
cvtsi2sd %rax, %xmm1
callq 0x3c410
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
movq -0x20(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x48df5(%rip), %rsi     # 0x57552
callq 0x3b240
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c4c0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x51(%rbp)
jne 0xe7a5
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c940
movsd -0x60(%rbp), %xmm0
cvtsi2sd %rax, %xmm1
callq 0x3c410
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
movq -0x20(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x48d99(%rip), %rsi     # 0x57552
callq 0x3b240
movsd -0x10(%rbp), %xmm0
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c820
movsd 0x47c3d(%rip), %xmm1    # 0x56420
callq 0x3c4c0
testb $0x1, %al
jne 0xe7f1
jmp 0xe8e3
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x5530
movsd %xmm0, -0x28(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x5530
subsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x5530
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x20(%rbp), %rdi
movsd 0x46f25(%rip), %xmm0    # 0x557a8
callq 0x3cd70
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
callq 0x3c480
movq -0x20(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x48cac(%rip), %rsi     # 0x57552
callq 0x3b240
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3cdd0
movaps %xmm0, %xmm1
movsd -0x68(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xe9c6
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x4ed0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c410
movq -0x20(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x48c3e(%rip), %rsi     # 0x57552
callq 0x3b240
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0xe92e
jmp 0xe971
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x4ed0
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x4ed0
movaps %xmm0, %xmm1
movsd -0x78(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0xe9b2
movsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x4ed0
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x4ed0
movaps %xmm0, %xmm1
movsd -0x80(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)