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

    ImGuiWindow* hovered_window = NULL;
    ImGuiWindow* hovered_window_ignoring_moving_window = NULL;
    if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs))
        hovered_window = g.MovingWindow;

    ImVec2 padding_regular = g.Style.TouchExtraPadding;
    ImVec2 padding_for_resize_from_edges = g.IO.ConfigWindowsResizeFromEdges ? ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS)) : padding_regular;
    for (int i = g.Windows.Size - 1; i >= 0; i--)
    {
        ImGuiWindow* window = g.Windows[i];
        if (!window->Active || window->Hidden)
            continue;
        if (window->Flags & ImGuiWindowFlags_NoMouseInputs)
            continue;

        // Using the clipped AABB, a child window will typically be clipped by its parent (not always)
        ImRect bb(window->OuterRectClipped);
        if (window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize))
            bb.Expand(padding_regular);
        else
            bb.Expand(padding_for_resize_from_edges);
        if (!bb.Contains(g.IO.MousePos))
            continue;

        // Support for one rectangular hole in any given window
        // FIXME: Consider generalizing hit-testing override (with more generic data, callback, etc.) (#1512)
        if (window->HitTestHoleSize.x != 0)
        {
            ImVec2 hole_pos(window->Pos.x + (float)window->HitTestHoleOffset.x, window->Pos.y + (float)window->HitTestHoleOffset.y);
            ImVec2 hole_size((float)window->HitTestHoleSize.x, (float)window->HitTestHoleSize.y);
            if (ImRect(hole_pos, hole_pos + hole_size).Contains(g.IO.MousePos))
                continue;
        }

        if (hovered_window == NULL)
            hovered_window = window;
        if (hovered_window_ignoring_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow))
            hovered_window_ignoring_moving_window = window;
        if (hovered_window && hovered_window_ignoring_moving_window)
            break;
    }

    g.HoveredWindow = hovered_window;
    g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
    g.HoveredWindowUnderMovingWindow = hovered_window_ignoring_moving_window;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x146cbe(%rip), %rax    # 0x212f40
movq %rax, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1b00(%rax)
je 0xcc2cb
movq -0x8(%rbp), %rax
movq 0x1b00(%rax), %rax
movl 0xc(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0xcc2cb
movq -0x8(%rbp), %rax
movq 0x1b00(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x15c0(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0xcc(%rax)
je 0xcc327
movq -0x8(%rbp), %rax
addq $0x15c0, %rax           # imm = 0x15C0
movq %rax, -0x88(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x80(%rbp)
movss 0xa642c(%rip), %xmm1    # 0x172734
movaps %xmm1, %xmm0
callq 0xbf4c0
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0xd7960
movlpd %xmm0, -0x28(%rbp)
jmp 0xcc32f
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x1a88(%rax), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0xcc530
movq -0x8(%rbp), %rdi
addq $0x1a88, %rdi           # imm = 0x1A88
movl -0x34(%rbp), %esi
callq 0xea8d0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
testb $0x1, 0x8e(%rax)
je 0xcc37d
movq -0x40(%rbp), %rax
testb $0x1, 0x95(%rax)
je 0xcc382
jmp 0xcc522
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0xcc398
jmp 0xcc522
movq -0x40(%rbp), %rax
movq 0x208(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x210(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1000042, %eax        # imm = 0x1000042
cmpl $0x0, %eax
je 0xcc3d2
leaq -0x50(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xe89d0
jmp 0xcc3df
leaq -0x50(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xe89d0
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
addq $0x120, %rsi            # imm = 0x120
leaq -0x50(%rbp), %rdi
callq 0xea710
testb $0x1, %al
jne 0xcc400
jmp 0xcc522
movq -0x40(%rbp), %rax
movswl 0x278(%rax), %eax
cmpl $0x0, %eax
je 0xcc4c5
movq -0x40(%rbp), %rax
movswl 0x27c(%rax), %ecx
cvtsi2ss %ecx, %xmm2
movss 0x10(%rax), %xmm0
movss 0x14(%rax), %xmm1
addss %xmm2, %xmm0
movswl 0x27e(%rax), %eax
cvtsi2ss %eax, %xmm2
addss %xmm2, %xmm1
leaq -0x58(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0xbf4c0
movq -0x40(%rbp), %rax
movswl 0x278(%rax), %ecx
cvtsi2ss %ecx, %xmm0
movswl 0x27a(%rax), %eax
cvtsi2ss %eax, %xmm1
leaq -0x60(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0xbf4c0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0xc41b0
movlpd %xmm0, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0xe8660
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
addq $0x120, %rsi            # imm = 0x120
leaq -0x70(%rbp), %rdi
callq 0xea710
testb $0x1, %al
jne 0xcc4c1
jmp 0xcc4c3
jmp 0xcc522
jmp 0xcc4c5
cmpq $0x0, -0x10(%rbp)
jne 0xcc4d4
movq -0x40(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xcc510
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1b00(%rax)
je 0xcc508
movq -0x40(%rbp), %rax
movq 0x390(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x1b00(%rcx), %rcx
cmpq 0x390(%rcx), %rax
je 0xcc510
movq -0x40(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xcc520
cmpq $0x0, -0x18(%rbp)
je 0xcc520
jmp 0xcc530
jmp 0xcc522
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xcc33f
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1ae8(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1ae8(%rax)
je 0xcc568
movq -0x8(%rbp), %rax
movq 0x1ae8(%rax), %rax
movq 0x390(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0xcc573
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
jmp 0xcc573
movq -0xa0(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1af0(%rax)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1af8(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)