// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow*)
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
{
    ImVec2 scroll = window->Scroll;
    if (window->ScrollTarget.x < FLT_MAX)
    {
        float center_x_ratio = window->ScrollTargetCenterRatio.x;
        float scroll_target_x = window->ScrollTarget.x;
        float snap_x_min = 0.0f;
        float snap_x_max = window->ScrollMax.x + window->Size.x;
        if (window->ScrollTargetEdgeSnapDist.x > 0.0f)
            scroll_target_x = CalcScrollEdgeSnap(scroll_target_x, snap_x_min, snap_x_max, window->ScrollTargetEdgeSnapDist.x, center_x_ratio);
        scroll.x = scroll_target_x - center_x_ratio * (window->SizeFull.x - window->ScrollbarSizes.x);
    }
    if (window->ScrollTarget.y < FLT_MAX)
    {
        float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
        float center_y_ratio = window->ScrollTargetCenterRatio.y;
        float scroll_target_y = window->ScrollTarget.y;
        float snap_y_min = 0.0f;
        float snap_y_max = window->ScrollMax.y + window->Size.y - decoration_up_height;
        if (window->ScrollTargetEdgeSnapDist.y > 0.0f)
            scroll_target_y = CalcScrollEdgeSnap(scroll_target_y, snap_y_min, snap_y_max, window->ScrollTargetEdgeSnapDist.y, center_y_ratio);
        scroll.y = scroll_target_y - center_y_ratio * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height);
    }
    scroll.x = IM_FLOOR(ImMax(scroll.x, 0.0f));
    scroll.y = IM_FLOOR(ImMax(scroll.y, 0.0f));
    if (!window->Collapsed && !window->SkipItems)
    {
        scroll.x = ImMin(scroll.x, window->ScrollMax.x);
        scroll.y = ImMin(scroll.y, window->ScrollMax.y);
    }
    return scroll;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movsd 0x5c(%rdi), %xmm6
movss 0x6c(%rdi), %xmm1
movss 0x5aae2(%rip), %xmm0    # 0x9c870
ucomiss %xmm1, %xmm0
jbe 0x41df2
movss 0x74(%rbx), %xmm2
movss 0x7c(%rbx), %xmm3
xorps %xmm4, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x41dd9
ucomiss %xmm1, %xmm3
jae 0x41dce
movss 0x64(%rbx), %xmm4
addss 0x18(%rbx), %xmm4
movaps %xmm4, %xmm5
subss %xmm3, %xmm5
ucomiss %xmm5, %xmm1
jb 0x41dd9
subss %xmm1, %xmm4
mulss %xmm2, %xmm4
addss %xmm4, %xmm1
jmp 0x41dd9
mulss %xmm2, %xmm1
xorps %xmm3, %xmm3
addss %xmm3, %xmm1
movss 0x20(%rbx), %xmm3
subss 0x84(%rbx), %xmm3
mulss %xmm3, %xmm2
subss %xmm2, %xmm1
movss %xmm1, %xmm6            # xmm6 = xmm1[0],xmm6[1,2,3]
ucomiss 0x70(%rbx), %xmm0
jbe 0x41e99
movaps %xmm6, -0x20(%rbp)
movq %rbx, %rdi
callq 0x4b4aa
movss %xmm0, -0xc(%rbp)
movq %rbx, %rdi
callq 0x4b4de
addss -0xc(%rbp), %xmm0
movss 0x70(%rbx), %xmm1
movss 0x78(%rbx), %xmm2
movss 0x80(%rbx), %xmm3
xorps %xmm4, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x41e65
ucomiss %xmm1, %xmm3
movaps -0x20(%rbp), %xmm6
jae 0x41e6b
movss 0x68(%rbx), %xmm4
addss 0x1c(%rbx), %xmm4
subss %xmm0, %xmm4
movaps %xmm4, %xmm5
subss %xmm3, %xmm5
ucomiss %xmm5, %xmm1
jb 0x41e76
subss %xmm1, %xmm4
mulss %xmm2, %xmm4
addss %xmm4, %xmm1
jmp 0x41e76
movaps -0x20(%rbp), %xmm6
jmp 0x41e76
mulss %xmm2, %xmm1
xorps %xmm3, %xmm3
addss %xmm3, %xmm1
movss 0x24(%rbx), %xmm3
subss 0x88(%rbx), %xmm3
subss %xmm0, %xmm3
mulss %xmm3, %xmm2
subss %xmm2, %xmm1
movlhps %xmm6, %xmm1            # xmm1 = xmm1[0],xmm6[0]
shufps $0xe2, %xmm6, %xmm1     # xmm1 = xmm1[2,0],xmm6[2,3]
movaps %xmm1, %xmm6
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
cmpless %xmm6, %xmm1
andps %xmm6, %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
cmpless %xmm6, %xmm0
andps %xmm6, %xmm0
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm2
movaps %xmm1, %xmm0
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
cmpb $0x0, 0x91(%rbx)
jne 0x41ee9
cmpb $0x0, 0x93(%rbx)
jne 0x41ee9
minss 0x64(%rbx), %xmm1
minss 0x68(%rbx), %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movaps %xmm1, %xmm0
addq $0x18, %rsp
popq %rbx
popq %rbp
retq