// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::UpdateMouseMovingWindowEndFrame()
void ImGui::UpdateMouseMovingWindowEndFrame()
{
    ImGuiContext& g = *GImGui;
    if (g.ActiveId != 0 || g.HoveredId != 0)
        return;

    // Unless we just made a window/popup appear
    if (g.NavWindow && g.NavWindow->Appearing)
        return;

    // Click on empty space to focus window and start moving (after we're done with all our widgets)
    if (g.IO.MouseClicked[0])
    {
        // Handle the edge case of a popup being closed while clicking in its empty space.
        // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
        ImGuiWindow* root_window = g.HoveredRootWindow;
        const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel);

        if (root_window != NULL && !is_closed_popup)
        {
            StartMouseMovingWindow(g.HoveredWindow); //-V595

            // Cancel moving if clicked outside of title bar
            if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(root_window->Flags & ImGuiWindowFlags_NoTitleBar))
                if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
                    g.MovingWindow = NULL;

            // Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already)
            if (g.HoveredIdDisabled)
                g.MovingWindow = NULL;
        }
        else if (root_window == NULL && g.NavWindow != NULL && GetTopMostPopupModal() == NULL)
        {
            // Clicking on void disable focus
            FocusWindow(NULL);
        }
    }

    // With right mouse button we close popups without changing focus based on where the mouse is aimed
    // Instead, focus will be restored to the window under the bottom-most closed popup.
    // (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
    if (g.IO.MouseClicked[1])
    {
        // Find the top-most window between HoveredWindow and the top-most Modal Window.
        // This is where we can trim the popup stack.
        ImGuiWindow* modal = GetTopMostPopupModal();
        bool hovered_window_above_modal = g.HoveredWindow && IsWindowAbove(g.HoveredWindow, modal);
        ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x1475e1(%rip), %rax    # 0x212f40
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1b30(%rax)
jne 0xcb97d
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1b1c(%rax)
je 0xcb982
jmp 0xcbb52
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1c90(%rax)
je 0xcb9a9
movq -0x8(%rbp), %rax
movq 0x1c90(%rax), %rax
testb $0x1, 0x94(%rax)
je 0xcb9a9
jmp 0xcbb52
movq -0x8(%rbp), %rax
testb $0x1, 0x420(%rax)
je 0xcbadd
movq -0x8(%rbp), %rax
movq 0x1af0(%rax), %rax
movq %rax, -0x10(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x32(%rbp)
je 0xcba05
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x4000000, %ecx        # imm = 0x4000000
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x32(%rbp)
je 0xcba05
movq -0x10(%rbp), %rax
movl 0xa0(%rax), %edi
movl $0x100, %esi            # imm = 0x100
callq 0xcbb60
xorb $-0x1, %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
andb $0x1, %al
movb %al, -0x11(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xcbab0
testb $0x1, -0x11(%rbp)
jne 0xcbab0
movq -0x8(%rbp), %rax
movq 0x1ae8(%rax), %rdi
callq 0xcb2c0
movq -0x8(%rbp), %rax
testb $0x1, 0xcd(%rax)
je 0xcba92
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xcba92
movq -0x10(%rbp), %rdi
callq 0xea690
movlpd %xmm0, -0x24(%rbp)
movlpd %xmm1, -0x1c(%rbp)
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
addq $0x3c4, %rsi            # imm = 0x3C4
leaq -0x24(%rbp), %rdi
callq 0xea710
xorb $-0x1, %al
testb $0x1, %al
jne 0xcba81
jmp 0xcba90
movq -0x8(%rbp), %rax
movq $0x0, 0x1b00(%rax)
jmp 0xcba92
movq -0x8(%rbp), %rax
testb $0x1, 0x1b27(%rax)
je 0xcbaae
movq -0x8(%rbp), %rax
movq $0x0, 0x1b00(%rax)
jmp 0xcbadb
cmpq $0x0, -0x10(%rbp)
jne 0xcbad9
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1c90(%rax)
je 0xcbad9
callq 0xcbca0
cmpq $0x0, %rax
jne 0xcbad9
xorl %eax, %eax
movl %eax, %edi
callq 0xcb380
jmp 0xcbadb
jmp 0xcbadd
movq -0x8(%rbp), %rax
testb $0x1, 0x421(%rax)
je 0xcbb52
callq 0xcbca0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x1ae8(%rcx)
movb %al, -0x33(%rbp)
je 0xcbb1d
movq -0x8(%rbp), %rax
movq 0x1ae8(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xcbd30
movb %al, -0x33(%rbp)
movb -0x33(%rbp), %al
andb $0x1, %al
movb %al, -0x31(%rbp)
testb $0x1, -0x31(%rbp)
je 0xcbb3c
movq -0x8(%rbp), %rax
movq 0x1ae8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xcbb44
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0xcbdc0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)