// File: /workspace/github_cpp_makefile_star2_O2/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 0x94af4
jnp 0x94df6
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 0x94b5f
movapd %xmm2, %xmm5
minsd %xmm1, %xmm5
movapd %xmm1, %xmm7
maxsd %xmm2, %xmm7
movapd 0x23605(%rip), %xmm6    # 0xb8140
andpd %xmm5, %xmm6
cvtss2sd %xmm3, %xmm9
ucomisd %xmm6, %xmm9
movapd %xmm5, %xmm10
jbe 0x94b84
xorpd %xmm6, %xmm6
ucomisd %xmm5, %xmm6
ja 0x94b75
movaps %xmm3, %xmm6
jmp 0x94b7f
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm11
jmp 0x94df6
movaps 0x7464(%rip), %xmm6     # 0x9bfe0
xorps %xmm3, %xmm6
cvtss2sd %xmm6, %xmm10
movapd 0x235b4(%rip), %xmm6    # 0xb8140
andpd %xmm7, %xmm6
ucomisd %xmm6, %xmm9
movapd %xmm7, %xmm12
jbe 0x94bba
xorpd %xmm6, %xmm6
ucomisd %xmm7, %xmm6
ja 0x94bab
movaps %xmm3, %xmm6
jmp 0x94bb5
movaps 0x742e(%rip), %xmm6     # 0x9bfe0
xorps %xmm3, %xmm6
cvtss2sd %xmm6, %xmm12
xorpd %xmm6, %xmm6
ucomisd %xmm6, %xmm5
jne 0x94bda
jp 0x94bda
ucomisd %xmm7, %xmm6
jbe 0x94bda
xorps 0x740d(%rip), %xmm3     # 0x9bfe0
cvtss2sd %xmm3, %xmm10
jmp 0x94bf4
ucomisd %xmm6, %xmm7
jne 0x94bf4
jp 0x94bf4
ucomisd %xmm5, %xmm6
jbe 0x94bf4
xorps 0x73f1(%rip), %xmm3     # 0x9bfe0
cvtss2sd %xmm3, %xmm12
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
xorps %xmm11, %xmm11
ucomisd %xmm0, %xmm10
jae 0x94dda
ucomisd %xmm12, %xmm0
jae 0x94cda
movapd %xmm1, %xmm6
mulsd %xmm2, %xmm6
xorps %xmm3, %xmm3
ucomisd %xmm6, %xmm3
jbe 0x94ce8
cvtsd2ss %xmm5, %xmm5
movaps 0x73a9(%rip), %xmm11    # 0x9bfe0
xorps %xmm5, %xmm11
cvtsd2ss %xmm7, %xmm6
subss %xmm5, %xmm6
divss %xmm6, %xmm11
ucomisd %xmm3, %xmm8
jne 0x94c55
jnp 0x94dda
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
xorpd %xmm2, %xmm2
ucomisd %xmm8, %xmm2
movsd %xmm9, -0x48(%rbp)
jbe 0x94d7a
subss %xmm4, %xmm11
movaps %xmm11, -0x30(%rbp)
xorpd 0x234ca(%rip), %xmm0    # 0xb8150
divsd %xmm9, %xmm0
movapd %xmm10, -0x40(%rbp)
callq 0xc150
movsd %xmm0, -0x8(%rbp)
movapd -0x40(%rbp), %xmm0
xorpd 0x234a8(%rip), %xmm0    # 0xb8150
divsd -0x48(%rbp), %xmm0
callq 0xc150
movaps -0x30(%rbp), %xmm11
movsd -0x8(%rbp), %xmm1
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss 0x732c(%rip), %xmm1     # 0x9bff8
subss %xmm0, %xmm1
mulss %xmm1, %xmm11
jmp 0x94dd0
movss 0x7315(%rip), %xmm11    # 0x9bff8
jmp 0x94dda
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
ucomisd %xmm5, %xmm3
movapd %xmm10, -0x40(%rbp)
movsd %xmm12, -0x8(%rbp)
ja 0x94d3f
xorpd %xmm1, %xmm1
ucomisd %xmm7, %xmm1
ja 0x94d3f
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
cvtsd2ss %xmm1, %xmm11
jmp 0x94dd0
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
cvtsd2ss %xmm1, %xmm0
movss 0x7285(%rip), %xmm11    # 0x9bff8
subss %xmm0, %xmm11
jmp 0x94dd0
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
cvtsd2ss %xmm1, %xmm0
movss 0x7236(%rip), %xmm1     # 0x9bff8
subss %xmm11, %xmm1
mulss %xmm0, %xmm1
addss %xmm1, %xmm11
movsd -0x18(%rbp), %xmm2
movsd -0x10(%rbp), %xmm1
ucomisd %xmm2, %xmm1
jbe 0x94df1
movss 0x7210(%rip), %xmm0     # 0x9bff8
subss %xmm11, %xmm0
movaps %xmm0, %xmm11
addq $0x50, %rsp
popq %rbp
movaps %xmm11, %xmm0
retq