// File: /workspace/github_cpp_makefile_star2_O2/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 $0xa8, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq 0x3fafa(%rip), %r15     # 0x50480
leaq 0x273dc(%rip), %rax     # 0x37d69
leaq 0x26b59(%rip), %rsi     # 0x374ed
testl %ebx, %ebx
cmovneq %rax, %rsi
xorl %edx, %edx
callq 0x9858
movl %eax, -0x70(%rbp)
movl %ebx, %eax
xorps %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
cmpb $0x1, 0x64(%r14,%rax)
jne 0x109c4
movss 0x1438(%r15), %xmm0
movss %xmm0, -0x60(%rbp)
movq %r14, %rdi
callq 0x1ee52
testb %bl, %bl
movq %r15, -0xc0(%rbp)
je 0x10a17
movss 0x18(%r14), %xmm3
addss 0x259ab(%rip), %xmm3    # 0x36390
movaps %xmm1, %xmm4
shufps $0x55, %xmm1, %xmm4     # xmm4 = xmm4[1,1],xmm1[1,1]
movaps %xmm4, %xmm0
subss 0x1438(%r15), %xmm0
movss 0x2599c(%rip), %xmm2    # 0x3639c
addss %xmm1, %xmm2
subss -0x60(%rbp), %xmm2
pushq $0x20
popq %rax
movq %rax, -0x90(%rbp)
pushq $0x30
jmp 0x10a85
movss 0x1438(%r15), %xmm0
movaps %xmm1, %xmm2
subss %xmm0, %xmm2
movss %xmm2, -0xa0(%rbp)
movss 0x1c(%r14), %xmm0
movss %xmm0, -0x30(%rbp)
movq %r14, %rdi
movaps %xmm1, -0xb0(%rbp)
callq 0x1ede2
movss -0xa0(%rbp), %xmm3
addss -0x30(%rbp), %xmm0
addss 0x25932(%rip), %xmm0    # 0x36390
movaps -0xb0(%rbp), %xmm2
movaps %xmm2, %xmm4
shufps $0x55, %xmm2, %xmm4     # xmm4 = xmm4[1,1],xmm2[1,1]
addss 0x25928(%rip), %xmm4    # 0x3639c
subss -0x60(%rbp), %xmm4
pushq $0x24
popq %rax
movq %rax, -0x90(%rbp)
pushq $0x34
popq %rax
movq %rax, -0x40(%rbp)
leaq -0x48(%rbp), %r13
movss %xmm3, -0x8(%r13)
movss %xmm0, -0x4(%r13)
movss %xmm2, (%r13)
movss %xmm4, 0x4(%r13)
movq 0x270(%r14), %r15
pushq $0xd
popq %rsi
movss 0x258d8(%rip), %xmm0    # 0x36390
movq %r14, %rdi
callq 0x1eae4
leaq -0x50(%rbp), %r12
pushq $0xf
popq %r8
xorps %xmm0, %xmm0
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movl %eax, %ecx
callq 0x29a42
movss 0x2590d(%rip), %xmm0    # 0x363f0
movss (%r12), %xmm1
addss %xmm0, %xmm1
movss %xmm1, (%r12)
addss 0x4(%r12), %xmm0
movss %xmm0, 0x4(%r12)
movss 0x2591b(%rip), %xmm2    # 0x36424
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 0x10b38
subss %xmm0, %xmm2
movaps %xmm2, %xmm3
jmp 0x10b3c
subss %xmm1, %xmm3
movl -0x70(%rbp), %ebx
movss %xmm3, -0x30(%rbp)
movl %ecx, %eax
xorb $0x1, %al
movzbl %al, %eax
movq %rax, -0xb8(%rbp)
movss 0x4c(%r14,%rax,4), %xmm0
movaps %xmm0, -0x70(%rbp)
movq -0x90(%rbp), %rax
movss (%r14,%rax), %xmm2
subss -0x60(%rbp), %xmm2
movaps %xmm2, -0xb0(%rbp)
movq -0x40(%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 0x257e6(%rip), %xmm0    # 0x36390
minss %xmm1, %xmm0
xorps %xmm2, %xmm2
cmpltss %xmm2, %xmm1
andnps %xmm0, %xmm1
mulss %xmm3, %xmm1
movq -0xc0(%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, -0x60(%rbp)
divss %xmm3, %xmm2
movaps %xmm2, -0xa0(%rbp)
xorl %eax, %eax
movl %ecx, -0x40(%rbp)
leaq -0x31(%rbp), %r13
movb %al, (%r13)
leaq -0x29(%rbp), %rdx
movb %al, (%rdx)
movl 0x1790(%r15), %eax
movl %eax, -0x74(%rbp)
pushq $0x1
popq %r8
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rcx
xorl %r9d, %r9d
callq 0x1077a
movaps -0xa0(%rbp), %xmm9
movaps -0x70(%rbp), %xmm5
movss -0x30(%rbp), %xmm8
movss 0x25754(%rip), %xmm7    # 0x36390
movaps -0x90(%rbp), %xmm1
subss -0xb0(%rbp), %xmm1
movaps %xmm7, %xmm0
maxss %xmm1, %xmm0
divss %xmm0, %xmm5
movaps %xmm7, %xmm1
minss %xmm5, %xmm1
cmpltss 0x2574a(%rip), %xmm5    # 0x363b0
andnps %xmm1, %xmm5
movaps %xmm8, %xmm1
subss -0x60(%rbp), %xmm1
mulss %xmm1, %xmm5
movb (%r13), %al
movl %eax, %ecx
xorb $0x1, %cl
ucomiss %xmm9, %xmm7
divss %xmm8, %xmm5
setbe %dl
orb %cl, %dl
jne 0x10cf2
leaq -0x4c(%rbp), %rdx
movl -0x40(%rbp), %r8d
testb %r8b, %r8b
cmovneq %r12, %rdx
movq -0xb8(%rbp), %rdi
leal (,%rdi,4), %esi
leaq 0x27d8(%rsi), %rcx
movss 0xf0(%r15,%rsi), %xmm2
subss (%rdx), %xmm2
divss %xmm8, %xmm2
movaps %xmm7, %xmm3
minss %xmm2, %xmm3
xorps %xmm4, %xmm4
cmpltss %xmm4, %xmm2
andnps %xmm3, %xmm2
movl %ebx, 0x1788(%r15)
cmpl %ebx, -0x74(%rbp)
movl %r8d, %ebx
movq %rdi, %rsi
jne 0x10cfe
movss (%r15,%rcx), %xmm3
jmp 0x10d2e
movaps %xmm5, -0x70(%rbp)
movl -0x40(%rbp), %ebx
jmp 0x10dcc
ucomiss %xmm5, %xmm2
jb 0x10d32
movaps %xmm9, %xmm3
addss %xmm5, %xmm3
ucomiss %xmm2, %xmm3
jb 0x10d32
movaps %xmm2, %xmm4
subss %xmm5, %xmm4
movss 0x256c1(%rip), %xmm3    # 0x363e0
mulss %xmm9, %xmm3
addss %xmm4, %xmm3
movss %xmm3, (%r15,%rcx)
xorl %edx, %edx
jmp 0x10d3c
andl $0x0, (%r15,%rcx)
movb $0x1, %dl
xorps %xmm3, %xmm3
movaps %xmm2, %xmm4
subss %xmm3, %xmm4
movss 0x25685(%rip), %xmm3    # 0x363d0
movaps %xmm9, %xmm5
mulss %xmm3, %xmm5
subss %xmm5, %xmm4
movaps %xmm7, %xmm5
subss %xmm9, %xmm5
divss %xmm5, %xmm4
movaps %xmm7, %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, %xmm7
cmpltss %xmm6, %xmm3
andnps %xmm7, %xmm3
mulss %xmm3, %xmm1
divss %xmm8, %xmm1
testb %dl, %dl
movaps %xmm1, -0x70(%rbp)
je 0x10dcc
xorps 0x2557c(%rip), %xmm9    # 0x36330
subss %xmm1, %xmm2
mulss 0x2560f(%rip), %xmm9    # 0x363d0
addss %xmm2, %xmm9
movss %xmm9, (%r15,%rcx)
movzbl -0x29(%rbp), %ecx
andl $0x1, %ecx
orl $0xe, %ecx
testb %al, %al
pushq $0x10
popq %rsi
cmovel %ecx, %esi
movss 0x255aa(%rip), %xmm0    # 0x36390
movq %r14, %rdi
callq 0x1eae4
movq 0x270(%r14), %rdi
testb %bl, %bl
je 0x10e44
movss -0x48(%rbp), %xmm0
movss -0x50(%rbp), %xmm1
movss -0x4c(%rbp), %xmm2
subss %xmm1, %xmm0
mulss -0x70(%rbp), %xmm0
addss %xmm1, %xmm0
leaq -0xd0(%rbp), %rsi
movss %xmm0, (%rsi)
movss %xmm2, 0x4(%rsi)
movaps -0x60(%rbp), %xmm1
addss %xmm0, %xmm1
movss -0x44(%rbp), %xmm0
leaq -0xc8(%rbp), %rdx
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
jmp 0x10e8d
movss -0x50(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
movss -0x44(%rbp), %xmm2
subss %xmm1, %xmm2
mulss -0x70(%rbp), %xmm2
addss %xmm1, %xmm2
leaq -0xd0(%rbp), %rsi
movss %xmm0, (%rsi)
movss %xmm2, 0x4(%rsi)
movss -0x48(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
addss %xmm2, %xmm1
leaq -0xc8(%rbp), %rdx
movss %xmm0, (%rdx)
movss %xmm1, 0x4(%rdx)
movss 0x143c(%r15), %xmm0
pushq $0xf
popq %r8
movl %eax, %ecx
callq 0x29a42
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq