// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: float ImGui::ScaleRatioFromValueT<double, double, double>(int, double, double, double, bool, float, float)
float ImGui::ScaleRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_halfsize)
{
    if (v_min == v_max)
        return 0.0f;
    IM_UNUSED(data_type);

    const TYPE v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min);
    if (is_logarithmic)
    {
        bool flipped = v_max < v_min;

        if (flipped) // Handle the case where the range is backwards
            ImSwap(v_min, v_max);

        // Fudge min/max to avoid getting close to log(0)
        FLOATTYPE v_min_fudged = (ImAbs((FLOATTYPE)v_min) < logarithmic_zero_epsilon) ? ((v_min < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_min;
        FLOATTYPE v_max_fudged = (ImAbs((FLOATTYPE)v_max) < logarithmic_zero_epsilon) ? ((v_max < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_max;

        // Awkward special cases - we need ranges of the form (-100 .. 0) to convert to (-100 .. -epsilon), not (-100 .. epsilon)
        if ((v_min == 0.0f) && (v_max < 0.0f))
            v_min_fudged = -logarithmic_zero_epsilon;
        else if ((v_max == 0.0f) && (v_min < 0.0f))
            v_max_fudged = -logarithmic_zero_epsilon;

        float result;

        if (v_clamped <= v_min_fudged)
            result = 0.0f; // Workaround for values that are in-range but below our fudge
        else if (v_clamped >= v_max_fudged)
            result = 1.0f; // Workaround for values that are in-range but above our fudge
        else if ((v_min * v_max) < 0.0f) // Range crosses zero, so split into two portions
        {
            float zero_point_center = (-(float)v_min) / ((float)v_max - (float)v_min); // The zero point in parametric space.  There's an argument we should take the logarithmic nature into account when calculating this, but for now this should do (and the most common case of a symmetrical range works fine)
            float zero_point_snap_L = zero_point_center - zero_deadzone_halfsize;
            float zero_point_snap_R = zero_point_center + zero_deadzone_halfsize;
            if (v == 0.0f)
                result = zero_point_center; // Special case for exactly zero
            else if (v < 0.0f)
                result = (1.0f - (float)(ImLog(-(FLOATTYPE)v_clamped / logarithmic_zero_epsilon) / ImLog(-v_min_fudged / logarithmic_zero_epsilon))) * zero_point_snap_L;
            else
                result = zero_point_snap_R + ((float)(ImLog((FLOATTYPE)v_clamped / logarithmic_zero_epsilon) / ImLog(v_max_fudged / logarithmic_zero_epsilon)) * (1.0f - zero_point_snap_R));
        }
        else if ((v_min < 0.0f) || (v_max < 0.0f)) // Entirely negative slider
            result = 1.0f - (float)(ImLog(-(FLOATTYPE)v_clamped / -v_max_fudged) / ImLog(-v_min_fudged / -v_max_fudged));
        else
            result = (float)(ImLog((FLOATTYPE)v_clamped / v_min_fudged) / ImLog(v_max_fudged / v_min_fudged));

        return flipped ? (1.0f - result) : result;
    }

    // Linear slider
    return (float)((FLOATTYPE)(SIGNEDTYPE)(v_clamped - v_min) / (FLOATTYPE)(SIGNEDTYPE)(v_max - v_min));
}

// Assembly:
xorps %xmm11, %xmm11
ucomisd %xmm2, %xmm1
jne 0xad79e
jnp 0xadac4
movapd %xmm0, %xmm8
movapd %xmm1, %xmm6
minsd %xmm2, %xmm6
movapd %xmm2, %xmm5
maxsd %xmm1, %xmm5
minsd %xmm0, %xmm5
cmpltsd %xmm6, %xmm0
andpd %xmm0, %xmm6
andnpd %xmm5, %xmm0
orpd %xmm6, %xmm0
testb %sil, %sil
je 0xad809
movapd %xmm2, %xmm5
minsd %xmm1, %xmm5
movapd %xmm1, %xmm7
maxsd %xmm2, %xmm7
movapd 0x235eb(%rip), %xmm6    # 0xd0dd0
andpd %xmm5, %xmm6
cvtss2sd %xmm3, %xmm9
ucomisd %xmm6, %xmm9
movapd %xmm5, %xmm10
jbe 0xad836
xorpd %xmm6, %xmm6
ucomisd %xmm5, %xmm6
ja 0xad823
movaps %xmm3, %xmm6
jmp 0xad82d
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
xorps %xmm11, %xmm11
cvtsd2ss %xmm0, %xmm11
jmp 0xadac4
movaps 0x7796(%rip), %xmm6     # 0xb4fc0
xorps %xmm3, %xmm6
xorps %xmm10, %xmm10
cvtss2sd %xmm6, %xmm10
movapd 0x23592(%rip), %xmm6    # 0xd0dd0
andpd %xmm7, %xmm6
ucomisd %xmm6, %xmm9
movapd %xmm7, %xmm12
jbe 0xad870
xorpd %xmm6, %xmm6
ucomisd %xmm7, %xmm6
ja 0xad85d
movaps %xmm3, %xmm6
jmp 0xad867
movaps 0x775c(%rip), %xmm6     # 0xb4fc0
xorps %xmm3, %xmm6
xorps %xmm12, %xmm12
cvtss2sd %xmm6, %xmm12
xorpd %xmm6, %xmm6
ucomisd %xmm6, %xmm5
jne 0xad894
jp 0xad894
ucomisd %xmm7, %xmm6
jbe 0xad894
xorps 0x7737(%rip), %xmm3     # 0xb4fc0
xorps %xmm10, %xmm10
cvtss2sd %xmm3, %xmm10
jmp 0xad8b2
ucomisd %xmm6, %xmm7
jne 0xad8b2
jp 0xad8b2
ucomisd %xmm5, %xmm6
jbe 0xad8b2
xorps 0x7717(%rip), %xmm3     # 0xb4fc0
xorps %xmm12, %xmm12
cvtss2sd %xmm3, %xmm12
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
xorps %xmm11, %xmm11
ucomisd %xmm0, %xmm10
jae 0xadaa8
ucomisd %xmm12, %xmm0
jae 0xad99e
movapd %xmm1, %xmm6
mulsd %xmm2, %xmm6
xorps %xmm3, %xmm3
ucomisd %xmm6, %xmm3
jbe 0xad9ac
cvtsd2ss %xmm5, %xmm5
movaps 0x76cb(%rip), %xmm11    # 0xb4fc0
xorps %xmm5, %xmm11
xorps %xmm6, %xmm6
cvtsd2ss %xmm7, %xmm6
subss %xmm5, %xmm6
divss %xmm6, %xmm11
ucomisd %xmm3, %xmm8
jne 0xad916
jnp 0xadaa8
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
xorpd %xmm2, %xmm2
ucomisd %xmm8, %xmm2
movsd %xmm9, -0x48(%rbp)
jbe 0xada45
subss %xmm4, %xmm11
movaps %xmm11, -0x30(%rbp)
xorpd 0x23499(%rip), %xmm0    # 0xd0de0
divsd %xmm9, %xmm0
movapd %xmm10, -0x40(%rbp)
callq 0xc150
movsd %xmm0, -0x8(%rbp)
movapd -0x40(%rbp), %xmm0
xorpd 0x23477(%rip), %xmm0    # 0xd0de0
divsd -0x48(%rbp), %xmm0
callq 0xc150
movaps -0x30(%rbp), %xmm11
movsd -0x8(%rbp), %xmm1
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0x7654(%rip), %xmm1     # 0xb4fe4
subss %xmm0, %xmm1
mulss %xmm1, %xmm11
jmp 0xada9e
movss 0x763d(%rip), %xmm11    # 0xb4fe4
jmp 0xadaa8
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
ucomisd %xmm5, %xmm3
movapd %xmm10, -0x40(%rbp)
movsd %xmm12, -0x8(%rbp)
ja 0xada07
xorpd %xmm1, %xmm1
ucomisd %xmm7, %xmm1
ja 0xada07
divsd %xmm10, %xmm0
callq 0xc150
movsd %xmm0, -0x30(%rbp)
movsd -0x8(%rbp), %xmm0
divsd -0x40(%rbp), %xmm0
callq 0xc150
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
xorps %xmm11, %xmm11
cvtsd2ss %xmm1, %xmm11
jmp 0xada9e
divsd %xmm12, %xmm0
callq 0xc150
movsd %xmm0, -0x30(%rbp)
movapd -0x40(%rbp), %xmm0
divsd -0x8(%rbp), %xmm0
callq 0xc150
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0x75a6(%rip), %xmm11    # 0xb4fe4
subss %xmm0, %xmm11
jmp 0xada9e
addss %xmm4, %xmm11
movaps %xmm11, -0x30(%rbp)
divsd %xmm9, %xmm0
movsd %xmm12, -0x8(%rbp)
callq 0xc150
movsd %xmm0, -0x40(%rbp)
movsd -0x8(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
callq 0xc150
movaps -0x30(%rbp), %xmm11
movsd -0x40(%rbp), %xmm1
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0x7554(%rip), %xmm1     # 0xb4fe4
subss %xmm11, %xmm1
mulss %xmm0, %xmm1
addss %xmm1, %xmm11
movsd -0x18(%rbp), %xmm2
movsd -0x10(%rbp), %xmm1
ucomisd %xmm2, %xmm1
jbe 0xadabf
movss 0x752e(%rip), %xmm0     # 0xb4fe4
subss %xmm11, %xmm0
movaps %xmm0, %xmm11
addq $0x50, %rsp
popq %rbp
movaps %xmm11, %xmm0
retq