// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: CalcWindowAutoFitSize(ImGuiWindow*, ImVec2 const&)
static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_contents)
{
    ImGuiContext& g = *GImGui;
    ImGuiStyle& style = g.Style;
    ImVec2 size_decorations = ImVec2(0.0f, window->TitleBarHeight() + window->MenuBarHeight());
    ImVec2 size_pad = window->WindowPadding * 2.0f;
    ImVec2 size_desired = size_contents + size_pad + size_decorations;
    if (window->Flags & ImGuiWindowFlags_Tooltip)
    {
        // Tooltip always resize
        return size_desired;
    }
    else
    {
        // Maximum window size is determined by the viewport size or monitor size
        const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0;
        const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0;
        ImVec2 size_min = style.WindowMinSize;
        if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
            size_min = ImMin(size_min, ImVec2(4.0f, 4.0f));
        ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f));

        // When the window cannot fit all contents (either because of constraints, either because screen is too small),
        // we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding.
        ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit);
        bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - size_decorations.x < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar);
        bool will_have_scrollbar_y = (size_auto_fit_after_constraint.y - size_pad.y - size_decorations.y < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysVerticalScrollbar);
        if (will_have_scrollbar_x)
            size_auto_fit.y += style.ScrollbarSize;
        if (will_have_scrollbar_y)
            size_auto_fit.x += style.ScrollbarSize;
        return size_auto_fit;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0xa9200(%rip), %r15     # 0xfbcd0
testb $0x1, 0xc(%rdi)
xorps %xmm1, %xmm1
jne 0x52b10
movss 0x1984(%r15), %xmm0
mulss 0x2b0(%r14), %xmm0
movq 0x388(%r14), %rax
testq %rax, %rax
je 0x52aff
mulss 0x2b0(%rax), %xmm0
movss 0x159c(%r15), %xmm1
addss %xmm1, %xmm1
addss %xmm0, %xmm1
movaps %xmm1, -0x40(%rbp)
movq %r14, %rdi
callq 0x5e2b4
movaps %xmm0, %xmm1
addss -0x40(%rbp), %xmm1
movss 0x40(%r14), %xmm3
movss 0x44(%r14), %xmm2
addss %xmm3, %xmm3
addss %xmm2, %xmm2
movss (%rbx), %xmm0
addss %xmm3, %xmm0
movss 0x4(%rbx), %xmm7
addss %xmm2, %xmm7
xorps %xmm8, %xmm8
addss %xmm0, %xmm8
addss %xmm1, %xmm7
movl 0xc(%r14), %eax
btl $0x19, %eax
jb 0x52cda
movss %xmm2, -0x20(%rbp)
movss %xmm1, -0x24(%rbp)
movsd 0x1574(%r15), %xmm6
testl $0x14000000, %eax       # imm = 0x14000000
movss %xmm3, -0x1c(%rbp)
je 0x52b9d
movaps %xmm6, %xmm1
shufps $0x55, %xmm6, %xmm1     # xmm1 = xmm1[1,1],xmm6[1,1]
movss 0x62cd2(%rip), %xmm2    # 0xb5864
minss %xmm2, %xmm6
minss %xmm2, %xmm1
unpcklps %xmm1, %xmm6            # xmm6 = xmm6[0],xmm1[0],xmm6[1],xmm1[1]
movss 0x160c(%r15), %xmm1
movss 0x1610(%r15), %xmm2
addss %xmm1, %xmm1
addss %xmm2, %xmm2
movss 0x10(%r15), %xmm3
movss 0x14(%r15), %xmm4
subss %xmm1, %xmm3
subss %xmm2, %xmm4
movaps %xmm6, %xmm1
shufps $0x55, %xmm6, %xmm1     # xmm1 = xmm1[1,1],xmm6[1,1]
movaps %xmm3, %xmm2
cmpless %xmm6, %xmm2
movaps %xmm2, %xmm5
andnps %xmm3, %xmm5
andps %xmm6, %xmm2
orps %xmm5, %xmm2
movaps %xmm4, %xmm3
cmpless %xmm1, %xmm3
movaps %xmm3, %xmm5
andnps %xmm4, %xmm5
andps %xmm1, %xmm3
orps %xmm5, %xmm3
minss %xmm7, %xmm3
cmpltss %xmm1, %xmm7
movaps %xmm7, %xmm4
andnps %xmm3, %xmm4
andps %xmm1, %xmm7
orps %xmm4, %xmm7
movaps %xmm2, %xmm1
cmpltss %xmm0, %xmm1
movaps %xmm1, %xmm3
andps %xmm2, %xmm3
andnps %xmm8, %xmm1
orps %xmm3, %xmm1
cmpltss %xmm6, %xmm0
movaps %xmm0, %xmm2
andnps %xmm1, %xmm2
andps %xmm6, %xmm0
orps %xmm2, %xmm0
movaps %xmm7, -0x50(%rbp)
unpcklps %xmm7, %xmm0            # xmm0 = xmm0[0],xmm7[0],xmm0[1],xmm7[1]
movq %r14, %rdi
movaps %xmm0, -0x40(%rbp)
callq 0x52ced
movaps %xmm0, %xmm1
subss -0x1c(%rbp), %xmm1
movss (%rbx), %xmm2
ucomiss %xmm1, %xmm2
seta %sil
movl 0xc(%r14), %ecx
movl %ecx, %eax
andl $0x808, %eax            # imm = 0x808
cmpl $0x800, %eax            # imm = 0x800
sete %dil
movb $0x1, %al
movb $0x1, %dl
testb %dil, %sil
jne 0x52c7e
movzwl %cx, %edx
shrl $0xf, %edx
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
subss -0x20(%rbp), %xmm0
subss -0x24(%rbp), %xmm0
movss 0x4(%rbx), %xmm1
ucomiss %xmm0, %xmm1
seta %sil
testb $0x8, %cl
sete %dil
testb %dil, %sil
jne 0x52cac
shrl $0xe, %ecx
andl $0x1, %ecx
movl %ecx, %eax
testb %dl, %dl
movaps -0x40(%rbp), %xmm0
movaps -0x50(%rbp), %xmm1
je 0x52ccb
addss 0x15d0(%r15), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
shufps $0xe2, %xmm0, %xmm1     # xmm1 = xmm1[2,0],xmm0[2,3]
movaps %xmm1, %xmm0
testb %al, %al
je 0x52ce2
addss 0x15d0(%r15), %xmm0
jmp 0x52ce2
unpcklps %xmm7, %xmm8            # xmm8 = xmm8[0],xmm7[0],xmm8[1],xmm7[1]
movaps %xmm8, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq