// File: /workspace/github_cpp_makefile_star2_O2/donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::ShowMetricsWindow(bool*)
void ImGui::ShowMetricsWindow(bool* opened)
{
    if (ImGui::Begin("ImGui Metrics", opened))
    {
        ImGui::Text("ImGui %s", ImGui::GetVersion());
        ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
        ImGui::Text("%d vertices, %d indices (%d triangles)", ImGui::GetIO().MetricsRenderVertices, ImGui::GetIO().MetricsRenderIndices, ImGui::GetIO().MetricsRenderIndices / 3);
        ImGui::Text("%d allocations", ImGui::GetIO().MetricsAllocs);
        static bool show_clip_rects = true;
        ImGui::Checkbox("Show clipping rectangles when hovering a ImDrawCmd", &show_clip_rects);
        ImGui::Separator();

        struct Funcs
        {
            static void NodeDrawList(ImDrawList* draw_list, const char* label)
            {
                bool node_opened = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size);
                if (draw_list == ImGui::GetWindowDrawList())
                {
                    ImGui::SameLine();
                    ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
                }
                if (!node_opened)
                    return;

                int elem_offset = 0;
                for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
                {
                    if (pcmd->UserCallback)
                        ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
                    else
                    {
                        ImGui::BulletText("Draw %d indexed vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
                        if (show_clip_rects && ImGui::IsItemHovered())
                        {
                            ImRect clip_rect = pcmd->ClipRect;
                            ImRect vtxs_rect;
                            for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
                                vtxs_rect.Add(draw_list->VtxBuffer[draw_list->IdxBuffer[i]].pos);
                            GImGui->OverlayDrawList.PushClipRectFullScreen();
                            clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
                            vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
                            GImGui->OverlayDrawList.PopClipRect();
                        }
                    }
                }
                ImGui::TreePop();
            }

            static void NodeWindows(ImVector<ImGuiWindow*>& windows, const char* label)
            {
                if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
                    return;
                for (int i = 0; i < windows.Size; i++)
                    Funcs::NodeWindow(windows[i], "Window");
                ImGui::TreePop();
            }

            static void NodeWindow(ImGuiWindow* window, const char* label)
            {
                if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, window->Active || window->WasActive, window))
                    return;
                NodeDrawList(window->DrawList, "DrawList");
                if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
                if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
                ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
                ImGui::TreePop();
            }
        };

        ImGuiState& g = *GImGui;                // Access private state
        g.DisableHideTextAfterDoubleHash++;     // Not exposed (yet). Disable processing that hides text after '##' markers.
        Funcs::NodeWindows(g.Windows, "Windows");
        if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.RenderDrawLists[0].Size))
        {
            for (int i = 0; i < g.RenderDrawLists[0].Size; i++)
                Funcs::NodeDrawList(g.RenderDrawLists[0][i], "DrawList");
            ImGui::TreePop();
        }
        if (ImGui::TreeNode("Popups", "Opened Popups Stack (%d)", g.OpenedPopupStack.Size))
        {
            for (int i = 0; i < g.OpenedPopupStack.Size; i++)
            {
                ImGuiWindow* window = g.OpenedPopupStack[i].Window;
                ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenedPopupStack[i].PopupID, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
            }
            ImGui::TreePop();
        }
        if (ImGui::TreeNode("Basic state"))
        {
            ImGui::Text("FocusedWindow: '%s'", g.FocusedWindow ? g.FocusedWindow->Name : "NULL");
            ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL");
            ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL");
            ImGui::Text("HoveredID: 0x%08X/0x%08X", g.HoveredId, g.HoveredIdPreviousFrame); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
            ImGui::Text("ActiveID: 0x%08X/0x%08X", g.ActiveId, g.ActiveIdPreviousFrame);
            ImGui::TreePop();
        }
        g.DisableHideTextAfterDoubleHash--;
    }
    ImGui::End();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rsi
leaq 0x1ab0c(%rip), %rdi     # 0x378a6
xorl %edx, %edx
callq 0xb0d4
testb %al, %al
je 0x1d029
leaq 0x1ab04(%rip), %rdi     # 0x378b4
leaq 0x199e9(%rip), %rsi     # 0x367a0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1227e
movq 0x336b9(%rip), %rax     # 0x50480
movss 0x330(%rax), %xmm1
movss 0x1969d(%rip), %xmm0    # 0x36474
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
leaq 0x1aad3(%rip), %rdi     # 0x378bd
movb $0x2, %al
callq 0x1227e
movq 0x33688(%rip), %rax     # 0x50480
movl 0x338(%rax), %esi
movl 0x33c(%rax), %ecx
pushq $0x3
popq %rdi
movl %ecx, %eax
cltd
idivl %edi
leaq 0x1aad7(%rip), %rdi     # 0x378ea
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x1227e
movq 0x3365b(%rip), %rax     # 0x50480
movl 0x334(%rax), %esi
leaq 0x1aadf(%rip), %rdi     # 0x37911
xorl %eax, %eax
callq 0x1227e
leaq 0x1aae0(%rip), %rdi     # 0x37920
leaq 0x33641(%rip), %rsi     # 0x50488
callq 0x18846
callq 0x1c64c
movq 0x33628(%rip), %r15     # 0x50480
incl 0x17c4(%r15)
leaq 0x1738(%r15), %rdi
leaq 0x1b1b4(%rip), %rsi     # 0x38021
callq 0x1d03c
movl 0x1870(%r15), %edx
leaq 0x1aad3(%rip), %rdi     # 0x37953
leaq 0x1aad5(%rip), %rsi     # 0x3795c
xorl %eax, %eax
callq 0x13b50
testb %al, %al
je 0x1ceb9
leaq 0x1870(%r15), %r14
cmpl (%r14), %ebx
jge 0x1ceb4
movq %r14, %rdi
movl %ebx, %esi
callq 0x1eab0
movq (%rax), %rdi
callq 0x1d0a8
incl %ebx
jmp 0x1ce99
callq 0x1cba4
movl 0x17f8(%r15), %edx
leaq 0x1aaab(%rip), %rdi     # 0x37972
leaq 0x1aaab(%rip), %rsi     # 0x37979
xorl %eax, %eax
callq 0x13b50
testb %al, %al
je 0x1cf6a
movq %r15, -0x30(%rbp)
leaq 0x17f8(%r15), %rbx
leaq 0x1d73a(%rip), %r12     # 0x3a629
leaq 0x1aa9c(%rip), %r14     # 0x37992
xorl %r15d, %r15d
cmpl (%rbx), %r15d
jge 0x1cf61
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1ebd4
movq 0x8(%rax), %r13
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1ebd4
movq %r12, %rcx
leaq 0x1aa90(%rip), %rdx     # 0x379b2
movq %r12, %r8
testq %r13, %r13
je 0x1cf50
movq (%r13), %rdx
movl 0xc(%r13), %esi
btl $0x14, %esi
leaq 0x1aa7a(%rip), %rcx     # 0x379b7
cmovaeq %r12, %rcx
btl $0x1b, %esi
leaq 0x1aa78(%rip), %r8      # 0x379c4
cmovaeq %r12, %r8
movl (%rax), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x139fd
incl %r15d
jmp 0x1cef9
callq 0x1cba4
movq -0x30(%rbp), %r15
leaq 0x1aa5e(%rip), %rdi     # 0x379cf
callq 0x13d10
testb %al, %al
je 0x1d022
leaq 0x1aa2d(%rip), %rbx     # 0x379b2
movq 0x1770(%r15), %rax
movq %rbx, %rsi
testq %rax, %rax
je 0x1cf97
movq (%rax), %rsi
leaq 0x1aa3d(%rip), %rdi     # 0x379db
xorl %eax, %eax
callq 0x1227e
movq 0x1778(%r15), %rax
movq %rbx, %rsi
testq %rax, %rax
je 0x1cfb7
movq (%rax), %rsi
leaq 0x1aa31(%rip), %rdi     # 0x379ef
xorl %eax, %eax
callq 0x1227e
movq 0x1780(%r15), %rax
testq %rax, %rax
je 0x1cfd4
movq (%rax), %rbx
leaq 0x1aa28(%rip), %rdi     # 0x37a03
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1227e
movl 0x1788(%r15), %esi
movl 0x178c(%r15), %edx
leaq 0x1aa21(%rip), %rdi     # 0x37a1b
xorl %eax, %eax
callq 0x1227e
movl 0x1790(%r15), %esi
movl 0x1794(%r15), %edx
leaq 0x1aa1e(%rip), %rdi     # 0x37a34
xorl %eax, %eax
callq 0x1227e
callq 0x1cba4
decl 0x17c4(%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb516