// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, (%rdi)
xorpd %xmm1, %xmm1
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
callq 0x241f5
movl %eax, %ebp
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm0
callq 0x241f5
testb %bpl, %bpl
je 0x136e3
testb %al, %al
je 0x136ab
movsd 0x8(%r14), %xmm0
movsd %xmm0, (%rbx)
xorpd %xmm1, %xmm1
movaps (%rsp), %xmm0
callq 0x24279
testb %al, %al
je 0x136c6
movsd 0x10(%r14), %xmm0
movsd %xmm0, (%rbx)
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm0
callq 0x24239
testb %al, %al
je 0x136f3
movsd 0x18(%r14), %xmm0
pushq $0x1
popq %rax
jmp 0x136ed
testb %al, %al
je 0x136ff
xorl %eax, %eax
xorpd %xmm0, %xmm0
movsd %xmm0, (%rbx)
jmp 0x136f6
pushq $0x1
popq %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
xorpd %xmm1, %xmm1
movaps 0x10(%rsp), %xmm0
callq 0x24239
testb %al, %al
jne 0x13719
movapd 0x10(%rsp), %xmm0
jmp 0x1373d
movapd 0x1ca8f(%rip), %xmm0    # 0x301b0
movapd (%rsp), %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd 0x1cab3(%rip), %xmm1    # 0x301f8
movapd %xmm0, 0x10(%rsp)
callq 0x24295
testb %al, %al
je 0x13784
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rbx)
movq %r14, %rdi
callq 0x2440c
movsd 0x1dafd(%rip), %xmm1    # 0x31270
callq 0x24259
testb %al, %al
je 0x137c5
pushq $-0x1
popq %rax
jmp 0x136e9
movaps (%rsp), %xmm0
movq %r14, %rdi
callq 0x2440c
movsd 0x1cec8(%rip), %xmm1    # 0x30660
mulsd 0x10(%rsp), %xmm1
callq 0x24295
testb %al, %al
je 0x137cc
xorpd %xmm1, %xmm1
movaps (%rsp), %xmm0
callq 0x24279
xorb $0x1, %al
movzbl %al, %eax
movsd 0x10(%r14,%rax,8), %xmm0
jmp 0x136de
xorl %eax, %eax
jmp 0x136f6
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
xorl %eax, %eax
jmp 0x136ed