// File: /workspace/github_cpp_makefile_star2_O3/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 -0x30(%rbp), %rdx
movq $0x0, (%rdx)
leaq 0x1bd72(%rip), %rdi     # 0x3e8ee
movss 0x1a818(%rip), %xmm0    # 0x3d39c
xorl %ecx, %ecx
callq 0xf554
testb %al, %al
je 0x22e2b
leaq 0x1bd62(%rip), %rdi     # 0x3e8fc
leaq 0x1ac47(%rip), %rsi     # 0x3d7e8
xorl %eax, %eax
callq 0x15c0a
movq 0x328d1(%rip), %rax     # 0x55480
movss 0x330(%rax), %xmm1
movss 0x1a8bd(%rip), %xmm0    # 0x3d47c
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
leaq 0x1bd33(%rip), %rdi     # 0x3e905
movb $0x2, %al
callq 0x15c0a
movq 0x328a0(%rip), %rax     # 0x55480
movl 0x338(%rax), %esi
movslq 0x33c(%rax), %rdx
imulq $0x55555556, %rdx, %rcx # imm = 0x55555556
movq %rcx, %rax
shrq $0x3f, %rax
shrq $0x20, %rcx
addl %eax, %ecx
leaq 0x1bd2a(%rip), %rdi     # 0x3e932
xorl %eax, %eax
callq 0x15c0a
movq 0x3286a(%rip), %rax     # 0x55480
movl 0x334(%rax), %esi
leaq 0x1bd36(%rip), %rdi     # 0x3e959
xorl %eax, %eax
callq 0x15c0a
leaq 0x1bd37(%rip), %rdi     # 0x3e968
leaq 0x32850(%rip), %rsi     # 0x55488
callq 0x1d626
callq 0x222dc
movq 0x32837(%rip), %r14     # 0x55480
incl 0x17c4(%r14)
leaq 0x1738(%r14), %rdi
leaq 0x1c356(%rip), %rsi     # 0x3efb4
callq 0x22e3e
movl 0x1870(%r14), %edx
leaq 0x1bd2a(%rip), %rdi     # 0x3e99b
leaq 0x1bd2c(%rip), %rsi     # 0x3e9a4
xorl %eax, %eax
callq 0x17b31
testb %al, %al
je 0x22cb3
cmpl $0x0, 0x1870(%r14)
jle 0x22cae
xorl %ebx, %ebx
movq 0x1878(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0x22eaa
incq %rbx
movslq 0x1870(%r14), %rax
cmpq %rax, %rbx
jl 0x22c8f
callq 0x228ce
movl 0x17f8(%r14), %edx
leaq 0x1bcf9(%rip), %rdi     # 0x3e9ba
leaq 0x1bcf9(%rip), %rsi     # 0x3e9c1
xorl %eax, %eax
callq 0x17b31
testb %al, %al
je 0x22d60
cmpl $0x0, 0x17f8(%r14)
jle 0x22d5b
movl $0x8, %r15d
leaq 0x1e74b(%rip), %r13     # 0x41439
leaq 0x1bce5(%rip), %rbx     # 0x3e9da
xorl %r12d, %r12d
movq 0x1800(%r14), %rax
movq (%rax,%r15), %rsi
movq %r13, %rcx
leaq 0x1bced(%rip), %rdx     # 0x3e9fa
movq %r13, %r8
testq %rsi, %rsi
je 0x22d39
movq (%rsi), %rdx
movl 0xc(%rsi), %esi
btl $0x14, %esi
leaq 0x1bcd9(%rip), %rcx     # 0x3e9ff
cmovaeq %r13, %rcx
btl $0x1b, %esi
leaq 0x1bcd7(%rip), %r8      # 0x3ea0c
cmovaeq %r13, %r8
movl -0x8(%rax,%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x179b7
incq %r12
movslq 0x17f8(%r14), %rax
addq $0x28, %r15
cmpq %rax, %r12
jl 0x22cf8
callq 0x228ce
leaq 0x1f6c6(%rip), %rsi     # 0x4242d
leaq 0x1bca9(%rip), %rdi     # 0x3ea17
movq %rdi, %rdx
xorl %eax, %eax
callq 0x17b31
testb %al, %al
je 0x22e24
movq 0x1770(%r14), %rax
leaq 0x1bc6c(%rip), %rbx     # 0x3e9fa
movq %rbx, %rsi
testq %rax, %rax
je 0x22d99
movq (%rax), %rsi
leaq 0x1bc83(%rip), %rdi     # 0x3ea23
xorl %eax, %eax
callq 0x15c0a
movq 0x1778(%r14), %rax
movq %rbx, %rsi
testq %rax, %rax
je 0x22db9
movq (%rax), %rsi
leaq 0x1bc77(%rip), %rdi     # 0x3ea37
xorl %eax, %eax
callq 0x15c0a
movq 0x1780(%r14), %rax
testq %rax, %rax
je 0x22dd6
movq (%rax), %rbx
leaq 0x1bc6e(%rip), %rdi     # 0x3ea4b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x15c0a
movl 0x1788(%r14), %esi
movl 0x178c(%r14), %edx
leaq 0x1bc67(%rip), %rdi     # 0x3ea63
xorl %eax, %eax
callq 0x15c0a
movl 0x1790(%r14), %esi
movl 0x1794(%r14), %edx
leaq 0x1bc64(%rip), %rdi     # 0x3ea7c
xorl %eax, %eax
callq 0x15c0a
callq 0x228ce
decl 0x17c4(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcc43