// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::Shutdown()
void ImGui::Shutdown()
{
    ImGuiState& g = *GImGui;
    if (!g.Initialized)
        return;

    SaveSettings();

    for (int i = 0; i < g.Windows.Size; i++)
    {
        g.Windows[i]->~ImGuiWindow();
        ImGui::MemFree(g.Windows[i]);
    }
    g.Windows.clear();
    g.WindowsSortBuffer.clear();
    g.CurrentWindowStack.clear();
    g.FocusedWindow = NULL;
    g.HoveredWindow = NULL;
    g.HoveredRootWindow = NULL;
    for (int i = 0; i < g.Settings.Size; i++)
        ImGui::MemFree(g.Settings[i].Name);
    g.Settings.clear();
    g.ColorModifiers.clear();
    g.StyleModifiers.clear();
    g.FontStack.clear();
    g.OpenedPopupStack.clear();
    g.CurrentPopupStack.clear();
    for (int i = 0; i < IM_ARRAYSIZE(g.RenderDrawLists); i++)
        g.RenderDrawLists[i].clear();
    g.OverlayDrawList.ClearFreeMemory();
    g.ColorEditModeStorage.Clear();
    if (g.PrivateClipboard)
    {
        ImGui::MemFree(g.PrivateClipboard);
        g.PrivateClipboard = NULL;
    }
    g.InputTextState.Text.clear();
    g.InputTextState.InitialText.clear();
    g.InputTextState.TempTextBuffer.clear();

    if (g.LogFile && g.LogFile != stdout)
    {
        fclose(g.LogFile);
        g.LogFile = NULL;
    }
    if (g.LogClipboard)
    {
        g.LogClipboard->~ImGuiTextBuffer();
        ImGui::MemFree(g.LogClipboard);
    }

    if (g.IO.Fonts) // Testing for NULL to allow user to NULLify in case of running Shutdown() on multiple contexts. Bit hacky.
        g.IO.Fonts->Clear();

    g.Initialized = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq 0x6ac71(%rip), %rax     # 0x794c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, (%rax)
jne 0xe861
jmp 0xeb09
callq 0xdfb0
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1738(%rcx), %eax
jge 0xe8bd
movq -0x8(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
movl -0xc(%rbp), %esi
callq 0x2e1c0
movq (%rax), %rdi
callq 0xbce0
movq -0x8(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
movl -0xc(%rbp), %esi
callq 0x2e1c0
movq (%rax), %rdi
callq 0xa760
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xe86d
movq -0x8(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
callq 0x2e510
movq -0x8(%rbp), %rdi
addq $0x1748, %rdi           # imm = 0x1748
callq 0x2e510
movq -0x8(%rbp), %rdi
addq $0x1760, %rdi           # imm = 0x1760
callq 0x2e510
movq -0x8(%rbp), %rax
movq $0x0, 0x1770(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x1778(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x1780(%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x17b0(%rcx), %eax
jge 0xe956
movq -0x8(%rbp), %rdi
addq $0x17b0, %rdi           # imm = 0x17B0
movl -0x10(%rbp), %esi
callq 0x2e560
movq (%rax), %rdi
callq 0xa760
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xe921
movq -0x8(%rbp), %rdi
addq $0x17b0, %rdi           # imm = 0x17B0
callq 0x2e5c0
movq -0x8(%rbp), %rdi
addq $0x17c8, %rdi           # imm = 0x17C8
callq 0x2e610
movq -0x8(%rbp), %rdi
addq $0x17d8, %rdi           # imm = 0x17D8
callq 0x2e660
movq -0x8(%rbp), %rdi
addq $0x17e8, %rdi           # imm = 0x17E8
callq 0x2e6b0
movq -0x8(%rbp), %rdi
addq $0x17f8, %rdi           # imm = 0x17F8
callq 0x2e700
movq -0x8(%rbp), %rdi
addq $0x1808, %rdi           # imm = 0x1808
callq 0x2e700
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0xe9e9
movq -0x8(%rbp), %rdi
addq $0x1870, %rdi           # imm = 0x1870
movslq -0x14(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x2e750
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xe9bd
movq -0x8(%rbp), %rdi
addq $0x18a8, %rdi           # imm = 0x18A8
callq 0x3cc70
movq -0x8(%rbp), %rdi
addq $0x27a8, %rdi           # imm = 0x27A8
callq 0xa7b0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x2be0(%rax)
je 0xea36
movq -0x8(%rbp), %rax
movq 0x2be0(%rax), %rdi
callq 0xa760
movq -0x8(%rbp), %rax
movq $0x0, 0x2be0(%rax)
movq -0x8(%rbp), %rdi
addq $0x1ab0, %rdi           # imm = 0x1AB0
addq $0x8, %rdi
callq 0x2e7a0
movq -0x8(%rbp), %rdi
addq $0x1ab0, %rdi           # imm = 0x1AB0
addq $0x18, %rdi
callq 0x2e7f0
movq -0x8(%rbp), %rdi
addq $0x1ab0, %rdi           # imm = 0x1AB0
addq $0x28, %rdi
callq 0x2e7f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x2bf0(%rax)
je 0xeab6
movq -0x8(%rbp), %rax
movq 0x2bf0(%rax), %rax
movq 0x6a53e(%rip), %rcx     # 0x78fd0
cmpq (%rcx), %rax
je 0xeab6
movq -0x8(%rbp), %rax
movq 0x2bf0(%rax), %rdi
callq 0x7390
movq -0x8(%rbp), %rax
movq $0x0, 0x2bf0(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x2bf8(%rax)
je 0xeae4
movq -0x8(%rbp), %rax
movq 0x2bf8(%rax), %rdi
callq 0x2e840
movq -0x8(%rbp), %rax
movq 0x2bf8(%rax), %rdi
callq 0xa760
movq -0x8(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0xeb02
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x41c40
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nop