// File: /workspace/github_cpp_makefile_star2_O1/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 0xaa843(%rip), %r12     # 0xfdcd0
movq 0x1ae0(%r12), %r13
testl %esi, %esi
je 0x534de
movq %rdx, %r15
movl 0x14c(%r13), %ecx
movl $0x1, %eax
shll %cl, %eax
orl %eax, 0x154(%r13)
cmpl %r14d, 0x1c98(%r12)
je 0x534c6
cmpb $0x1, 0x1ce8(%r12)
jne 0x534de
movq 0x1c90(%r12), %rax
movq 0x3a0(%rax), %rdx
cmpq 0x3a0(%r13), %rdx
je 0x5354b
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 0x4709d
movl %eax, %r14d
testb %al, %al
jne 0x53535
leaq 0x8(%rbx), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x46fad
testb %al, %al
je 0x53535
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 0x5355d
movl 0xc(%rax), %eax
orl 0xc(%r13), %eax
btl $0x17, %eax
jae 0x534de
testq %r15, %r15
cmoveq %rbx, %r15
movl 0x1cc(%r13), %eax
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
subss %xmm1, %xmm8
movss 0xc(%r15), %xmm0
subss %xmm2, %xmm0
unpcklps %xmm0, %xmm8            # xmm8 = xmm8[0],xmm0[0],xmm8[1],xmm0[1]
cmpb $0x1, 0x1ce9(%r12)
jne 0x5363a
cmpl %ecx, 0x1cdc(%r12)
jne 0x5363a
testb $0x10, %al
je 0x535ce
cmpl $0x0, 0x1cec(%r12)
jne 0x535e6
movl %r14d, 0x1cec(%r12)
movaps %xmm7, %xmm0
movlhps %xmm8, %xmm0            # xmm0 = xmm0[0],xmm8[0]
movups %xmm0, 0x1cf0(%r12)
testb $0x10, %al
jne 0x5363a
movb $0x0, 0x1ce9(%r12)
cmpb $0x0, 0x1d00(%r12)
je 0x53631
movb $0x1, 0x1ce8(%r12)
cmpq $0x0, 0x1c90(%r12)
jne 0x5363a
leaq 0x68c2b(%rip), %rdi     # 0xbc244
leaq 0x64b45(%rip), %rsi     # 0xb8165
leaq 0x68c33(%rip), %rcx     # 0xbc25a
movl $0x2200, %edx           # imm = 0x2200
callq 0xc140
movb $0x0, 0x1ce8(%r12)
cmpl %r14d, 0x1c98(%r12)
jne 0x5365d
testb $0x10, 0x1d04(%r12)
je 0x537e2
andl $0xc, %eax
je 0x53665
jmp 0x537e2
testb $0xc, %al
jne 0x537e2
leaq 0x1d80(%r12), %rcx
leaq 0x1d20(%r12), %rax
cmpq %r13, 0x1c90(%r12)
cmoveq %rax, %rcx
cmpb $0x1, 0x1d00(%r12)
jne 0x536da
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movaps %xmm7, -0x50(%rbp)
movaps %xmm8, -0x40(%rbp)
callq 0x5db49
movq -0x30(%rbp), %rcx
movaps -0x40(%rbp), %xmm8
movaps -0x50(%rbp), %xmm7
testb %al, %al
je 0x536da
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 0x537e2
movss 0x4(%r15), %xmm0
movss 0x264(%r13), %xmm2
ucomiss %xmm0, %xmm2
jbe 0x537e2
movss 0xc(%r15), %xmm1
movss 0x25c(%r13), %xmm3
ucomiss %xmm3, %xmm1
jbe 0x537e2
movss 0x260(%r13), %xmm4
ucomiss (%r15), %xmm4
jbe 0x537e2
movss 0x8(%r15), %xmm4
ucomiss 0x258(%r13), %xmm4
jbe 0x537e2
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 0x64154(%rip), %xmm1    # 0xb78d4
ucomiss %xmm1, %xmm5
jb 0x537e2
leaq 0x1d50(%r12), %rdi
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movaps %xmm7, -0x50(%rbp)
movaps %xmm8, -0x40(%rbp)
callq 0x5db49
movaps -0x40(%rbp), %xmm8
movaps -0x50(%rbp), %xmm7
testb %al, %al
je 0x537e2
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 0x534de
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 0x534de