// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: CalcWindowSizeAfterConstraint(ImGuiWindow*, ImVec2)
static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
{
    ImGuiContext& g = *GImGui;
    if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)
    {
        // Using -1,-1 on either X/Y axis to preserve the current size.
        ImRect cr = g.NextWindowData.SizeConstraintRect;
        new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x;
        new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y;
        if (g.NextWindowData.SizeCallback)
        {
            ImGuiSizeCallbackData data;
            data.UserData = g.NextWindowData.SizeCallbackUserData;
            data.Pos = window->Pos;
            data.CurrentSize = window->SizeFull;
            data.DesiredSize = new_size;
            g.NextWindowData.SizeCallback(&data);
            new_size = data.DesiredSize;
        }
        new_size.x = IM_FLOOR(new_size.x);
        new_size.y = IM_FLOOR(new_size.y);
    }

    // Minimum size
    if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
    {
        ImGuiWindow* window_for_height = window;
        new_size = ImMax(new_size, g.Style.WindowMinSize);
        new_size.y = ImMax(new_size.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
    }
    return new_size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movlpd %xmm0, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq 0x13c465(%rip), %rax    # 0x212f40
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x1b88(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xd6c21
movq -0x20(%rbp), %rax
movq 0x1bc4(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x1bcc(%rax), %rax
movq %rax, -0x28(%rbp)
movss -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xd6b44
movss -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xd6b44
movss -0x10(%rbp), %xmm0
movss -0x30(%rbp), %xmm1
movss -0x28(%rbp), %xmm2
callq 0xe5390
movss %xmm0, -0x64(%rbp)
jmp 0xd6b52
movq -0x18(%rbp), %rax
movss 0x20(%rax), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x64(%rbp), %xmm0
movss %xmm0, -0x10(%rbp)
movss -0x2c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xd6b91
movss -0x24(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xd6b91
movss -0xc(%rbp), %xmm0
movss -0x2c(%rbp), %xmm1
movss -0x24(%rbp), %xmm2
callq 0xe5390
movss %xmm0, -0x68(%rbp)
jmp 0xd6b9f
movq -0x18(%rbp), %rax
movss 0x24(%rax), %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x68(%rbp), %xmm0
movss %xmm0, -0xc(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x1bd8(%rax)
je 0xd6c05
leaq -0x50(%rbp), %rdi
callq 0xee180
movq -0x20(%rbp), %rax
movq 0x1be0(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
leaq -0x50(%rbp), %rdi
callq *0x1bd8(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x10(%rbp)
cvttss2si -0x10(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x10(%rbp)
cvttss2si -0xc(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0xc(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1000040, %eax        # imm = 0x1000040
cmpl $0x0, %eax
jne 0xd6ccc
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rsi
addq $0x1574, %rsi           # imm = 0x1574
leaq -0x10(%rbp), %rdi
callq 0xd7960
movlpd %xmm0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x10(%rbp)
movss -0xc(%rbp), %xmm0
movss %xmm0, -0x6c(%rbp)
movq -0x58(%rbp), %rdi
callq 0xeb6f0
movss %xmm0, -0x74(%rbp)
movq -0x58(%rbp), %rdi
callq 0xeb760
movaps %xmm0, %xmm1
movss -0x74(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movq -0x20(%rbp), %rax
movss 0x156c(%rax), %xmm1
movss 0x99f97(%rip), %xmm0    # 0x170c3c
subss %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0xc88c0
movss -0x70(%rbp), %xmm1
movaps %xmm0, %xmm2
movss -0x6c(%rbp), %xmm0
addss %xmm2, %xmm1
callq 0xc88c0
movss %xmm0, -0xc(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)