// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::ScrollbarEx(ImRect const&, unsigned int, ImGuiAxis, float*, float, float, int)
bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float size_avail_v, float size_contents_v, ImDrawCornerFlags rounding_corners)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    if (window->SkipItems)
        return false;

    const float bb_frame_width = bb_frame.GetWidth();
    const float bb_frame_height = bb_frame.GetHeight();
    if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f)
        return false;

    // When we are too small, start hiding and disabling the grab (this reduce visual noise on very small window and facilitate using the window resize grab)
    float alpha = 1.0f;
    if ((axis == ImGuiAxis_Y) && bb_frame_height < g.FontSize + g.Style.FramePadding.y * 2.0f)
        alpha = ImSaturate((bb_frame_height - g.FontSize) / (g.Style.FramePadding.y * 2.0f));
    if (alpha <= 0.0f)
        return false;

    const ImGuiStyle& style = g.Style;
    const bool allow_interaction = (alpha >= 1.0f);

    ImRect bb = bb_frame;
    bb.Expand(ImVec2(-ImClamp(IM_FLOOR((bb_frame_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp(IM_FLOOR((bb_frame_height - 2.0f) * 0.5f), 0.0f, 3.0f)));

    // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
    const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight();

    // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount)
    // But we maintain a minimum size in pixel to allow for the user to still aim inside.
    IM_ASSERT(ImMax(size_contents_v, size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers.
    const float win_size_v = ImMax(ImMax(size_contents_v, size_avail_v), 1.0f);
    const float grab_h_pixels = ImClamp(scrollbar_size_v * (size_avail_v / win_size_v), style.GrabMinSize, scrollbar_size_v);
    const float grab_h_norm = grab_h_pixels / scrollbar_size_v;

    // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar().
    bool held = false;
    bool hovered = false;
    ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_NoNavFocus);

    float scroll_max = ImMax(1.0f, size_contents_v - size_avail_v);
    float scroll_ratio = ImSaturate(*p_scroll_v / scroll_max);
    float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; // Grab position in normalized space
    if (held && allow_interaction && grab_h_norm < 1.0f)
    {
        float scrollbar_pos_v = bb.Min[axis];
        float mouse_pos_v = g.IO.MousePos[axis];

        // Click position in scrollbar normalized space (0.0f->1.0f)
        const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
        SetHoveredID(id);

        bool seek_absolute = false;
        if (g.ActiveIdIsJustActivated)
        {
            // On initial click calculate the distance between mouse and the center of the grab
            seek_absolute = (clicked_v_norm < grab_v_norm || clicked_v_norm > grab_v_norm + grab_h_norm);
            if (seek_absolute)
                g.ScrollbarClickDeltaToGrabCenter = 0.0f;
            else
                g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
        }

        // Apply scroll (p_scroll_v will generally point on one member of window->Scroll)
        // It is ok to modify Scroll here because we are being called in Begin() after the calculation of ContentSize and before setting up our starting position
        const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm));
        *p_scroll_v = IM_ROUND(scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v));

        // Update values for rendering
        scroll_ratio = ImSaturate(*p_scroll_v / scroll_max);
        grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;

        // Update distance to grab now that we have seeked and saturated
        if (seek_absolute)
            g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
    }

    // Render
    const ImU32 bg_col = GetColorU32(ImGuiCol_ScrollbarBg);
    const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha);
    window->DrawList->AddRectFilled(bb_frame.Min, bb_frame.Max, bg_col, window->WindowRounding, rounding_corners);
    ImRect grab_rect;
    if (axis == ImGuiAxis_X)
        grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y);
    else
        grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels);
    window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding);

    return held;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
leaq 0x69ec4(%rip), %rax     # 0xfbcd0
movq (%rax), %r12
movq 0x1ae0(%r12), %rbx
cmpb $0x0, 0x93(%rbx)
je 0x91e27
xorl %eax, %eax
jmp 0x9234a
movq %rdi, %r15
movss 0x8(%rdi), %xmm8
subss (%rdi), %xmm8
xorl %eax, %eax
xorps %xmm2, %xmm2
ucomiss %xmm8, %xmm2
jae 0x9234a
movss 0xc(%r15), %xmm6
subss 0x4(%r15), %xmm6
ucomiss %xmm6, %xmm2
jae 0x9234a
movq %rcx, %r14
movl %esi, %r13d
movss 0x2317d(%rip), %xmm2    # 0xb4fe4
movss %xmm2, -0x30(%rbp)
cmpl $0x1, %edx
jne 0x91ec8
movss 0x1980(%r12), %xmm3
movss 0x159c(%r12), %xmm2
addss %xmm2, %xmm2
movaps %xmm2, %xmm4
addss %xmm3, %xmm4
ucomiss %xmm6, %xmm4
jbe 0x91ec8
movaps %xmm6, %xmm4
subss %xmm3, %xmm4
divss %xmm2, %xmm4
xorl %eax, %eax
xorps %xmm2, %xmm2
ucomiss %xmm4, %xmm2
ja 0x9234a
movss 0x2312e(%rip), %xmm3    # 0xb4fe4
minss %xmm4, %xmm3
movss %xmm3, -0x30(%rbp)
ucomiss %xmm3, %xmm2
jae 0x9234a
movups (%r15), %xmm2
movaps %xmm2, -0x50(%rbp)
movss 0x239b4(%rip), %xmm4    # 0xb588c
addss %xmm4, %xmm8
movss 0x2311f(%rip), %xmm7    # 0xb5004
mulss %xmm7, %xmm8
cvttss2si %xmm8, %eax
movaps 0x230ca(%rip), %xmm3    # 0xb4fc0
movss 0x3ee82(%rip), %xmm2    # 0xd0d80
movaps %xmm2, %xmm5
cmpl $0x4, %eax
jge 0x91f11
cvttps2dq %xmm8, %xmm5
cvtdq2ps %xmm5, %xmm5
xorps %xmm3, %xmm5
movss 0x3ee6a(%rip), %xmm9    # 0xd0d84
movaps %xmm9, %xmm8
testl %eax, %eax
js 0x91f26
movaps %xmm5, %xmm8
addss %xmm4, %xmm6
mulss %xmm7, %xmm6
cvttss2si %xmm6, %eax
cmpl $0x4, %eax
jge 0x91f41
cvttps2dq %xmm6, %xmm2
cvtdq2ps %xmm2, %xmm2
xorps %xmm3, %xmm2
testl %eax, %eax
js 0x91f49
movaps %xmm2, %xmm9
movss -0x50(%rbp), %xmm3
movss -0x4c(%rbp), %xmm2
subss %xmm8, %xmm3
movss %xmm3, -0x50(%rbp)
subss %xmm9, %xmm2
movss %xmm2, -0x4c(%rbp)
addss -0x48(%rbp), %xmm8
movss %xmm8, -0x48(%rbp)
addss -0x44(%rbp), %xmm9
movss %xmm9, -0x44(%rbp)
testl %edx, %edx
je 0x91f8e
subss %xmm2, %xmm9
movaps %xmm9, %xmm8
jmp 0x91f93
subss %xmm3, %xmm8
movss %xmm8, -0x34(%rbp)
movl %r8d, -0x5c(%rbp)
movl %edx, -0x58(%rbp)
movaps %xmm0, %xmm3
cmpless %xmm1, %xmm3
movaps %xmm3, %xmm2
andps %xmm1, %xmm2
andnps %xmm0, %xmm3
orps %xmm2, %xmm3
xorps %xmm2, %xmm2
movaps %xmm3, -0x90(%rbp)
ucomiss %xmm2, %xmm3
movaps %xmm0, -0xa0(%rbp)
movaps %xmm1, -0x70(%rbp)
jbe 0x9235c
movss 0x15d8(%r12), %xmm0
movaps %xmm0, -0x80(%rbp)
xorl %eax, %eax
leaq -0x29(%rbp), %rcx
movb %al, (%rcx)
leaq -0x2a(%rbp), %rdx
movb %al, (%rdx)
leaq -0x50(%rbp), %rdi
movl %r13d, %esi
movl $0x40000, %r8d          # imm = 0x40000
callq 0x90b6f
movss 0x22fdc(%rip), %xmm3    # 0xb4fe4
movss -0x30(%rbp), %xmm0
ucomiss %xmm3, %xmm0
movaps -0x90(%rbp), %xmm0
maxss %xmm3, %xmm0
movaps -0xa0(%rbp), %xmm4
movaps -0x70(%rbp), %xmm6
subss %xmm4, %xmm6
divss %xmm0, %xmm4
movss -0x34(%rbp), %xmm2
mulss %xmm2, %xmm4
movaps %xmm2, %xmm0
minss %xmm4, %xmm0
movaps -0x80(%rbp), %xmm5
cmpltss %xmm5, %xmm4
movaps %xmm4, %xmm1
andnps %xmm0, %xmm1
andps %xmm5, %xmm4
orps %xmm1, %xmm4
movaps %xmm3, %xmm5
maxss %xmm6, %xmm5
movss (%r14), %xmm1
divss %xmm5, %xmm1
movaps %xmm3, %xmm0
minss %xmm1, %xmm0
cmpltss 0x237d1(%rip), %xmm1    # 0xb5844
andnps %xmm0, %xmm1
movaps %xmm2, %xmm6
subss %xmm4, %xmm6
mulss %xmm6, %xmm1
divss %xmm2, %xmm1
movaps %xmm4, -0xa0(%rbp)
movaps %xmm1, -0x70(%rbp)
jb 0x92252
divss %xmm2, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x92252
cmpb $0x0, -0x29(%rbp)
je 0x92252
movss %xmm6, -0x54(%rbp)
movss %xmm5, -0x80(%rbp)
movaps %xmm4, -0x90(%rbp)
movl -0x58(%rbp), %eax
cmpl $0x2, %eax
jae 0x9237b
movl %eax, %eax
movss 0x128(%r12,%rax,4), %xmm4
subss -0x50(%rbp,%rax,4), %xmm4
divss %xmm2, %xmm4
movaps %xmm3, %xmm0
minss %xmm4, %xmm0
xorps %xmm1, %xmm1
cmpltss %xmm1, %xmm4
andnps %xmm0, %xmm4
movaps %xmm4, -0xb0(%rbp)
movl %r13d, %edi
callq 0x4613e
cmpb $0x0, 0x1b3c(%r12)
je 0x9216b
movaps -0x70(%rbp), %xmm2
movaps -0xb0(%rbp), %xmm9
ucomiss %xmm9, %xmm2
movss 0x22ee0(%rip), %xmm3    # 0xb5004
movaps -0x90(%rbp), %xmm6
movss -0x80(%rbp), %xmm7
movss -0x54(%rbp), %xmm8
ja 0x921a8
movaps %xmm6, %xmm0
addss %xmm2, %xmm0
ucomiss %xmm0, %xmm9
ja 0x921a8
movaps %xmm9, %xmm1
subss %xmm2, %xmm1
movss 0x2376f(%rip), %xmm0    # 0xb58c4
mulss %xmm6, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x30a4(%r12)
xorl %eax, %eax
jmp 0x921b9
movss 0x30a4(%r12), %xmm0
xorl %eax, %eax
movss 0x22e85(%rip), %xmm3    # 0xb5004
movss -0x34(%rbp), %xmm4
movss 0x22e58(%rip), %xmm5    # 0xb4fe4
movaps -0x90(%rbp), %xmm6
movss -0x80(%rbp), %xmm7
movss -0x54(%rbp), %xmm8
movaps -0xb0(%rbp), %xmm9
jmp 0x921c6
movl $0x0, 0x30a4(%r12)
movb $0x1, %al
xorps %xmm0, %xmm0
movss -0x34(%rbp), %xmm4
movss 0x22e1e(%rip), %xmm5    # 0xb4fe4
movaps %xmm9, %xmm1
subss %xmm0, %xmm1
movaps %xmm6, %xmm0
mulss %xmm3, %xmm0
subss %xmm0, %xmm1
movaps %xmm5, %xmm0
subss %xmm6, %xmm0
divss %xmm0, %xmm1
movaps %xmm5, %xmm0
minss %xmm1, %xmm0
xorps %xmm2, %xmm2
cmpltss %xmm2, %xmm1
andnps %xmm0, %xmm1
mulss %xmm7, %xmm1
addss %xmm3, %xmm1
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
movss %xmm0, (%r14)
divss %xmm7, %xmm0
minss %xmm0, %xmm5
cmpltss %xmm2, %xmm0
andnps %xmm5, %xmm0
mulss %xmm0, %xmm8
movaps %xmm8, %xmm0
divss %xmm4, %xmm0
testb %al, %al
movaps %xmm0, -0x70(%rbp)
je 0x92252
xorps 0x22d8a(%rip), %xmm6    # 0xb4fc0
subss %xmm0, %xmm9
mulss 0x22dc1(%rip), %xmm6    # 0xb5004
addss %xmm9, %xmm6
movss %xmm6, 0x30a4(%r12)
leaq 0x8(%r15), %r13
movss 0x22d86(%rip), %xmm0    # 0xb4fe4
movl $0xe, %edi
callq 0x43bca
movzbl -0x2a(%rbp), %ecx
andl $0x1, %ecx
addl $0xf, %ecx
cmpb $0x0, -0x29(%rbp)
movl %eax, %r14d
movl $0x11, %edi
cmovel %ecx, %edi
movss -0x30(%rbp), %xmm0
callq 0x43bca
movl %eax, -0x30(%rbp)
movq 0x2b8(%rbx), %rdi
movss 0x48(%rbx), %xmm0
movq %r15, %rsi
movq %r13, %rdx
movl %r14d, %ecx
movl -0x5c(%rbp), %r8d
callq 0x785e6
movss -0x50(%rbp), %xmm0
cmpl $0x0, -0x58(%rbp)
je 0x922e0
movss -0x44(%rbp), %xmm1
movss -0x4c(%rbp), %xmm3
movaps -0xa0(%rbp), %xmm2
movss -0x48(%rbp), %xmm4
subss %xmm3, %xmm1
mulss -0x70(%rbp), %xmm1
addss %xmm3, %xmm1
addss %xmm1, %xmm2
jmp 0x92307
movss -0x4c(%rbp), %xmm1
movss -0x48(%rbp), %xmm2
subss %xmm0, %xmm2
mulss -0x70(%rbp), %xmm2
addss %xmm2, %xmm0
movaps -0xa0(%rbp), %xmm4
addss %xmm0, %xmm4
movss -0x44(%rbp), %xmm2
leaq -0xb8(%rbp), %rdx
movss %xmm0, -0x8(%rdx)
movss %xmm1, -0x4(%rdx)
movss %xmm4, (%rdx)
movss %xmm2, 0x4(%rdx)
movq 0x2b8(%rbx), %rdi
movss 0x15d4(%r12), %xmm0
leaq -0xc0(%rbp), %rsi
movl -0x30(%rbp), %ecx
movl $0xf, %r8d
callq 0x785e6
movb -0x29(%rbp), %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ee81(%rip), %rdi     # 0xd11e4
leaq 0x3ecae(%rip), %rsi     # 0xd1018
leaq 0x3ee9f(%rip), %rcx     # 0xd1210
movl $0x399, %edx            # imm = 0x399
callq 0xc140
leaq 0x40b79(%rip), %rdi     # 0xd2efb
leaq 0x27302(%rip), %rsi     # 0xb968b
leaq 0x40b74(%rip), %rcx     # 0xd2f04
movl $0xe5, %edx
callq 0xc140