// File: /workspace/github_cpp_makefile_star2_O1/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 0x6a200(%rip), %rax     # 0xfdcd0
movq (%rax), %r14
movq 0x1ae0(%r14), %rbx
cmpb $0x0, 0x93(%rbx)
je 0x93af7
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r15
movss 0x8(%rdi), %xmm8
subss (%rdi), %xmm8
xorl %eax, %eax
xorps %xmm2, %xmm2
ucomiss %xmm8, %xmm2
jae 0x93ae5
movss 0xc(%r15), %xmm6
subss 0x4(%r15), %xmm6
ucomiss %xmm6, %xmm2
jae 0x93ae5
movq %rcx, %r12
movl %esi, %r13d
movss 0x234b5(%rip), %xmm5    # 0xb6fe4
cmpl $0x1, %edx
jne 0x93b78
movss 0x1980(%r14), %xmm3
movss 0x159c(%r14), %xmm2
addss %xmm2, %xmm2
movaps %xmm2, %xmm4
addss %xmm3, %xmm4
ucomiss %xmm6, %xmm4
jbe 0x93b78
movaps %xmm6, %xmm5
subss %xmm3, %xmm5
divss %xmm2, %xmm5
movss 0x2347b(%rip), %xmm2    # 0xb6fe4
minss %xmm5, %xmm2
xorps %xmm3, %xmm3
cmpltss %xmm3, %xmm5
andnps %xmm2, %xmm5
xorps %xmm2, %xmm2
ucomiss %xmm5, %xmm2
jae 0x93ae3
movaps %xmm5, -0x90(%rbp)
movups (%r15), %xmm2
movaps %xmm2, -0x40(%rbp)
movss 0x23cf1(%rip), %xmm4    # 0xb788c
addss %xmm4, %xmm8
movss 0x2345c(%rip), %xmm7    # 0xb7004
mulss %xmm7, %xmm8
cvttss2si %xmm8, %eax
movaps 0x23407(%rip), %xmm3    # 0xb6fc0
movss 0x3f2eb(%rip), %xmm2    # 0xd2eac
movaps %xmm2, %xmm5
cmpl $0x4, %eax
jge 0x93bd4
cvttps2dq %xmm8, %xmm5
cvtdq2ps %xmm5, %xmm5
xorps %xmm3, %xmm5
movss 0x3f2d3(%rip), %xmm9    # 0xd2eb0
movaps %xmm9, %xmm8
testl %eax, %eax
js 0x93be9
movaps %xmm5, %xmm8
addss %xmm4, %xmm6
mulss %xmm7, %xmm6
cvttss2si %xmm6, %eax
cmpl $0x4, %eax
jge 0x93c04
cvttps2dq %xmm6, %xmm2
cvtdq2ps %xmm2, %xmm2
xorps %xmm3, %xmm2
testl %eax, %eax
js 0x93c0c
movaps %xmm2, %xmm9
movss -0x40(%rbp), %xmm3
movss -0x3c(%rbp), %xmm2
subss %xmm8, %xmm3
movss %xmm3, -0x40(%rbp)
subss %xmm9, %xmm2
movss %xmm2, -0x3c(%rbp)
addss -0x38(%rbp), %xmm8
movss %xmm8, -0x38(%rbp)
addss -0x34(%rbp), %xmm9
movss %xmm9, -0x34(%rbp)
testl %edx, %edx
je 0x93c51
subss %xmm2, %xmm9
movaps %xmm9, %xmm8
jmp 0x93c56
subss %xmm3, %xmm8
movss %xmm8, -0x44(%rbp)
movl %r8d, -0x50(%rbp)
movl %edx, -0x4c(%rbp)
movaps %xmm0, %xmm3
cmpless %xmm1, %xmm3
movaps %xmm3, %xmm2
andps %xmm1, %xmm2
andnps %xmm0, %xmm3
orps %xmm2, %xmm3
xorps %xmm2, %xmm2
movaps %xmm3, -0x80(%rbp)
ucomiss %xmm2, %xmm3
movaps %xmm0, -0xa0(%rbp)
movaps %xmm1, -0x60(%rbp)
jbe 0x9400c
movss 0x15d8(%r14), %xmm0
movaps %xmm0, -0x70(%rbp)
xorl %eax, %eax
leaq -0x29(%rbp), %rcx
movb %al, (%rcx)
leaq -0x2a(%rbp), %rdx
movb %al, (%rdx)
leaq -0x40(%rbp), %rdi
movl %r13d, %esi
movl $0x40000, %r8d          # imm = 0x40000
callq 0x92870
movss 0x2331d(%rip), %xmm3    # 0xb6fe4
movaps -0x90(%rbp), %xmm0
ucomiss %xmm3, %xmm0
movaps -0x80(%rbp), %xmm0
maxss %xmm3, %xmm0
movaps -0xa0(%rbp), %xmm4
movaps -0x60(%rbp), %xmm6
subss %xmm4, %xmm6
divss %xmm0, %xmm4
movss -0x44(%rbp), %xmm2
mulss %xmm2, %xmm4
movaps %xmm2, %xmm0
minss %xmm4, %xmm0
movaps -0x70(%rbp), %xmm5
cmpltss %xmm5, %xmm4
movaps %xmm4, %xmm1
andnps %xmm0, %xmm1
andps %xmm5, %xmm4
orps %xmm1, %xmm4
movaps %xmm3, %xmm5
maxss %xmm6, %xmm5
movss (%r12), %xmm1
divss %xmm5, %xmm1
movaps %xmm3, %xmm0
minss %xmm1, %xmm0
cmpltss 0x23b12(%rip), %xmm1    # 0xb7844
andnps %xmm0, %xmm1
movaps %xmm2, %xmm6
subss %xmm4, %xmm6
mulss %xmm6, %xmm1
divss %xmm2, %xmm1
movaps %xmm4, -0xa0(%rbp)
movaps %xmm1, -0x60(%rbp)
jb 0x93efe
divss %xmm2, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x93efe
cmpb $0x0, -0x29(%rbp)
je 0x93efe
movss %xmm6, -0x48(%rbp)
movss %xmm5, -0x70(%rbp)
movaps %xmm4, -0x80(%rbp)
movl -0x4c(%rbp), %eax
cmpl $0x2, %eax
jae 0x9402b
movl %eax, %eax
movss 0x128(%r14,%rax,4), %xmm4
subss -0x40(%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 0x46c54
cmpb $0x1, 0x1b3c(%r14)
jne 0x93e3b
movaps -0x80(%rbp), %xmm5
movaps %xmm5, %xmm0
movaps -0x60(%rbp), %xmm3
addss %xmm3, %xmm0
movaps -0xb0(%rbp), %xmm8
movaps %xmm8, %xmm1
cmpltps %xmm3, %xmm1
cmpltps %xmm8, %xmm0
orps %xmm1, %xmm0
movd %xmm0, %eax
xorps %xmm0, %xmm0
testb $0x1, %al
movss 0x23205(%rip), %xmm2    # 0xb7004
movss -0x70(%rbp), %xmm6
movss -0x48(%rbp), %xmm7
jne 0x93e23
movaps %xmm8, %xmm1
subss %xmm3, %xmm1
movss 0x23aa9(%rip), %xmm0    # 0xb78c4
mulss %xmm5, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x30a4(%r14)
movss -0x44(%rbp), %xmm3
movss 0x231ab(%rip), %xmm4    # 0xb6fe4
jmp 0x93e68
xorl %eax, %eax
movss 0x231bf(%rip), %xmm2    # 0xb7004
movss -0x44(%rbp), %xmm3
movss 0x23192(%rip), %xmm4    # 0xb6fe4
movaps -0x80(%rbp), %xmm5
movss -0x70(%rbp), %xmm6
movss -0x48(%rbp), %xmm7
movaps -0xb0(%rbp), %xmm8
xorps %xmm9, %xmm9
movss 0x30a4(%r14), %xmm0
movaps %xmm8, %xmm1
subss %xmm0, %xmm1
movaps %xmm5, %xmm0
mulss %xmm2, %xmm0
subss %xmm0, %xmm1
movaps %xmm4, %xmm0
subss %xmm5, %xmm0
divss %xmm0, %xmm1
movaps %xmm4, %xmm0
minss %xmm1, %xmm0
cmpltss %xmm9, %xmm1
andnps %xmm0, %xmm1
mulss %xmm6, %xmm1
addss %xmm2, %xmm1
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
movss %xmm0, (%r12)
divss %xmm6, %xmm0
minss %xmm0, %xmm4
cmpltss %xmm9, %xmm0
andnps %xmm4, %xmm0
mulss %xmm0, %xmm7
movaps %xmm7, %xmm0
divss %xmm3, %xmm0
testb $0x1, %al
movaps %xmm0, -0x60(%rbp)
je 0x93efe
xorps 0x230dd(%rip), %xmm5    # 0xb6fc0
subss %xmm0, %xmm8
mulss 0x23114(%rip), %xmm5    # 0xb7004
addss %xmm8, %xmm5
movss %xmm5, 0x30a4(%r14)
leaq 0x8(%r15), %r13
movss 0x230da(%rip), %xmm0    # 0xb6fe4
movl $0xe, %edi
callq 0x445bd
movzbl -0x2a(%rbp), %ecx
andl $0x1, %ecx
addl $0xf, %ecx
cmpb $0x0, -0x29(%rbp)
movl %eax, %r12d
movl $0x11, %edi
cmovel %ecx, %edi
movaps -0x90(%rbp), %xmm0
callq 0x445bd
movl %eax, -0x90(%rbp)
movq 0x2b8(%rbx), %rdi
movss 0x48(%rbx), %xmm0
movq %r15, %rsi
movq %r13, %rdx
movl %r12d, %ecx
movl -0x50(%rbp), %r8d
callq 0x79d4a
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movss -0x40(%rbp), %xmm0
cmpl $0x0, -0x4c(%rbp)
je 0x93f9b
movss -0x34(%rbp), %xmm1
movss -0x3c(%rbp), %xmm3
movaps -0xa0(%rbp), %xmm2
movss -0x38(%rbp), %xmm4
subss %xmm3, %xmm1
mulss -0x60(%rbp), %xmm1
addss %xmm3, %xmm1
addss %xmm1, %xmm2
jmp 0x93fc2
movss -0x3c(%rbp), %xmm1
movss -0x38(%rbp), %xmm2
subss %xmm0, %xmm2
mulss -0x60(%rbp), %xmm2
addss %xmm2, %xmm0
movaps -0xa0(%rbp), %xmm4
addss %xmm0, %xmm4
movss -0x34(%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(%r14), %xmm0
leaq -0xc0(%rbp), %rsi
movl -0x90(%rbp), %ecx
movl $0xf, %r8d
callq 0x79d4a
movb -0x29(%rbp), %al
jmp 0x93ae5
leaq 0x3f301(%rip), %rdi     # 0xd3314
leaq 0x3f12e(%rip), %rsi     # 0xd3148
leaq 0x3f31f(%rip), %rcx     # 0xd3340
movl $0x399, %edx            # imm = 0x399
callq 0xc140
leaq 0x4101c(%rip), %rdi     # 0xd504e
leaq 0x27652(%rip), %rsi     # 0xbb68b
leaq 0x41017(%rip), %rcx     # 0xd5057
movl $0xe5, %edx
callq 0xc140