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

    if (g.NavWindow != window)
    {
        g.NavWindow = window;
        if (window && g.NavDisableMouseHover)
            g.NavMousePosDirty = true;
        g.NavInitRequest = false;
        g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
        g.NavFocusScopeId = 0;
        g.NavIdIsAlive = false;
        g.NavLayer = ImGuiNavLayer_Main;
        //IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
    }

    // Close popups if any
    ClosePopupsOverWindow(window, false);

    // Move the root window to the top of the pile
    IM_ASSERT(window == NULL || window->RootWindow != NULL);
    ImGuiWindow* focus_front_window = window ? window->RootWindow : NULL; // NB: In docking branch this is window->RootWindowDockStop
    ImGuiWindow* display_front_window = window ? window->RootWindow : NULL;

    // Steal active widgets. Some of the cases it triggers includes:
    // - Focus a window while an InputText in another window is active, if focus happens before the old InputText can run.
    // - When using Nav to activate menu items (due to timing of activating on press->new window appears->losing ActiveId)
    if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window)
        if (!g.ActiveIdNoClearOnFocusLoss)
            ClearActiveID();

    // Passing NULL allow to disable keyboard focus
    if (!window)
        return;

    // Bring to front
    BringWindowToFocusFront(focus_front_window);
    if (((window->Flags | display_front_window->Flags) & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0)
        BringWindowToDisplayFront(display_front_window);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0xb5f20(%rip), %r12     # 0xfdcd0
cmpq %rdi, 0x1c90(%r12)
je 0x47e1a
movq %rbx, 0x1c90(%r12)
testq %rbx, %rbx
je 0x47dec
cmpb $0x1, 0x1ce7(%r12)
jne 0x47ddb
movb $0x1, 0x1ce5(%r12)
movb $0x0, 0x1ce9(%r12)
movl 0x3b0(%rbx), %eax
jmp 0x47df7
movb $0x0, 0x1ce9(%r12)
xorl %eax, %eax
movl %eax, 0x1c98(%r12)
xorl %eax, %eax
movl %eax, 0x1c9c(%r12)
movb $0x0, 0x1ce4(%r12)
movl %eax, 0x1cdc(%r12)
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4853f
testq %rbx, %rbx
je 0x47e4b
cmpq $0x0, 0x390(%rbx)
je 0x47ec4
testq %rbx, %rbx
je 0x47e48
movq 0x390(%rbx), %r14
jmp 0x47e4b
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x47e59
movq 0x390(%rbx), %r15
jmp 0x47e5c
xorl %r15d, %r15d
cmpl $0x0, 0x1b30(%r12)
je 0x47e91
movq 0x1b60(%r12), %rax
testq %rax, %rax
je 0x47e91
cmpq %r14, 0x390(%rax)
je 0x47e91
cmpb $0x0, 0x1b3e(%r12)
jne 0x47e91
xorl %edi, %edi
xorl %esi, %esi
callq 0x46b95
testq %rbx, %rbx
je 0x47ebb
movq %r14, %rdi
callq 0x549a4
movl 0xc(%r15), %eax
orl 0xc(%rbx), %eax
btl $0xd, %eax
jb 0x47ebb
movq %r15, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x54a6d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7148c(%rip), %rdi     # 0xb9357
leaq 0x70293(%rip), %rsi     # 0xb8165
leaq 0x714af(%rip), %rcx     # 0xb9388
movl $0x1889, %edx           # imm = 0x1889
callq 0xc140