// File: /workspace/github_cpp_makefile_star2_O1/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 0x63278(%rip), %xmm0    # 0xb7840
ucomiss %xmm1, %xmm0
jbe 0x5462c
movss 0x74(%rbx), %xmm2
movss 0x7c(%rbx), %xmm3
xorps %xmm4, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x54613
ucomiss %xmm1, %xmm3
jae 0x54608
movss 0x64(%rbx), %xmm4
addss 0x18(%rbx), %xmm4
movaps %xmm4, %xmm5
subss %xmm3, %xmm5
ucomiss %xmm5, %xmm1
jb 0x54613
subss %xmm1, %xmm4
mulss %xmm2, %xmm4
addss %xmm4, %xmm1
jmp 0x54613
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 0x5470c
movaps %xmm6, -0x20(%rbp)
testb $0x1, 0xc(%rbx)
xorps %xmm1, %xmm1
jne 0x5467e
movq 0xa9686(%rip), %rax     # 0xfdcd0
movss 0x1984(%rax), %xmm0
mulss 0x2b0(%rbx), %xmm0
movq 0x388(%rbx), %rcx
testq %rcx, %rcx
je 0x5466e
mulss 0x2b0(%rcx), %xmm0
movss 0x159c(%rax), %xmm1
addss %xmm1, %xmm1
addss %xmm0, %xmm1
movss %xmm1, -0xc(%rbp)
movq %rbx, %rdi
callq 0x5f48e
addss -0xc(%rbp), %xmm0
movss 0x70(%rbx), %xmm1
movss 0x78(%rbx), %xmm2
movss 0x80(%rbx), %xmm4
ucomiss 0x6319b(%rip), %xmm4    # 0xb7844
jbe 0x546d8
ucomiss %xmm1, %xmm4
movaps -0x20(%rbp), %xmm6
jae 0x546de
movss 0x68(%rbx), %xmm3
addss 0x1c(%rbx), %xmm3
subss %xmm0, %xmm3
movaps %xmm3, %xmm5
subss %xmm4, %xmm5
ucomiss %xmm5, %xmm1
jb 0x546e9
subss %xmm1, %xmm3
mulss %xmm2, %xmm3
jmp 0x546e5
movaps -0x20(%rbp), %xmm6
jmp 0x546e9
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 0x5475c
cmpb $0x0, 0x93(%rbx)
jne 0x5475c
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