// File: /workspace/github_cpp_makefile_star2_O2/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 $0xa8, %rsp
leaq 0x68c52(%rip), %rax     # 0xe3ce0
movq (%rax), %rbx
movq 0x1ae0(%rbx), %r12
cmpb $0x0, 0x93(%r12)
je 0x7b0aa
xorl %eax, %eax
jmp 0x7b5ef
movq %rdi, %r15
movss 0x8(%rdi), %xmm8
subss (%rdi), %xmm8
xorl %eax, %eax
xorps %xmm2, %xmm2
ucomiss %xmm8, %xmm2
jae 0x7b5ef
movss 0xc(%r15), %xmm6
subss 0x4(%r15), %xmm6
ucomiss %xmm6, %xmm2
jae 0x7b5ef
movl %edx, %r14d
movl %esi, %r13d
movss 0x20f0e(%rip), %xmm2    # 0x9bff8
movss %xmm2, -0x44(%rbp)
cmpl $0x1, %edx
jne 0x7b147
movss 0x1980(%rbx), %xmm3
movss 0x159c(%rbx), %xmm2
addss %xmm2, %xmm2
movaps %xmm2, %xmm4
addss %xmm3, %xmm4
ucomiss %xmm6, %xmm4
jbe 0x7b147
movaps %xmm6, %xmm4
subss %xmm3, %xmm4
divss %xmm2, %xmm4
xorl %eax, %eax
xorps %xmm2, %xmm2
ucomiss %xmm4, %xmm2
ja 0x7b5ef
movss 0x20ec3(%rip), %xmm3    # 0x9bff8
minss %xmm4, %xmm3
movss %xmm3, -0x44(%rbp)
ucomiss %xmm3, %xmm2
jae 0x7b5ef
movups (%r15), %xmm2
movaps %xmm2, -0x40(%rbp)
movss 0x21761(%rip), %xmm4    # 0x9c8b8
addss %xmm4, %xmm8
movss 0x20eb4(%rip), %xmm7    # 0x9c018
mulss %xmm7, %xmm8
cvttss2si %xmm8, %eax
movaps 0x20e6b(%rip), %xmm3    # 0x9bfe0
movss 0x3cf6b(%rip), %xmm2    # 0xb80e8
movaps %xmm2, %xmm5
cmpl $0x4, %eax
jge 0x7b190
cvttps2dq %xmm8, %xmm5
cvtdq2ps %xmm5, %xmm5
xorps %xmm3, %xmm5
movss 0x3cf53(%rip), %xmm9    # 0xb80ec
movaps %xmm9, %xmm8
testl %eax, %eax
js 0x7b1a5
movaps %xmm5, %xmm8
addss %xmm4, %xmm6
mulss %xmm7, %xmm6
cvttss2si %xmm6, %eax
cmpl $0x4, %eax
jge 0x7b1c0
cvttps2dq %xmm6, %xmm2
cvtdq2ps %xmm2, %xmm2
xorps %xmm3, %xmm2
testl %eax, %eax
js 0x7b1c8
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 %r14d, %r14d
je 0x7b20e
subss %xmm2, %xmm9
movaps %xmm9, %xmm8
jmp 0x7b213
subss %xmm3, %xmm8
movss %xmm8, -0x30(%rbp)
movq %rcx, -0x50(%rbp)
movl %r8d, -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, -0xa0(%rbp)
ucomiss %xmm2, %xmm3
movaps %xmm0, -0xb0(%rbp)
movaps %xmm1, -0x70(%rbp)
jbe 0x7b601
leaq 0x8(%r15), %rax
movq %rax, -0xb8(%rbp)
movss 0x15d8(%rbx), %xmm0
movaps %xmm0, -0x90(%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 0x79dde
movss 0x20d63(%rip), %xmm3    # 0x9bff8
movss -0x44(%rbp), %xmm0
ucomiss %xmm3, %xmm0
movaps -0xa0(%rbp), %xmm0
maxss %xmm3, %xmm0
movaps -0xb0(%rbp), %xmm4
movaps -0x70(%rbp), %xmm6
subss %xmm4, %xmm6
divss %xmm0, %xmm4
movss -0x30(%rbp), %xmm2
mulss %xmm2, %xmm4
movaps %xmm2, %xmm0
minss %xmm4, %xmm0
movaps -0x90(%rbp), %xmm5
cmpltss %xmm5, %xmm4
movaps %xmm4, %xmm1
andnps %xmm0, %xmm1
andps %xmm5, %xmm4
orps %xmm1, %xmm4
movaps %xmm3, %xmm5
maxss %xmm6, %xmm5
movq -0x50(%rbp), %rax
movss (%rax), %xmm1
divss %xmm5, %xmm1
movaps %xmm3, %xmm0
minss %xmm1, %xmm0
cmpltss 0x215be(%rip), %xmm1    # 0x9c8c4
andnps %xmm0, %xmm1
movaps %xmm2, %xmm6
subss %xmm4, %xmm6
mulss %xmm6, %xmm1
divss %xmm2, %xmm1
movaps %xmm4, -0xb0(%rbp)
movl %r14d, -0x54(%rbp)
movaps %xmm1, -0x70(%rbp)
jb 0x7b4fb
divss %xmm2, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x7b4fb
cmpb $0x0, -0x29(%rbp)
je 0x7b4fb
movss %xmm6, -0x48(%rbp)
movss %xmm5, -0x90(%rbp)
movaps %xmm4, -0xa0(%rbp)
movslq %r14d, %r14
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x8e818
movss (%rax), %xmm0
movss %xmm0, -0x80(%rbp)
leaq 0x128(%rbx), %rdi
movq %r14, %rsi
callq 0x8e818
movss (%rax), %xmm2
subss -0x80(%rbp), %xmm2
divss -0x30(%rbp), %xmm2
movss 0x20c63(%rip), %xmm0    # 0x9bff8
minss %xmm2, %xmm0
xorps %xmm1, %xmm1
cmpltss %xmm1, %xmm2
andnps %xmm0, %xmm2
movaps %xmm2, -0x80(%rbp)
movl %r13d, %edi
callq 0x37452
cmpb $0x0, 0x1b3c(%rbx)
je 0x7b41a
movaps -0x70(%rbp), %xmm2
movaps -0x80(%rbp), %xmm9
ucomiss %xmm9, %xmm2
movq -0x50(%rbp), %rcx
movss 0x20c46(%rip), %xmm3    # 0x9c018
movaps -0xa0(%rbp), %xmm6
movss -0x90(%rbp), %xmm7
movss -0x48(%rbp), %xmm8
ja 0x7b459
movaps %xmm6, %xmm0
addss %xmm2, %xmm0
ucomiss %xmm0, %xmm9
ja 0x7b459
movaps %xmm9, %xmm1
subss %xmm2, %xmm1
movss 0x214ee(%rip), %xmm0    # 0x9c8f4
mulss %xmm6, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x30a4(%rbx)
xorl %eax, %eax
jmp 0x7b465
movss 0x30a4(%rbx), %xmm0
xorl %eax, %eax
movq -0x50(%rbp), %rcx
movss 0x20be8(%rip), %xmm3    # 0x9c018
movss -0x30(%rbp), %xmm4
movss 0x20bbb(%rip), %xmm5    # 0x9bff8
movaps -0xa0(%rbp), %xmm6
movss -0x90(%rbp), %xmm7
movss -0x48(%rbp), %xmm8
movaps -0x80(%rbp), %xmm9
jmp 0x7b472
andl $0x0, 0x30a4(%rbx)
movb $0x1, %al
xorps %xmm0, %xmm0
movss -0x30(%rbp), %xmm4
movss 0x20b86(%rip), %xmm5    # 0x9bff8
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, (%rcx)
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 0x7b4fb
xorps 0x20aff(%rip), %xmm6    # 0x9bfe0
subss %xmm0, %xmm9
mulss 0x20b2a(%rip), %xmm6    # 0x9c018
addss %xmm9, %xmm6
movss %xmm6, 0x30a4(%rbx)
pushq $0xe
popq %rdi
movss 0x20af2(%rip), %xmm0    # 0x9bff8
callq 0x35d33
movzbl -0x2a(%rbp), %ecx
andl $0x1, %ecx
addl $0xf, %ecx
cmpb $0x0, -0x29(%rbp)
movl %eax, %r14d
pushq $0x11
popq %rdi
cmovel %ecx, %edi
movss -0x44(%rbp), %xmm0
callq 0x35d33
movl %eax, %r13d
movq 0x2b8(%r12), %rdi
movss 0x48(%r12), %xmm0
movq %r15, %rsi
movq -0xb8(%rbp), %rdx
movl %r14d, %ecx
movl -0x58(%rbp), %r8d
callq 0x64020
movss -0x40(%rbp), %xmm0
cmpl $0x0, -0x54(%rbp)
je 0x7b588
movss -0x34(%rbp), %xmm1
movss -0x3c(%rbp), %xmm3
movaps -0xb0(%rbp), %xmm2
movss -0x38(%rbp), %xmm4
subss %xmm3, %xmm1
mulss -0x70(%rbp), %xmm1
addss %xmm3, %xmm1
addss %xmm1, %xmm2
jmp 0x7b5af
movss -0x3c(%rbp), %xmm1
movss -0x38(%rbp), %xmm2
subss %xmm0, %xmm2
mulss -0x70(%rbp), %xmm2
addss %xmm2, %xmm0
movaps -0xb0(%rbp), %xmm4
addss %xmm0, %xmm4
movss -0x34(%rbp), %xmm2
leaq -0xc0(%rbp), %rdx
movss %xmm0, -0x8(%rdx)
movss %xmm1, -0x4(%rdx)
movss %xmm4, (%rdx)
movss %xmm2, 0x4(%rdx)
movq 0x2b8(%r12), %rdi
movss 0x15d4(%rbx), %xmm0
leaq -0xc8(%rbp), %rsi
pushq $0xf
popq %r8
movl %r13d, %ecx
callq 0x64020
movb -0x29(%rbp), %al
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3cf4c(%rip), %rdi     # 0xb8554
leaq 0x3cd79(%rip), %rsi     # 0xb8388
leaq 0x3cf6a(%rip), %rcx     # 0xb8580
movl $0x399, %edx            # imm = 0x399
callq 0xc140