// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::ScrollToBringRectIntoView(ImGuiWindow*, ImRect const&)
ImVec2 ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect)
{
    ImGuiContext& g = *GImGui;
    ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1));
    //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]

    ImVec2 delta_scroll;
    if (!window_rect.Contains(item_rect))
    {
        if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
            SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x - g.Style.ItemSpacing.x, 0.0f);
        else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
            SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f);
        if (item_rect.Min.y < window_rect.Min.y)
            SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f);
        else if (item_rect.Max.y >= window_rect.Max.y)
            SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f);

        ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window);
        delta_scroll = next_scroll - window->Scroll;
    }

    // Also scroll parent window to keep us into view if necessary
    if (window->Flags & ImGuiWindowFlags_ChildWindow)
        delta_scroll += ScrollToBringRectIntoView(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll));

    return delta_scroll;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movss 0x5e9a4(%rip), %xmm1    # 0xb4fd0
movss 0x218(%rdi), %xmm6
addss %xmm1, %xmm6
addss 0x21c(%rdi), %xmm1
movq 0xa5689(%rip), %rax     # 0xfbcd0
movss 0x5e995(%rip), %xmm4    # 0xb4fe4
movss 0x220(%rdi), %xmm7
addss %xmm4, %xmm7
movss 0x224(%rdi), %xmm3
addss %xmm4, %xmm3
movss (%rsi), %xmm5
movss 0x4(%rsi), %xmm0
ucomiss %xmm6, %xmm5
movss 0x8(%rsi), %xmm8
movss 0xc(%rsi), %xmm2
jb 0x56698
ucomiss %xmm1, %xmm0
jb 0x56698
ucomiss %xmm8, %xmm7
jb 0x56698
xorps %xmm9, %xmm9
ucomiss %xmm2, %xmm3
jae 0x5675a
cmpb $0x1, 0x8c(%r14)
jne 0x566f4
ucomiss %xmm5, %xmm6
jbe 0x566ba
subss 0x10(%r14), %xmm5
subss 0x15a8(%rax), %xmm5
xorps %xmm4, %xmm4
jmp 0x566d3
ucomiss %xmm7, %xmm8
jb 0x566f4
subss 0x10(%r14), %xmm8
addss 0x15a8(%rax), %xmm8
movaps %xmm8, %xmm5
addss 0x5c(%r14), %xmm5
cvttps2dq %xmm5, %xmm5
cvtdq2ps %xmm5, %xmm5
movss %xmm5, 0x6c(%r14)
movss %xmm4, 0x74(%r14)
movl $0x0, 0x7c(%r14)
ucomiss %xmm0, %xmm1
jbe 0x5670f
subss 0x14(%r14), %xmm0
subss 0x15ac(%rax), %xmm0
xorps %xmm1, %xmm1
movq %r14, %rdi
jmp 0x56730
ucomiss %xmm3, %xmm2
jb 0x56735
subss 0x14(%r14), %xmm2
addss 0x15ac(%rax), %xmm2
movss 0x5e8ba(%rip), %xmm1    # 0xb4fe4
movq %r14, %rdi
movaps %xmm2, %xmm0
callq 0x5681c
movq %r14, %rdi
callq 0x5355d
movaps %xmm0, %xmm9
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movss 0x5c(%r14), %xmm1
subss %xmm1, %xmm9
subss 0x60(%r14), %xmm0
unpcklps %xmm0, %xmm9            # xmm9 = xmm9[0],xmm0[0],xmm9[1],xmm0[1]
testb $0x1, 0xf(%r14)
je 0x567b9
movq 0x388(%r14), %rdi
movss (%rbx), %xmm0
movss 0x4(%rbx), %xmm1
movaps %xmm9, %xmm2
shufps $0x55, %xmm9, %xmm2     # xmm2 = xmm2[1,1],xmm9[1,1]
subss %xmm9, %xmm0
subss %xmm2, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x8(%rbx), %xmm1
movss 0xc(%rbx), %xmm3
subss %xmm9, %xmm1
subss %xmm2, %xmm3
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
leaq -0x30(%rbp), %rsi
movups %xmm0, (%rsi)
movaps %xmm9, -0x20(%rbp)
callq 0x56613
movaps -0x20(%rbp), %xmm9
addps %xmm0, %xmm9
movaps %xmm9, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq