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

    // Pressing TAB activate widget focus
    g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab));
    if (g.ActiveId == 0 && g.FocusTabPressed)
    {
        // Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
        // manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
        g.FocusRequestNextWindow = g.NavWindow;
        g.FocusRequestNextCounterRegular = INT_MAX;
        if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
            g.FocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
        else
            g.FocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0;
    }

    // Turn queued focus request into current one
    g.FocusRequestCurrWindow = NULL;
    g.FocusRequestCurrCounterRegular = g.FocusRequestCurrCounterTabStop = INT_MAX;
    if (g.FocusRequestNextWindow != NULL)
    {
        ImGuiWindow* window = g.FocusRequestNextWindow;
        g.FocusRequestCurrWindow = window;
        if (g.FocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1)
            g.FocusRequestCurrCounterRegular = ImModPositive(g.FocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1);
        if (g.FocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1)
            g.FocusRequestCurrCounterTabStop = ImModPositive(g.FocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1);
        g.FocusRequestNextWindow = NULL;
        g.FocusRequestNextCounterRegular = g.FocusRequestNextCounterTabStop = INT_MAX;
    }

    g.NavIdTabCounter = INT_MAX;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq 0x1432d1(%rip), %rax    # 0x212f40
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x1c90(%rcx)
movb %al, -0x11(%rbp)
je 0xcfcde
movq -0x8(%rbp), %rax
movq 0x1c90(%rax), %rcx
xorl %eax, %eax
testb $0x1, 0x8e(%rcx)
movb %al, -0x11(%rbp)
je 0xcfcde
movq -0x8(%rbp), %rax
movq 0x1c90(%rax), %rax
movl 0xc(%rax), %ecx
andl $0x40000, %ecx          # imm = 0x40000
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x11(%rbp)
jne 0xcfcde
movq -0x8(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x140(%rcx)
movb %al, -0x11(%rbp)
jne 0xcfcde
xorl %edi, %edi
movl $0x1, %esi
callq 0xedee0
movb %al, -0x11(%rbp)
movb -0x11(%rbp), %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x1e08(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1b30(%rax)
jne 0xcfdab
movq -0x8(%rbp), %rax
testb $0x1, 0x1e08(%rax)
je 0xcfdab
movq -0x8(%rbp), %rax
movq 0x1c90(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1df0(%rax)
movq -0x8(%rbp), %rax
movl $0x7fffffff, 0x1e00(%rax) # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c98(%rax)
je 0xcfd88
movq -0x8(%rbp), %rax
cmpl $0x7fffffff, 0x1ce0(%rax) # imm = 0x7FFFFFFF
je 0xcfd88
movq -0x8(%rbp), %rax
movl 0x1ce0(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movb 0x141(%rax), %sil
movl $0x1, %eax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testb $0x1, %sil
cmovnel %edx, %eax
addl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1e04(%rax)
jmp 0xcfda9
movq -0x8(%rbp), %rax
movb 0x141(%rax), %dl
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1e04(%rax)
jmp 0xcfdab
movq -0x8(%rbp), %rax
movq $0x0, 0x1de8(%rax)
movq -0x8(%rbp), %rax
movl $0x7fffffff, 0x1dfc(%rax) # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movl $0x7fffffff, 0x1df8(%rax) # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1df0(%rax)
je 0xcfebb
movq -0x8(%rbp), %rax
movq 0x1df0(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1de8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x7fffffff, 0x1e00(%rax) # imm = 0x7FFFFFFF
je 0xcfe4b
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x1c4(%rax)
je 0xcfe4b
movq -0x8(%rbp), %rax
movl 0x1e00(%rax), %edi
movq -0x10(%rbp), %rax
movl 0x1c4(%rax), %esi
addl $0x1, %esi
callq 0xe5440
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1df8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x7fffffff, 0x1e04(%rax) # imm = 0x7FFFFFFF
je 0xcfe90
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x1c8(%rax)
je 0xcfe90
movq -0x8(%rbp), %rax
movl 0x1e04(%rax), %edi
movq -0x10(%rbp), %rax
movl 0x1c8(%rax), %esi
addl $0x1, %esi
callq 0xe5440
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1dfc(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x1df0(%rax)
movq -0x8(%rbp), %rax
movl $0x7fffffff, 0x1e04(%rax) # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movl $0x7fffffff, 0x1e00(%rax) # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movl $0x7fffffff, 0x1ce0(%rax) # imm = 0x7FFFFFFF
addq $0x20, %rsp
popq %rbp
retq
nop