// File: /workspace/github_cpp_makefile_star2_O2/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 $0x18, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq 0xa2e1d(%rip), %r12     # 0xe3ce0
movq 0x1ae0(%r12), %r13
testl %esi, %esi
je 0x40f15
movq %rdx, %r15
movl 0x14c(%r13), %ecx
pushq $0x1
popq %rax
shll %cl, %eax
orl %eax, 0x154(%r13)
movl 0x1c98(%r12), %eax
cmpl %r14d, %eax
je 0x40efd
cmpb $0x1, 0x1ce8(%r12)
jne 0x40f15
movq 0x1c90(%r12), %rdx
movq 0x3a0(%rdx), %rsi
cmpq 0x3a0(%r13), %rsi
je 0x40f7d
movl %r14d, 0x124(%r13)
movups (%rbx), %xmm0
movups %xmm0, 0x12c(%r13)
andl $0x0, 0x128(%r13)
andl $0x0, 0x1bf8(%r12)
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x37840
movl %eax, %r14d
testb %al, %al
jne 0x40f67
leaq 0x8(%rbx), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x37779
testb %al, %al
je 0x40f67
orb $0x1, 0x128(%r13)
xorb $0x1, %r14b
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %rdx, %r13
je 0x40f8f
movl 0xc(%rdx), %edx
orl 0xc(%r13), %edx
btl $0x17, %edx
jae 0x40f15
testq %r15, %r15
cmoveq %rbx, %r15
movl 0x1cc(%r13), %edx
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), %xmm0
subss %xmm1, %xmm0
movss 0xc(%r15), %xmm1
subss %xmm2, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movlhps %xmm0, %xmm7            # xmm7 = xmm7[0],xmm0[0]
cmpb $0x1, 0x1ce9(%r12)
jne 0x41046
cmpl %ecx, 0x1cdc(%r12)
jne 0x41046
testb $0x10, %dl
jne 0x4102a
movl %r14d, 0x1cec(%r12)
movups %xmm7, 0x1cf0(%r12)
movb $0x0, 0x1ce9(%r12)
movaps %xmm7, -0x40(%rbp)
movl %edx, -0x30(%rbp)
callq 0x42d8a
movl -0x30(%rbp), %edx
movaps -0x40(%rbp), %xmm7
movl 0x1c98(%r12), %eax
jmp 0x41046
cmpl $0x0, 0x1cec(%r12)
jne 0x41046
movl %r14d, 0x1cec(%r12)
movups %xmm7, 0x1cf0(%r12)
cmpl %r14d, %eax
jne 0x41064
testb $0x10, 0x1d04(%r12)
je 0x411a6
andl $0xc, %edx
je 0x4106d
jmp 0x411a6
testb $0xc, %dl
jne 0x411a6
leaq 0x1d80(%r12), %rcx
leaq 0x1d20(%r12), %rax
cmpq %r13, 0x1c90(%r12)
cmoveq %rax, %rcx
cmpb $0x1, 0x1d00(%r12)
movaps %xmm7, -0x40(%rbp)
jne 0x410d1
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4944b
movq -0x30(%rbp), %rcx
movaps -0x40(%rbp), %xmm7
testb %al, %al
je 0x410d1
movq %r13, (%rcx)
movl %r14d, 0x8(%rcx)
movl 0x158(%r13), %eax
movl %eax, 0xc(%rcx)
movups %xmm7, 0x1c(%rcx)
testb $0x20, 0x1d04(%r12)
je 0x411a6
leaq 0x258(%r13), %rdi
movq %r15, %rsi
callq 0x4a2f6
movaps -0x40(%rbp), %xmm7
testb %al, %al
je 0x411a6
movss 0x4(%r15), %xmm0
movss 0xc(%r15), %xmm1
movss 0x25c(%r13), %xmm2
movss 0x264(%r13), %xmm3
movaps %xmm3, %xmm4
minss %xmm1, %xmm4
movaps %xmm1, %xmm5
cmpltss %xmm2, %xmm5
movaps %xmm5, %xmm6
andnps %xmm4, %xmm6
andps %xmm2, %xmm5
orps %xmm6, %xmm5
minss %xmm0, %xmm3
subss %xmm0, %xmm1
cmpltss %xmm2, %xmm0
movaps %xmm0, %xmm4
andnps %xmm3, %xmm4
andps %xmm2, %xmm0
orps %xmm4, %xmm0
subss %xmm0, %xmm5
mulss 0x5b7ab(%rip), %xmm1    # 0x9c904
ucomiss %xmm1, %xmm5
jb 0x411a6
leaq 0x1d50(%r12), %rdi
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
callq 0x4944b
movaps -0x40(%rbp), %xmm7
testb %al, %al
je 0x411a6
movq %r13, 0x1d50(%r12)
movl %r14d, 0x1d58(%r12)
movl 0x158(%r13), %eax
movl %eax, 0x1d5c(%r12)
movups %xmm7, 0x1d6c(%r12)
cmpl %r14d, 0x1c98(%r12)
jne 0x40f15
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
movups %xmm7, 0x3b8(%r13,%rax)
jmp 0x40f15