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

    // Find the window hovered by mouse:
    // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow.
    // - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
    // - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
    bool clear_hovered_windows = false;
    FindHoveredWindow();

    // Modal windows prevents mouse from hovering behind them.
    ImGuiWindow* modal_window = GetTopMostPopupModal();
    if (modal_window && g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window))
        clear_hovered_windows = true;

    // Disabled mouse?
    if (g.IO.ConfigFlags & ImGuiConfigFlags_NoMouse)
        clear_hovered_windows = true;

    // We track click ownership. When clicked outside of a window the click is owned by the application and won't report hovering nor request capture even while dragging over our windows afterward.
    int mouse_earliest_button_down = -1;
    bool mouse_any_down = false;
    for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
    {
        if (g.IO.MouseClicked[i])
            g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (g.OpenPopupStack.Size > 0);
        mouse_any_down |= g.IO.MouseDown[i];
        if (g.IO.MouseDown[i])
            if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down])
                mouse_earliest_button_down = i;
    }
    const bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down];

    // If mouse was first clicked outside of ImGui bounds we also cancel out hovering.
    // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02)
    const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0;
    if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload)
        clear_hovered_windows = true;

    if (clear_hovered_windows)
        g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;

    // Update io.WantCaptureMouse for the user application (true = dispatch mouse info to imgui, false = dispatch mouse info to Dear ImGui + app)
    if (g.WantCaptureMouseNextFrame != -1)
        g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0);
    else
        g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (g.OpenPopupStack.Size > 0);

    // Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to imgui, false = dispatch keyboard info to Dear ImGui + app)
    if (g.WantCaptureKeyboardNextFrame != -1)
        g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
    else
        g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
    if (g.IO.NavActive && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
        g.IO.WantCaptureKeyboard = true;

    // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible
    g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq 0x146ff1(%rip), %rax    # 0x212f40
movq %rax, -0x8(%rbp)
movb $0x0, -0x9(%rbp)
callq 0xcc270
callq 0xcbca0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xcbf96
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1af0(%rax)
je 0xcbf96
movq -0x8(%rbp), %rax
movq 0x1af0(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xcc5a0
testb $0x1, %al
jne 0xcbf96
movb $0x1, -0x9(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xcbfa9
movb $0x1, -0x9(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movb $0x0, -0x1d(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x5, -0x24(%rbp)
jge 0xcc091
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
testb $0x1, 0x420(%rax,%rcx)
je 0xcc010
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x1ae8(%rcx)
movb %al, -0x27(%rbp)
jne 0xcbffb
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c70(%rax)
setg %al
movb %al, -0x27(%rbp)
movb -0x27(%rbp), %dl
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
andb $0x1, %dl
movb %dl, 0x42f(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb 0x130(%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %ecx
movb -0x1d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
orl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
testb $0x1, 0x130(%rax,%rcx)
je 0xcc081
cmpl $-0x1, -0x1c(%rbp)
je 0xcc079
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsd 0x3f8(%rax,%rcx,8), %xmm1
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd 0x3f8(%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xcc07f
movl -0x24(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0xcc081
jmp 0xcc083
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xcbfbb
movb $0x1, %al
cmpl $-0x1, -0x1c(%rbp)
movb %al, -0x28(%rbp)
je 0xcc0ae
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb 0x42f(%rax,%rcx), %al
movb %al, -0x28(%rbp)
movb -0x28(%rbp), %al
andb $0x1, %al
movb %al, -0x25(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x2004(%rcx)
movb %al, -0x29(%rbp)
je 0xcc0de
movq -0x8(%rbp), %rax
movl 0x2008(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x26(%rbp)
testb $0x1, -0x25(%rbp)
jne 0xcc0f6
testb $0x1, -0x26(%rbp)
jne 0xcc0f6
movb $0x1, -0x9(%rbp)
testb $0x1, -0x9(%rbp)
je 0xcc129
movq -0x8(%rbp), %rax
movq $0x0, 0x1af8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x1af0(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x1ae8(%rax)
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x336c(%rax)
je 0xcc153
movq -0x8(%rbp), %rax
cmpl $0x0, 0x336c(%rax)
setne %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x398(%rax)
jmp 0xcc198
testb $0x1, -0x25(%rbp)
je 0xcc177
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x1ae8(%rcx)
movb %al, -0x2a(%rbp)
jne 0xcc188
movb $0x1, %al
testb $0x1, -0x1d(%rbp)
movb %al, -0x2a(%rbp)
jne 0xcc188
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c70(%rax)
setg %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x398(%rax)
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x3370(%rax)
je 0xcc1c2
movq -0x8(%rbp), %rax
cmpl $0x0, 0x3370(%rax)
setne %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x399(%rax)
jmp 0xcc1ef
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x1b30(%rcx)
movb %al, -0x2b(%rbp)
jne 0xcc1df
cmpq $0x0, -0x18(%rbp)
setne %al
movb %al, -0x2b(%rbp)
movb -0x2b(%rbp), %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x399(%rax)
movq -0x8(%rbp), %rax
testb $0x1, 0x39d(%rax)
je 0xcc225
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xcc225
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xcc225
movq -0x8(%rbp), %rax
movb $0x1, 0x399(%rax)
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x3374(%rax)
je 0xcc245
movq -0x8(%rbp), %rax
cmpl $0x0, 0x3374(%rax)
setne %al
movb %al, -0x2c(%rbp)
jmp 0xcc24c
xorl %eax, %eax
movb %al, -0x2c(%rbp)
jmp 0xcc24c
movb -0x2c(%rbp), %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x39a(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)