// File: /workspace/github_cpp_makefile_star2_O1/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 0x1ba75(%rip), %rdi     # 0x3e8be
movss 0x1a53b(%rip), %xmm0    # 0x3d38c
xorl %ecx, %ecx
callq 0xf7d7
testb %al, %al
je 0x23103
leaq 0x1ba65(%rip), %rdi     # 0x3e8cc
leaq 0x1a94a(%rip), %rsi     # 0x3d7b8
xorl %eax, %eax
callq 0x1609c
movq 0x32614(%rip), %rax     # 0x55490
movss 0x330(%rax), %xmm1
movss 0x1a5e0(%rip), %xmm0    # 0x3d46c
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
leaq 0x1ba36(%rip), %rdi     # 0x3e8d5
movb $0x2, %al
callq 0x1609c
movq 0x325e3(%rip), %rax     # 0x55490
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 0x1ba2d(%rip), %rdi     # 0x3e902
xorl %eax, %eax
callq 0x1609c
movq 0x325ad(%rip), %rax     # 0x55490
movl 0x334(%rax), %esi
leaq 0x1ba39(%rip), %rdi     # 0x3e929
xorl %eax, %eax
callq 0x1609c
leaq 0x1ba3a(%rip), %rdi     # 0x3e938
leaq 0x32593(%rip), %rsi     # 0x55498
callq 0x1da36
callq 0x2259f
movq 0x3257a(%rip), %r14     # 0x55490
incl 0x17c4(%r14)
leaq 0x1738(%r14), %rdi
leaq 0x1c059(%rip), %rsi     # 0x3ef84
callq 0x23116
movl 0x1870(%r14), %edx
leaq 0x1ba2d(%rip), %rdi     # 0x3e96b
leaq 0x1ba2f(%rip), %rsi     # 0x3e974
xorl %eax, %eax
callq 0x18049
testb %al, %al
je 0x22f80
cmpl $0x0, 0x1870(%r14)
jle 0x22f7b
xorl %ebx, %ebx
movq 0x1878(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0x23182
incq %rbx
movslq 0x1870(%r14), %rax
cmpq %rax, %rbx
jl 0x22f5c
callq 0x22b95
movl 0x17f8(%r14), %edx
leaq 0x1b9fc(%rip), %rdi     # 0x3e98a
leaq 0x1b9fc(%rip), %rsi     # 0x3e991
xorl %eax, %eax
callq 0x18049
testb %al, %al
je 0x23038
cmpl $0x0, 0x17f8(%r14)
jle 0x23033
movl $0x8, %r15d
leaq 0x1e4fa(%rip), %r13     # 0x414b9
leaq 0x1b9e4(%rip), %rbx     # 0x3e9aa
xorl %r12d, %r12d
movq 0x1800(%r14), %rax
movq (%rax,%r15), %rsi
leaq 0x1b9ef(%rip), %rdx     # 0x3e9ca
testq %rsi, %rsi
je 0x22fe3
movq (%rsi), %rdx
movq %r13, %rcx
testq %rsi, %rsi
je 0x22ffa
testb $0x10, 0xe(%rsi)
leaq 0x1b9d9(%rip), %rcx     # 0x3e9cf
cmoveq %r13, %rcx
movq %r13, %r8
testq %rsi, %rsi
je 0x23011
testb $0x8, 0xf(%rsi)
leaq 0x1b9cf(%rip), %r8      # 0x3e9dc
cmoveq %r13, %r8
movl -0x8(%rax,%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x17ed5
incq %r12
movslq 0x17f8(%r14), %rax
addq $0x28, %r15
cmpq %rax, %r12
jl 0x22fc9
callq 0x22b95
leaq 0x1f471(%rip), %rsi     # 0x424b0
leaq 0x1b9a1(%rip), %rdi     # 0x3e9e7
movq %rdi, %rdx
xorl %eax, %eax
callq 0x18049
testb %al, %al
je 0x230fc
movq 0x1770(%r14), %rax
leaq 0x1b964(%rip), %rbx     # 0x3e9ca
movq %rbx, %rsi
testq %rax, %rax
je 0x23071
movq (%rax), %rsi
leaq 0x1b97b(%rip), %rdi     # 0x3e9f3
xorl %eax, %eax
callq 0x1609c
movq 0x1778(%r14), %rax
movq %rbx, %rsi
testq %rax, %rax
je 0x23091
movq (%rax), %rsi
leaq 0x1b96f(%rip), %rdi     # 0x3ea07
xorl %eax, %eax
callq 0x1609c
movq 0x1780(%r14), %rax
testq %rax, %rax
je 0x230ae
movq (%rax), %rbx
leaq 0x1b966(%rip), %rdi     # 0x3ea1b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1609c
movl 0x1788(%r14), %esi
movl 0x178c(%r14), %edx
leaq 0x1b95f(%rip), %rdi     # 0x3ea33
xorl %eax, %eax
callq 0x1609c
movl 0x1790(%r14), %esi
movl 0x1794(%r14), %edx
leaq 0x1b95c(%rip), %rdi     # 0x3ea4c
xorl %eax, %eax
callq 0x1609c
callq 0x22b95
decl 0x17c4(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcdc7