// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x9fbdb(%rip), %r15     # 0xe3ce0
movss 0x57ee3(%rip), %xmm0    # 0x9bff0
movss 0x218(%rdi), %xmm1
addss %xmm0, %xmm1
addss 0x21c(%rdi), %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movss 0x57ecc(%rip), %xmm3    # 0x9bff8
movss 0x220(%rdi), %xmm0
addss %xmm3, %xmm0
movss 0x224(%rdi), %xmm2
addss %xmm3, %xmm2
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
leaq -0x28(%rbp), %rdi
movups %xmm1, (%rdi)
callq 0x49f2c
xorps %xmm2, %xmm2
testb %al, %al
jne 0x4423c
cmpb $0x1, 0x8c(%r14)
jne 0x441cd
movss (%rbx), %xmm0
movss -0x28(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x4418d
subss 0x10(%r14), %xmm0
subss 0x15a8(%r15), %xmm0
xorps %xmm1, %xmm1
jmp 0x441af
movss 0x8(%rbx), %xmm0
ucomiss -0x20(%rbp), %xmm0
jb 0x441cd
subss 0x10(%r14), %xmm0
addss 0x15a8(%r15), %xmm0
movss 0x57e49(%rip), %xmm1    # 0x9bff8
addss 0x5c(%r14), %xmm0
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
movss %xmm0, 0x6c(%r14)
movss %xmm1, 0x74(%r14)
andl $0x0, 0x7c(%r14)
movss 0x4(%rbx), %xmm0
movss -0x24(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x441f0
subss 0x14(%r14), %xmm0
subss 0x15ac(%r15), %xmm0
xorps %xmm1, %xmm1
jmp 0x44212
movss 0xc(%rbx), %xmm0
ucomiss -0x1c(%rbp), %xmm0
jb 0x4421a
subss 0x14(%r14), %xmm0
addss 0x15ac(%r15), %xmm0
movss 0x57de6(%rip), %xmm1    # 0x9bff8
movq %r14, %rdi
callq 0x442f7
movq %r14, %rdi
callq 0x41d70
movss 0x5c(%r14), %xmm1
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
subss 0x60(%r14), %xmm0
unpcklps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
testb $0x1, 0xf(%r14)
je 0x44296
movq 0x388(%r14), %rdi
movss (%rbx), %xmm0
movss 0x4(%rbx), %xmm1
subss %xmm2, %xmm0
movaps %xmm2, -0x40(%rbp)
movaps -0x40(%rbp), %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
subss %xmm2, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x8(%rbx), %xmm1
subss -0x40(%rbp), %xmm1
movss 0xc(%rbx), %xmm3
subss %xmm2, %xmm3
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
leaq -0x50(%rbp), %rsi
movups %xmm0, (%rsi)
callq 0x440eb
movaps -0x40(%rbp), %xmm2
addps %xmm0, %xmm2
movaps %xmm2, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq