// File: /workspace/github_cpp_makefile_star2_O3/donfreiday[P]gb/./imgui/imgui.cpp
// Function: Scrollbar(ImGuiWindow*, bool)
static void Scrollbar(ImGuiWindow* window, bool horizontal)
{
    ImGuiState& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(horizontal ? "#SCROLLX" : "#SCROLLY");

    // Render background
    bool other_scrollbar = (horizontal ? window->ScrollbarY : window->ScrollbarX);
    float other_scrollbar_size_w = other_scrollbar ? style.ScrollbarSize : 0.0f;
    const ImRect window_rect = window->Rect();
    ImRect bb = horizontal
        ? ImRect(window->Pos.x + 1, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - 1 - other_scrollbar_size_w, window_rect.Max.y)
        : ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + window->TitleBarHeight()+1, window_rect.Max.x, window_rect.Max.y - 1 - other_scrollbar_size_w);
    window->DrawList->AddRectFilled(bb.Min, bb.Max, window->Color(ImGuiCol_ScrollbarBg));
    bb.Expand(-3.0f);

    // V denote the main axis of the scrollbar
    float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
    float scroll_v = horizontal ? window->Scroll.x : window->Scroll.y;
    float win_size_avail_v = (horizontal ? window->Size.x : window->Size.y) - other_scrollbar_size_w;
    float win_size_contents_v = horizontal ? window->SizeContents.x : window->SizeContents.y;

    // The grabable box size 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.
    const float grab_h_pixels = ImMin(ImMax(scrollbar_size_v * ImSaturate(win_size_avail_v / ImMax(win_size_contents_v, win_size_avail_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;
    const bool previously_held = (g.ActiveId == id);
    ImGui::ButtonBehavior(bb, id, &hovered, &held, true);

    float scroll_max = ImMax(1.0f, win_size_contents_v - win_size_avail_v);
    float scroll_ratio = ImSaturate(scroll_v / scroll_max);
    float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;
    if (held && grab_h_norm < 1.0f)
    {
        float scrollbar_pos_v = horizontal ? bb.Min.x : bb.Min.y;
        float mouse_pos_v = horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
        float* click_delta_to_grab_center_v = horizontal ? &g.ScrollbarClickDeltaToGrabCenter.x : &g.ScrollbarClickDeltaToGrabCenter.y;

        // 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);
        g.HoveredId = id;

        bool seek_absolute = false;
        if (!previously_held)
        {
            // On initial click calculate the distance between mouse and the center of the grab
            if (clicked_v_norm >= grab_v_norm && clicked_v_norm <= grab_v_norm + grab_h_norm)
            {
                *click_delta_to_grab_center_v = clicked_v_norm - grab_v_norm - grab_h_norm*0.5f;
            }
            else
            {
                seek_absolute = true;
                *click_delta_to_grab_center_v = 0.0f;
            }
        }

        // Apply scroll
        // It is ok to modify Scroll here because we are being called in Begin() after the calculation of SizeContents and before setting up our starting position
        const float scroll_v_norm = ImSaturate((clicked_v_norm - *click_delta_to_grab_center_v - grab_h_norm*0.5f) / (1.0f - grab_h_norm));
        scroll_v = (float)(int)(0.5f + scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v));
        if (horizontal)
            window->Scroll.x = scroll_v;
        else
            window->Scroll.y = scroll_v;

        // Update values for rendering
        scroll_ratio = ImSaturate(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)
            *click_delta_to_grab_center_v = clicked_v_norm - grab_v_norm - grab_h_norm*0.5f;
    }

    // Render
    const ImU32 grab_col = window->Color(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab);
    if (horizontal)
        window->DrawList->AddRectFilled(ImVec2(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y), ImVec2(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y), grab_col, style.ScrollbarRounding);
    else
        window->DrawList->AddRectFilled(ImVec2(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm)), ImVec2(bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels), grab_col, style.ScrollbarRounding);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq 0x41825(%rip), %r15     # 0x55480
leaq 0x2b11a(%rip), %rax     # 0x3ed7c
leaq 0x2a8cc(%rip), %rsi     # 0x3e535
testl %ebx, %ebx
cmovneq %rax, %rsi
xorl %edx, %edx
callq 0xa766
movl %ebx, %ecx
xorps %xmm5, %xmm5
cmpb $0x1, 0x64(%r14,%rcx)
jne 0x13c8c
movss 0x1438(%r15), %xmm5
movss 0x18(%r14), %xmm3
movss 0x1c(%r14), %xmm2
movss 0x20(%r14), %xmm0
addss %xmm3, %xmm0
movss 0x24(%r14), %xmm1
addss %xmm2, %xmm1
testb %bl, %bl
movq %r15, -0xb0(%rbp)
movl %eax, -0x3c(%rbp)
movss %xmm5, -0x70(%rbp)
je 0x13cee
addss 0x296c9(%rip), %xmm3    # 0x3d390
leaq 0x20(%r14), %rax
movq %rax, -0x38(%rbp)
movaps %xmm1, %xmm2
subss 0x1438(%r15), %xmm2
addss 0x296b9(%rip), %xmm0    # 0x3d39c
subss %xmm5, %xmm0
movl $0x30, %eax
jmp 0x13d51
xorps %xmm4, %xmm4
testb $0x1, 0xc(%r14)
jne 0x13d20
movq 0x41781(%rip), %rcx     # 0x55480
movss 0x171c(%rcx), %xmm3
mulss 0x268(%r14), %xmm3
movss 0x140c(%rcx), %xmm4
addss %xmm4, %xmm4
addss %xmm3, %xmm4
movaps %xmm0, %xmm3
subss 0x1438(%r15), %xmm3
leaq 0x24(%r14), %rax
movq %rax, -0x38(%rbp)
addss %xmm4, %xmm2
addss 0x29650(%rip), %xmm2    # 0x3d390
addss 0x29654(%rip), %xmm1    # 0x3d39c
subss %xmm5, %xmm1
movl $0x34, %eax
movq %rax, -0x90(%rbp)
leaq -0x44(%rbp), %r13
movss %xmm3, -0x8(%r13)
movss %xmm2, -0x4(%r13)
movss %xmm0, (%r13)
movss %xmm1, 0x4(%r13)
movq 0x270(%r14), %r15
movq 0x416fe(%rip), %rax     # 0x55480
movups 0x1530(%rax), %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movss 0x13e8(%rax), %xmm0
mulss 0xc(%rdi), %xmm0
movss %xmm0, 0xc(%rdi)
callq 0x8c82
leaq -0x4c(%rbp), %r12
xorps %xmm0, %xmm0
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movl %eax, %ecx
movl $0xf, %r8d
callq 0x2f984
movss 0x29621(%rip), %xmm0    # 0x3d3f0
movss (%r12), %xmm1
addss %xmm0, %xmm1
movss %xmm1, (%r12)
addss 0x4(%r12), %xmm0
movss %xmm0, 0x4(%r12)
movss 0x2962f(%rip), %xmm2    # 0x3d424
movss 0x8(%r12), %xmm3
addss %xmm2, %xmm3
movss %xmm3, 0x8(%r12)
addss 0xc(%r12), %xmm2
movss %xmm2, 0xc(%r12)
movl %ebx, %ecx
testb %cl, %cl
jne 0x13e24
subss %xmm0, %xmm2
movaps %xmm2, %xmm3
jmp 0x13e28
subss %xmm1, %xmm3
movl -0x3c(%rbp), %ebx
movss -0x70(%rbp), %xmm0
movss %xmm3, -0x54(%rbp)
movl %ecx, %eax
xorb $0x1, %al
movzbl %al, %eax
movq %rax, -0xa8(%rbp)
movss 0x4c(%r14,%rax,4), %xmm1
movaps %xmm1, -0x80(%rbp)
movq -0x38(%rbp), %rax
movss (%rax), %xmm2
subss %xmm0, %xmm2
movaps %xmm2, -0xe0(%rbp)
movq -0x90(%rbp), %rax
movss (%r14,%rax), %xmm4
movaps %xmm4, -0x90(%rbp)
movaps %xmm2, %xmm0
cmpless %xmm4, %xmm0
movaps %xmm0, %xmm1
andps %xmm4, %xmm1
andnps %xmm2, %xmm0
orps %xmm1, %xmm0
movaps %xmm2, %xmm1
divss %xmm0, %xmm1
movss 0x294f8(%rip), %xmm0    # 0x3d390
minss %xmm1, %xmm0
xorps %xmm2, %xmm2
cmpltss %xmm2, %xmm1
andnps %xmm0, %xmm1
mulss %xmm3, %xmm1
movq -0xb0(%rbp), %r15
movss 0x1440(%r15), %xmm0
movaps %xmm0, %xmm2
cmpless %xmm1, %xmm2
andps %xmm2, %xmm1
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
minss %xmm3, %xmm2
movaps %xmm2, -0x70(%rbp)
divss %xmm3, %xmm2
movaps %xmm2, -0xd0(%rbp)
xorl %eax, %eax
movl %ecx, -0x38(%rbp)
leaq -0x2a(%rbp), %r13
movb %al, (%r13)
leaq -0x29(%rbp), %rdx
movb %al, (%rdx)
movl 0x1790(%r15), %eax
movl %eax, -0x50(%rbp)
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x13a49
movaps -0xd0(%rbp), %xmm9
movss 0x2946d(%rip), %xmm8    # 0x3d390
movaps -0x80(%rbp), %xmm5
movss -0x54(%rbp), %xmm7
movaps -0x90(%rbp), %xmm1
subss -0xe0(%rbp), %xmm1
movaps %xmm8, %xmm0
maxss %xmm1, %xmm0
divss %xmm0, %xmm5
movaps %xmm8, %xmm1
minss %xmm5, %xmm1
cmpltss 0x29480(%rip), %xmm5    # 0x3d3d8
andnps %xmm1, %xmm5
movaps %xmm7, %xmm1
subss -0x70(%rbp), %xmm1
mulss %xmm1, %xmm5
movb (%r13), %al
movl %eax, %ecx
xorb $0x1, %cl
ucomiss %xmm9, %xmm8
divss %xmm7, %xmm5
setbe %dl
orb %cl, %dl
jne 0x13fe2
leaq -0x48(%rbp), %rdx
movl -0x38(%rbp), %r8d
testb %r8b, %r8b
cmovneq %r12, %rdx
movq -0xa8(%rbp), %rdi
leal (,%rdi,4), %esi
leaq 0x27d8(%rsi), %rcx
movss 0xf0(%r15,%rsi), %xmm2
subss (%rdx), %xmm2
divss %xmm7, %xmm2
movaps %xmm8, %xmm3
minss %xmm2, %xmm3
xorps %xmm4, %xmm4
cmpltss %xmm4, %xmm2
andnps %xmm3, %xmm2
movl %ebx, 0x1788(%r15)
cmpl %ebx, -0x50(%rbp)
movl %r8d, %ebx
movq %rdi, %rsi
jne 0x13fee
movss (%r15,%rcx), %xmm3
jmp 0x1401e
movaps %xmm5, -0x80(%rbp)
movl -0x38(%rbp), %ebx
jmp 0x140c2
ucomiss %xmm5, %xmm2
jb 0x14022
movaps %xmm9, %xmm3
addss %xmm5, %xmm3
ucomiss %xmm2, %xmm3
jb 0x14022
movaps %xmm2, %xmm4
subss %xmm5, %xmm4
movss 0x293d1(%rip), %xmm3    # 0x3d3e0
mulss %xmm9, %xmm3
addss %xmm4, %xmm3
movss %xmm3, (%r15,%rcx)
xorl %edx, %edx
jmp 0x1402f
movl $0x0, (%r15,%rcx)
movb $0x1, %dl
xorps %xmm3, %xmm3
movaps %xmm2, %xmm4
subss %xmm3, %xmm4
movss 0x2938e(%rip), %xmm3    # 0x3d3cc
movaps %xmm9, %xmm5
mulss %xmm3, %xmm5
subss %xmm5, %xmm4
movaps %xmm8, %xmm5
subss %xmm9, %xmm5
divss %xmm5, %xmm4
movaps %xmm8, %xmm5
minss %xmm4, %xmm5
xorps %xmm6, %xmm6
cmpltss %xmm6, %xmm4
andnps %xmm5, %xmm4
mulss %xmm0, %xmm4
addss %xmm3, %xmm4
cvttps2dq %xmm4, %xmm3
cvtdq2ps %xmm3, %xmm3
movss %xmm3, 0x4c(%r14,%rsi,4)
divss %xmm0, %xmm3
minss %xmm3, %xmm8
cmpltss %xmm6, %xmm3
andnps %xmm8, %xmm3
mulss %xmm3, %xmm1
divss %xmm7, %xmm1
testb %dl, %dl
movaps %xmm1, -0x80(%rbp)
je 0x140c2
xorps 0x29286(%rip), %xmm9    # 0x3d330
subss %xmm1, %xmm2
mulss 0x29315(%rip), %xmm9    # 0x3d3cc
addss %xmm2, %xmm9
movss %xmm9, (%r15,%rcx)
movzbl -0x29(%rbp), %ecx
movq 0x413b3(%rip), %rdx     # 0x55480
andl $0x1, %ecx
orl $0xe, %ecx
testb %al, %al
movl $0x10, %eax
cmovel %ecx, %eax
shll $0x4, %eax
movups 0x1460(%rdx,%rax), %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movss 0x13e8(%rdx), %xmm0
mulss 0xc(%rdi), %xmm0
movss %xmm0, 0xc(%rdi)
callq 0x8c82
movq 0x270(%r14), %rdi
testb %bl, %bl
je 0x1415f
movss -0x44(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
movss -0x48(%rbp), %xmm2
subss %xmm1, %xmm0
mulss -0x80(%rbp), %xmm0
addss %xmm1, %xmm0
leaq -0xa0(%rbp), %rsi
movss %xmm0, (%rsi)
movss %xmm2, 0x4(%rsi)
movaps -0x70(%rbp), %xmm1
addss %xmm0, %xmm1
movss -0x40(%rbp), %xmm0
leaq -0xb8(%rbp), %rdx
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
jmp 0x141a8
movss -0x4c(%rbp), %xmm0
movss -0x48(%rbp), %xmm1
movss -0x40(%rbp), %xmm2
subss %xmm1, %xmm2
mulss -0x80(%rbp), %xmm2
addss %xmm1, %xmm2
leaq -0xa0(%rbp), %rsi
movss %xmm0, (%rsi)
movss %xmm2, 0x4(%rsi)
movss -0x44(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
addss %xmm2, %xmm1
leaq -0xb8(%rbp), %rdx
movss %xmm0, (%rdx)
movss %xmm1, 0x4(%rdx)
movss 0x143c(%r15), %xmm0
movl %eax, %ecx
movl $0xf, %r8d
callq 0x2f984
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq