// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::FocusableItemRegister(ImGuiWindow*, unsigned int)
bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
{
    ImGuiContext& g = *GImGui;

    // Increment counters
    const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
    window->DC.FocusCounterRegular++;
    if (is_tab_stop)
        window->DC.FocusCounterTabStop++;

    // Process TAB/Shift-TAB to tab *OUT* of the currently focused item.
    // (Note that we can always TAB out of a widget that doesn't allow tabbing in)
    if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL)
    {
        g.FocusRequestNextWindow = window;
        g.FocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
    }

    // Handle focus requests
    if (g.FocusRequestCurrWindow == window)
    {
        if (window->DC.FocusCounterRegular == g.FocusRequestCurrCounterRegular)
            return true;
        if (is_tab_stop && window->DC.FocusCounterTabStop == g.FocusRequestCurrCounterTabStop)
        {
            g.NavJustTabbedId = id;
            return true;
        }

        // If another item is about to be focused, we clear our own active id
        if (g.ActiveId == id)
            ClearActiveID();
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq 0x14875a(%rip), %rax    # 0x212f40
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x1cc(%rax), %eax
andl $0x5, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c4(%rax)
testb $0x1, -0x21(%rbp)
je 0xca82e
movq -0x10(%rbp), %rax
movl 0x1c8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c8(%rax)
movq -0x20(%rbp), %rax
movl 0x1b30(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0xca8c1
movq -0x20(%rbp), %rax
testb $0x1, 0x1e08(%rax)
je 0xca8c1
xorl %edi, %edi
callq 0xe94a0
testb $0x1, %al
jne 0xca8c1
movq -0x20(%rbp), %rax
cmpq $0x0, 0x1df0(%rax)
jne 0xca8c1
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x1df0(%rax)
movq -0x10(%rbp), %rax
movl 0x1c8(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x141(%rax)
je 0xca8a5
movb -0x21(%rbp), %dl
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0xca8af
movl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xca8af
movl -0x28(%rbp), %ecx
movl -0x2c(%rbp), %eax
addl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1e04(%rax)
movq -0x20(%rbp), %rax
movq 0x1de8(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0xca933
movq -0x10(%rbp), %rax
movl 0x1c4(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1df8(%rcx), %eax
jne 0xca8ee
movb $0x1, -0x1(%rbp)
jmp 0xca937
testb $0x1, -0x21(%rbp)
je 0xca91d
movq -0x10(%rbp), %rax
movl 0x1c8(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1dfc(%rcx), %eax
jne 0xca91d
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1cb0(%rax)
movb $0x1, -0x1(%rbp)
jmp 0xca937
movq -0x20(%rbp), %rax
movl 0x1b30(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0xca931
callq 0xca040
jmp 0xca933
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)