// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::ItemAdd(ImRect const&, unsigned int, ImRect const*)
bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;

    if (id != 0)
    {
        // Navigation processing runs prior to clipping early-out
        //  (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
        //  (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests
        //      unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of
        //      thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
        //      We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able
        //      to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
        // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
        // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
        window->DC.NavLayerActiveMaskNext |= (1 << window->DC.NavLayerCurrent);
        if (g.NavId == id || g.NavAnyRequest)
            if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
                if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
                    NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);

        // [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd()
#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
        if (id == g.DebugItemPickerBreakId)
        {
            IM_DEBUG_BREAK();
            g.DebugItemPickerBreakId = 0;
        }
#endif
    }

    // Equivalent to calling SetLastItemData()
    window->DC.LastItemId = id;
    window->DC.LastItemRect = bb;
    window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None;
    g.NextItemData.Flags = ImGuiNextItemDataFlags_None;

#ifdef IMGUI_ENABLE_TEST_ENGINE
    if (id != 0)
        IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id);
#endif

    // Clipping test
    const bool is_clipped = IsClippedEx(bb, id, false);
    if (is_clipped)
        return false;
    //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]

    // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
    if (IsMouseHoveringRect(bb.Min, bb.Max))
        window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq 0xa980a(%rip), %r12     # 0xfbcd0
movq 0x1ae0(%r12), %r13
testl %esi, %esi
je 0x5251a
movq %rdx, %r15
movl 0x14c(%r13), %ecx
movl $0x1, %eax
shll %cl, %eax
orl %eax, 0x154(%r13)
movl 0x1c98(%r12), %edx
cmpl %r14d, %edx
je 0x52502
cmpb $0x1, 0x1ce8(%r12)
jne 0x5251a
movq 0x1c90(%r12), %rax
movq 0x3a0(%rax), %rsi
cmpq 0x3a0(%r13), %rsi
je 0x52587
movl %r14d, 0x124(%r13)
movups (%rbx), %xmm0
movups %xmm0, 0x12c(%r13)
xorl %eax, %eax
movl %eax, 0x128(%r13)
movl %eax, 0x1bf8(%r12)
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x46579
movl %eax, %r14d
testb %al, %al
jne 0x52571
leaq 0x8(%rbx), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x4648c
testb %al, %al
je 0x52571
movl $0x1, 0x128(%r13)
xorb $0x1, %r14b
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %rax, %r13
je 0x52599
movl 0xc(%rax), %esi
orl 0xc(%r13), %esi
btl $0x17, %esi
jae 0x5251a
testq %r15, %r15
cmoveq %rbx, %r15
movl 0x1cc(%r13), %esi
movss (%r15), %xmm7
movss 0x4(%r15), %xmm0
movss 0x10(%r13), %xmm1
movss 0x14(%r13), %xmm2
subss %xmm1, %xmm7
subss %xmm2, %xmm0
unpcklps %xmm0, %xmm7            # xmm7 = xmm7[0],xmm0[0],xmm7[1],xmm0[1]
movss 0x8(%r15), %xmm8
movss 0xc(%r15), %xmm0
subss %xmm1, %xmm8
subss %xmm2, %xmm0
unpcklps %xmm0, %xmm8            # xmm8 = xmm8[0],xmm0[0],xmm8[1],xmm0[1]
cmpb $0x1, 0x1ce9(%r12)
jne 0x52662
cmpl %ecx, 0x1cdc(%r12)
jne 0x52662
testb $0x10, %sil
jne 0x52634
movl %r14d, 0x1cec(%r12)
movaps %xmm7, %xmm0
movlhps %xmm8, %xmm0            # xmm0 = xmm0[0],xmm8[0]
movups %xmm0, 0x1cf0(%r12)
movb $0x0, 0x1ce9(%r12)
cmpb $0x0, 0x1d00(%r12)
je 0x52659
movb $0x1, 0x1ce8(%r12)
jmp 0x52662
cmpl $0x0, 0x1cec(%r12)
jne 0x52662
movl %r14d, 0x1cec(%r12)
movaps %xmm7, %xmm0
movlhps %xmm8, %xmm0            # xmm0 = xmm0[0],xmm8[0]
movups %xmm0, 0x1cf0(%r12)
jmp 0x52662
movb $0x0, 0x1ce8(%r12)
cmpl %r14d, %edx
jne 0x52680
testb $0x10, 0x1d04(%r12)
je 0x52802
andl $0xc, %esi
je 0x5268a
jmp 0x52802
testb $0xc, %sil
jne 0x52802
leaq 0x1d80(%r12), %rdx
leaq 0x1d20(%r12), %rcx
cmpq %rax, %r13
cmoveq %rcx, %rdx
cmpb $0x1, 0x1d00(%r12)
jne 0x526fa
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movq %rdx, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movaps %xmm7, -0x50(%rbp)
movaps %xmm8, -0x40(%rbp)
callq 0x5c9b7
movq -0x30(%rbp), %rcx
movaps -0x40(%rbp), %xmm8
movaps -0x50(%rbp), %xmm7
testb %al, %al
je 0x526fa
movq %r13, (%rcx)
movl %r14d, 0x8(%rcx)
movl 0x158(%r13), %eax
movl %eax, 0xc(%rcx)
movaps %xmm7, %xmm0
movlhps %xmm8, %xmm0            # xmm0 = xmm0[0],xmm8[0]
movups %xmm0, 0x1c(%rcx)
testb $0x20, 0x1d04(%r12)
je 0x52802
movss 0x4(%r15), %xmm0
movss 0x264(%r13), %xmm2
ucomiss %xmm0, %xmm2
jbe 0x52802
movss 0xc(%r15), %xmm1
movss 0x25c(%r13), %xmm3
ucomiss %xmm3, %xmm1
jbe 0x52802
movss 0x260(%r13), %xmm4
ucomiss (%r15), %xmm4
jbe 0x52802
movss 0x8(%r15), %xmm4
ucomiss 0x258(%r13), %xmm4
jbe 0x52802
movaps %xmm2, %xmm4
minss %xmm1, %xmm4
movaps %xmm1, %xmm5
cmpltss %xmm3, %xmm5
movaps %xmm5, %xmm6
andnps %xmm4, %xmm6
andps %xmm3, %xmm5
orps %xmm6, %xmm5
minss %xmm0, %xmm2
subss %xmm0, %xmm1
cmpltss %xmm3, %xmm0
movaps %xmm0, %xmm4
andnps %xmm2, %xmm4
andps %xmm3, %xmm0
orps %xmm4, %xmm0
subss %xmm0, %xmm5
mulss 0x63134(%rip), %xmm1    # 0xb58d4
ucomiss %xmm1, %xmm5
jb 0x52802
leaq 0x1d50(%r12), %rdi
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movaps %xmm7, -0x50(%rbp)
movaps %xmm8, -0x40(%rbp)
callq 0x5c9b7
movaps -0x40(%rbp), %xmm8
movaps -0x50(%rbp), %xmm7
testb %al, %al
je 0x52802
movq %r13, 0x1d50(%r12)
movl %r14d, 0x1d58(%r12)
movl 0x158(%r13), %eax
movl %eax, 0x1d5c(%r12)
movaps %xmm7, %xmm0
movlhps %xmm8, %xmm0            # xmm0 = xmm0[0],xmm8[0]
movups %xmm0, 0x1d6c(%r12)
cmpl %r14d, 0x1c98(%r12)
jne 0x5251a
movq %r13, 0x1c90(%r12)
movl 0x14c(%r13), %eax
movl %eax, 0x1cdc(%r12)
movl 0x158(%r13), %ecx
movl %ecx, 0x1c9c(%r12)
movb $0x1, 0x1ce4(%r12)
movl 0x1c8(%r13), %ecx
movl %ecx, 0x1ce0(%r12)
shlq $0x4, %rax
movlhps %xmm8, %xmm7            # xmm7 = xmm7[0],xmm8[0]
movups %xmm7, 0x3b8(%r13,%rax)
jmp 0x5251a