// File: /workspace/github_cpp_makefile_star2_O3/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 0x25b75
movl %eax, %ebp
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm0
callq 0x25b75
testb %bpl, %bpl
je 0x1432b
testb %al, %al
je 0x142ef
movsd 0x8(%r14), %xmm0
movsd %xmm0, (%rbx)
xorpd %xmm1, %xmm1
movaps (%rsp), %xmm0
callq 0x25bf9
testb %al, %al
je 0x1430a
movsd 0x10(%r14), %xmm0
movsd %xmm0, (%rbx)
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm0
callq 0x25bb9
movl %eax, %ecx
movl $0x1, %eax
testb %cl, %cl
je 0x14339
movsd 0x18(%r14), %xmm0
jmp 0x14335
testb %al, %al
je 0x14342
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 0x25bb9
testb %al, %al
jne 0x1435c
movapd 0x10(%rsp), %xmm0
jmp 0x14380
movapd 0x1ee4c(%rip), %xmm0    # 0x331b0
movapd (%rsp), %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd 0x1ee58(%rip), %xmm1    # 0x331e0
movapd %xmm0, 0x10(%rsp)
callq 0x25c15
testb %al, %al
je 0x143cb
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rbx)
movq %r14, %rdi
callq 0x25e30
movsd 0x1feba(%rip), %xmm1    # 0x34270
callq 0x25bd9
testb %al, %al
je 0x14411
movq $-0x1, %rax
jmp 0x14331
movaps (%rsp), %xmm0
movq %r14, %rdi
callq 0x25e30
movsd 0x1f281(%rip), %xmm1    # 0x33660
mulsd 0x10(%rsp), %xmm1
callq 0x25c15
testb %al, %al
je 0x14418
xorpd %xmm1, %xmm1
movaps (%rsp), %xmm0
callq 0x25bf9
xorb $0x1, %al
movzbl %al, %eax
movsd 0x10(%r14,%rax,8), %xmm0
movl $0x1, %eax
jmp 0x14335
xorl %eax, %eax
jmp 0x14339
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
xorl %eax, %eax
jmp 0x14335