// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::EndFrame()
void ImGui::EndFrame()
{
    ImGuiState& g = *GImGui;
    IM_ASSERT(g.Initialized);                       // Forgot to call ImGui::NewFrame()
    IM_ASSERT(g.FrameCountEnded != g.FrameCount);   // ImGui::EndFrame() called multiple times, or forgot to call ImGui::NewFrame() again

    g.FrameCountEnded = g.FrameCount;

    // Hide implicit "Debug" window if it hasn't been used
    IM_ASSERT(g.CurrentWindowStack.Size == 1);    // Mismatched Begin/End
    if (g.CurrentWindow && !g.CurrentWindow->Accessed)
        g.CurrentWindow->Active = false;
    ImGui::End();

    // Click to focus window and start moving (after we're done with all our widgets)
    if (!g.ActiveId)
        g.MovedWindow = NULL;
    if (g.ActiveId == 0 && g.HoveredId == 0 && g.IO.MouseClicked[0])
    {
        if (!(g.FocusedWindow && !g.FocusedWindow->WasActive && g.FocusedWindow->Active)) // Unless we just made a popup appear
        {
            if (g.HoveredRootWindow != NULL)
            {
                FocusWindow(g.HoveredWindow);
                if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove))
                {
                    g.MovedWindow = g.HoveredWindow;
                    SetActiveID(g.HoveredRootWindow->MoveID, g.HoveredRootWindow);
                }
            }
            else if (g.FocusedWindow != NULL && GetFrontMostModalRootWindow() == NULL)
            {
                // Clicking on void disable focus
                FocusWindow(NULL);
            }
        }
    }

    // Sort the window list so that all child windows are after their parent
    // We cannot do that on FocusWindow() because childs may not exist yet
    g.WindowsSortBuffer.resize(0);
    g.WindowsSortBuffer.reserve(g.Windows.Size);
    for (int i = 0; i != g.Windows.Size; i++)
    {
        ImGuiWindow* window = g.Windows[i];
        if (window->Flags & ImGuiWindowFlags_ChildWindow)       // if a child is active its parent will add it
            if (window->Active)
                continue;
        AddWindowToSortedBuffer(g.WindowsSortBuffer, window);
    }
    IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size);  // we done something wrong
    g.Windows.swap(g.WindowsSortBuffer);

    // Clear Input data for next frame
    g.IO.MouseWheel = 0.0f;
    memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq 0x6a9a1(%rip), %rax     # 0x794c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, (%rax)
je 0xeb2e
jmp 0xeb4d
leaq 0x4c9ac(%rip), %rdi     # 0x5b4e1
leaq 0x4c789(%rip), %rsi     # 0x5b2c5
movl $0x8dd, %edx            # imm = 0x8DD
leaq 0x4c9a7(%rip), %rcx     # 0x5b4ef
callq 0x7160
movq -0x8(%rbp), %rax
movl 0x1730(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x172c(%rcx), %eax
je 0xeb65
jmp 0xeb84
leaq 0x4c99a(%rip), %rdi     # 0x5b506
leaq 0x4c752(%rip), %rsi     # 0x5b2c5
movl $0x8de, %edx            # imm = 0x8DE
leaq 0x4c970(%rip), %rcx     # 0x5b4ef
callq 0x7160
movq -0x8(%rbp), %rax
movl 0x172c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1730(%rax)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1760(%rax)
jne 0xeba7
jmp 0xebc6
leaq 0x4c97a(%rip), %rdi     # 0x5b528
leaq 0x4c710(%rip), %rsi     # 0x5b2c5
movl $0x8e3, %edx            # imm = 0x8E3
leaq 0x4c92e(%rip), %rcx     # 0x5b4ef
callq 0x7160
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1758(%rax)
je 0xebf4
movq -0x8(%rbp), %rax
movq 0x1758(%rax), %rax
testb $0x1, 0x72(%rax)
jne 0xebf4
movq -0x8(%rbp), %rax
movq 0x1758(%rax), %rax
movb $0x0, 0x70(%rax)
callq 0xee30
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1790(%rax)
jne 0xec15
movq -0x8(%rbp), %rax
movq $0x0, 0x17a8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1790(%rax)
jne 0xed0e
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1788(%rax)
jne 0xed0e
movq -0x8(%rbp), %rax
testb $0x1, 0x354(%rax)
je 0xed0e
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1770(%rax)
je 0xec7c
movq -0x8(%rbp), %rax
movq 0x1770(%rax), %rax
testb $0x1, 0x71(%rax)
jne 0xec7c
movq -0x8(%rbp), %rax
movq 0x1770(%rax), %rax
testb $0x1, 0x70(%rax)
jne 0xed0c
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1780(%rax)
je 0xece6
movq -0x8(%rbp), %rax
movq 0x1778(%rax), %rdi
callq 0xef00
movq -0x8(%rbp), %rax
movq 0x1778(%rax), %rax
movl 0xc(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0xece4
movq -0x8(%rbp), %rax
movq 0x1778(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x17a8(%rax)
movq -0x8(%rbp), %rax
movq 0x1780(%rax), %rax
movl 0x48(%rax), %edi
movq -0x8(%rbp), %rax
movq 0x1780(%rax), %rsi
callq 0xbe60
jmp 0xed0a
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1770(%rax)
je 0xed08
callq 0xe2f0
cmpq $0x0, %rax
jne 0xed08
xorl %eax, %eax
movl %eax, %edi
callq 0xef00
jmp 0xed0a
jmp 0xed0c
jmp 0xed0e
movq -0x8(%rbp), %rdi
addq $0x1748, %rdi           # imm = 0x1748
xorl %esi, %esi
callq 0x2e470
movq -0x8(%rbp), %rdi
addq $0x1748, %rdi           # imm = 0x1748
movq -0x8(%rbp), %rax
movl 0x1738(%rax), %esi
callq 0x2e860
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1738(%rcx), %eax
je 0xeda8
movq -0x8(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
movl -0xc(%rbp), %esi
callq 0x2e1c0
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
je 0xed89
movq -0x18(%rbp), %rax
testb $0x1, 0x70(%rax)
je 0xed87
jmp 0xed9d
jmp 0xed89
movq -0x8(%rbp), %rdi
addq $0x1748, %rdi           # imm = 0x1748
movq -0x18(%rbp), %rsi
callq 0xf050
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xed41
movq -0x8(%rbp), %rax
movl 0x1738(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1748(%rcx), %eax
jne 0xedc0
jmp 0xeddf
leaq 0x4c780(%rip), %rdi     # 0x5b547
leaq 0x4c4f7(%rip), %rsi     # 0x5b2c5
movl $0x90c, %edx            # imm = 0x90C
leaq 0x4c715(%rip), %rcx     # 0x5b4ef
callq 0x7160
movq -0x8(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
movq -0x8(%rbp), %rsi
addq $0x1748, %rsi           # imm = 0x1748
callq 0x2e8e0
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x100(%rax)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
addq $0x300, %rdi            # imm = 0x300
xorl %esi, %esi
movl $0x22, %edx
callq 0x7240
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)