// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::EndFrame()
void ImGui::EndFrame()
{
    ImGuiContext& g = *GImGui;
    IM_ASSERT(g.Initialized);

    // Don't process EndFrame() multiple times.
    if (g.FrameCountEnded == g.FrameCount)
        return;
    IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?");

    CallContextHooks(&g, ImGuiContextHookType_EndFramePre);

    ErrorCheckEndFrameSanityChecks();

    // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
    if (g.IO.ImeSetInputScreenPosFn && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f))
    {
        g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y);
        g.PlatformImeLastPos = g.PlatformImePos;
    }

    // Hide implicit/fallback "Debug" window if it hasn't been used
    g.WithinFrameScopeWithImplicitWindow = false;
    if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
        g.CurrentWindow->Active = false;
    End();

    // Update navigation: CTRL+Tab, wrap-around requests
    NavEndFrame();

    // Drag and Drop: Elapse payload (if delivered, or if source stops being submitted)
    if (g.DragDropActive)
    {
        bool is_delivered = g.DragDropPayload.Delivery;
        bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton));
        if (is_delivered || is_elapsed)
            ClearDragDrop();
    }

    // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
    if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
    {
        g.DragDropWithinSource = true;
        SetTooltip("...");
        g.DragDropWithinSource = false;
    }

    // End frame
    g.WithinFrameScope = false;
    g.FrameCountEnded = g.FrameCount;

    // Initiate moving window + handle left-click and right-click focus
    UpdateMouseMovingWindowEndFrame();

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

    // This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong.
    IM_ASSERT(g.Windows.Size == g.WindowsTempSortBuffer.Size);
    g.Windows.swap(g.WindowsTempSortBuffer);
    g.IO.MetricsActiveWindows = g.WindowsActiveCount;

    // Unlock font atlas
    g.IO.Fonts->Locked = false;

    // Clear Input data for next frame
    g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f;
    g.IO.InputQueueCharacters.resize(0);
    memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs));

    CallContextHooks(&g, ImGuiContextHookType_EndFramePost);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq 0x13f971(%rip), %rax    # 0x212f40
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, (%rax)
je 0xd35de
jmp 0xd35fd
leaq 0xa03a3(%rip), %rdi     # 0x173988
leaq 0x9f91d(%rip), %rsi     # 0x172f09
movl $0x1096, %edx           # imm = 0x1096
leaq 0xa039e(%rip), %rcx     # 0x173996
callq 0xd180
movq -0x8(%rbp), %rax
movl 0x1a6c(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1a68(%rcx), %eax
jne 0xd3618
jmp 0xd39de
movq -0x8(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x1a74(%rcx)
movb %al, -0x21(%rbp)
je 0xd3631
movb $0x1, %al
movb %al, -0x21(%rbp)
jmp 0xd3631
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0xd363a
jmp 0xd363c
jmp 0xd365b
leaq 0xa038c(%rip), %rdi     # 0x1739cf
leaq 0x9f8bf(%rip), %rsi     # 0x172f09
movl $0x109b, %edx           # imm = 0x109B
leaq 0xa0340(%rip), %rcx     # 0x173996
callq 0xd180
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0xcb100
callq 0xd39f0
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x118(%rcx)
movb %al, -0x22(%rbp)
je 0xd36e2
movq -0x8(%rbp), %rax
movss 0x30d8(%rax), %xmm0
movb $0x1, %al
movss 0x9e91d(%rip), %xmm1    # 0x171fb4
ucomiss %xmm1, %xmm0
movb %al, -0x23(%rbp)
jne 0xd36a3
jp 0xd36a3
jmp 0xd36dc
movq -0x8(%rbp), %rsi
movq %rsi, %rdi
addq $0x30d8, %rdi           # imm = 0x30D8
addq $0x30d0, %rsi           # imm = 0x30D0
callq 0xc3c00
movlpd %xmm0, -0x10(%rbp)
leaq -0x10(%rbp), %rdi
callq 0xc3bc0
movss 0x9f0c1(%rip), %xmm1    # 0x172794
ucomiss %xmm1, %xmm0
seta %al
movb %al, -0x23(%rbp)
movb -0x23(%rbp), %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
testb $0x1, %al
jne 0xd36eb
jmp 0xd3726
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rax
movq -0x8(%rbp), %rcx
cvttss2si 0x30d0(%rcx), %edi
movq -0x8(%rbp), %rcx
cvttss2si 0x30d4(%rcx), %esi
callq *%rax
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x30d0(%rcx), %rcx
movq %rcx, 0x30d8(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x1a75(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1ae0(%rax)
je 0xd3765
movq -0x8(%rbp), %rax
movq 0x1ae0(%rax), %rax
testb $0x1, 0x90(%rax)
jne 0xd3765
movq -0x8(%rbp), %rax
movq 0x1ae0(%rax), %rax
movb $0x0, 0x8e(%rax)
callq 0xd3b60
callq 0xd3d30
movq -0x8(%rbp), %rax
testb $0x1, 0x2004(%rax)
je 0xd37f5
movq -0x8(%rbp), %rax
movb 0x2052(%rax), %al
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movl 0x202c(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x1a68(%rdx), %ecx
movb %al, -0x24(%rbp)
jge 0xd37da
movq -0x8(%rbp), %rax
movl 0x2008(%rax), %ecx
andl $0x20, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x25(%rbp)
jne 0xd37d4
movq -0x8(%rbp), %rax
movl 0x2010(%rax), %edi
callq 0xd4050
xorb $-0x1, %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
movb %al, -0x24(%rbp)
movb -0x24(%rbp), %al
andb $0x1, %al
movb %al, -0x12(%rbp)
testb $0x1, -0x11(%rbp)
jne 0xd37ee
testb $0x1, -0x12(%rbp)
je 0xd37f3
callq 0xd40c0
jmp 0xd37f5
movq -0x8(%rbp), %rax
testb $0x1, 0x2004(%rax)
je 0xd384e
movq -0x8(%rbp), %rax
movl 0x200c(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1a68(%rcx), %eax
jge 0xd384e
movq -0x8(%rbp), %rax
movl 0x2008(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xd384e
movq -0x8(%rbp), %rax
movb $0x1, 0x2005(%rax)
leaq 0xae4ba(%rip), %rdi     # 0x181cf6
movb $0x0, %al
callq 0xd4170
movq -0x8(%rbp), %rax
movb $0x0, 0x2005(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x1a74(%rax)
movq -0x8(%rbp), %rax
movl 0x1a68(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1a6c(%rax)
callq 0xcb950
movq -0x8(%rbp), %rdi
addq $0x1aa8, %rdi           # imm = 0x1AA8
xorl %esi, %esi
callq 0xeaa00
movq -0x8(%rbp), %rdi
addq $0x1aa8, %rdi           # imm = 0x1AA8
movq -0x8(%rbp), %rax
movl 0x1a88(%rax), %esi
callq 0xeb360
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1a88(%rcx), %eax
je 0xd390d
movq -0x8(%rbp), %rdi
addq $0x1a88, %rdi           # imm = 0x1A88
movl -0x18(%rbp), %esi
callq 0xea8d0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x8e(%rax)
je 0xd38ee
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x0, %eax
je 0xd38ee
jmp 0xd3902
movq -0x8(%rbp), %rdi
addq $0x1aa8, %rdi           # imm = 0x1AA8
movq -0x20(%rbp), %rsi
callq 0xd4210
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xd38a5
movq -0x8(%rbp), %rax
movl 0x1a88(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1aa8(%rcx), %eax
jne 0xd3925
jmp 0xd3944
leaq 0xa00dd(%rip), %rdi     # 0x173a09
leaq 0x9f5d6(%rip), %rsi     # 0x172f09
movl $0x10d6, %edx           # imm = 0x10D6
leaq 0xa0057(%rip), %rcx     # 0x173996
callq 0xd180
movq -0x8(%rbp), %rdi
addq $0x1a88, %rdi           # imm = 0x1A88
movq -0x8(%rbp), %rsi
addq $0x1aa8, %rsi           # imm = 0x1AA8
callq 0xeb3e0
movq -0x8(%rbp), %rax
movl 0x1ad8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x3b0(%rax)
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x13c(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x138(%rax)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
addq $0x1548, %rdi           # imm = 0x1548
xorl %esi, %esi
callq 0xe7f00
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
addq $0x33c, %rdi            # imm = 0x33C
xorl %esi, %esi
movl $0x54, %edx
callq 0xd2f0
movq -0x8(%rbp), %rdi
movl $0x3, %esi
callq 0xcb100
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)