// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/alglibinternal.cpp
// Function: alglib_impl::saferdiv(double, double, double*, alglib_impl::ae_state*)
ae_int_t saferdiv(double x, double y, double* r, ae_state *_state)
{
    ae_int_t result;

    *r = 0;

    
    /*
     * Two special cases:
     * * Y=0
     * * X=0 and Y<>0
     */
    if( ae_fp_eq(y,0) )
    {
        result = 1;
        if( ae_fp_eq(x,0) )
        {
            *r = _state->v_nan;
        }
        if( ae_fp_greater(x,0) )
        {
            *r = _state->v_posinf;
        }
        if( ae_fp_less(x,0) )
        {
            *r = _state->v_neginf;
        }
        return result;
    }
    if( ae_fp_eq(x,0) )
    {
        *r = 0;
        result = 0;
        return result;
    }
    
    /*
     * make Y>0
     */
    if( ae_fp_less(y,0) )
    {
        x = -x;
        y = -y;
    }
    
    /*
     *
     */
    if( ae_fp_greater_eq(y,1) )
    {
        *r = x/y;
        if( ae_fp_less_eq(ae_fabs(*r, _state),ae_minrealnumber) )
        {
            result = -1;
            *r = 0;
        }
        else
        {
            result = 0;
        }
    }
    else
    {
        if( ae_fp_greater_eq(ae_fabs(x, _state),ae_maxrealnumber*y) )
        {
            if( ae_fp_greater(x,0) )
            {
                *r = _state->v_posinf;
            }
            else
            {
                *r = _state->v_neginf;
            }
            result = 1;
        }
        else
        {
            *r = x/y;
            result = 0;
        }
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movapd %xmm1, %xmm2
movaps %xmm0, (%rsp)
movq $0x0, (%rdi)
xorpd %xmm1, %xmm1
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
callq 0x262ba
movl %eax, %ebp
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm0
callq 0x262ba
testb %bpl, %bpl
je 0x148b8
testb %al, %al
je 0x1487c
movsd 0x8(%r14), %xmm0
movsd %xmm0, (%rbx)
xorpd %xmm1, %xmm1
movaps (%rsp), %xmm0
callq 0x2633e
testb %al, %al
je 0x14897
movsd 0x10(%r14), %xmm0
movsd %xmm0, (%rbx)
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm0
callq 0x262fe
movl %eax, %ecx
movl $0x1, %eax
testb %cl, %cl
je 0x148c6
movsd 0x18(%r14), %xmm0
jmp 0x148c2
testb %al, %al
je 0x148cf
xorl %eax, %eax
xorpd %xmm0, %xmm0
movsd %xmm0, (%rbx)
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
xorpd %xmm1, %xmm1
movaps 0x10(%rsp), %xmm0
callq 0x262fe
testb %al, %al
jne 0x148e9
movapd 0x10(%rsp), %xmm0
jmp 0x1490d
movapd 0x1f8ef(%rip), %xmm0    # 0x341e0
movapd (%rsp), %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd 0x1f88b(%rip), %xmm1    # 0x341a0
movapd %xmm0, 0x10(%rsp)
callq 0x2635a
testb %al, %al
je 0x14958
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rbx)
movq %r14, %rdi
callq 0x26575
movsd 0x20b35(%rip), %xmm1    # 0x35478
callq 0x2631e
testb %al, %al
je 0x1499e
movq $-0x1, %rax
jmp 0x148be
movaps (%rsp), %xmm0
movq %r14, %rdi
callq 0x26575
movsd 0x1fccc(%rip), %xmm1    # 0x34638
mulsd 0x10(%rsp), %xmm1
callq 0x2635a
testb %al, %al
je 0x149a5
xorpd %xmm1, %xmm1
movaps (%rsp), %xmm0
callq 0x2633e
xorb $0x1, %al
movzbl %al, %eax
movsd 0x10(%r14,%rax,8), %xmm0
movl $0x1, %eax
jmp 0x148c2
xorl %eax, %eax
jmp 0x148c6
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
xorl %eax, %eax
jmp 0x148c2