// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::BeginDragDropSource(int)
bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;

    bool source_drag_active = false;
    ImGuiID source_id = 0;
    ImGuiID source_parent_id = 0;
    ImGuiMouseButton mouse_button = ImGuiMouseButton_Left;
    if (!(flags & ImGuiDragDropFlags_SourceExtern))
    {
        source_id = window->DC.LastItemId;
        if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case
            return false;
        if (g.IO.MouseDown[mouse_button] == false)
            return false;

        if (source_id == 0)
        {
            // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
            // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
            if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
            {
                IM_ASSERT(0);
                return false;
            }

            // Early out
            if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window))
                return false;

            // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
            // We build a throwaway ID based on current ID stack + relative AABB of items in window.
            // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
            // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
            source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect);
            bool is_hovered = ItemHoverable(window->DC.LastItemRect, source_id);
            if (is_hovered && g.IO.MouseClicked[mouse_button])
            {
                SetActiveID(source_id, window);
                FocusWindow(window);
            }
            if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker.
                g.ActiveIdAllowOverlap = is_hovered;
        }
        else
        {
            g.ActiveIdAllowOverlap = false;
        }
        if (g.ActiveId != source_id)
            return false;
        source_parent_id = window->IDStack.back();
        source_drag_active = IsMouseDragging(mouse_button);

        // Disable navigation and key inputs while dragging
        g.ActiveIdUsingNavDirMask = ~(ImU32)0;
        g.ActiveIdUsingNavInputMask = ~(ImU32)0;
        g.ActiveIdUsingKeyInputMask = ~(ImU64)0;
    }
    else
    {
        window = NULL;
        source_id = ImHashStr("#SourceExtern");
        source_drag_active = true;
    }

    if (source_drag_active)
    {
        if (!g.DragDropActive)
        {
            IM_ASSERT(source_id != 0);
            ClearDragDrop();
            ImGuiPayload& payload = g.DragDropPayload;
            payload.SourceId = source_id;
            payload.SourceParentId = source_parent_id;
            g.DragDropActive = true;
            g.DragDropSourceFlags = flags;
            g.DragDropMouseButton = mouse_button;
            if (payload.SourceId == g.ActiveId)
                g.ActiveIdNoClearOnFocusLoss = true;
        }
        g.DragDropSourceFrameCount = g.FrameCount;
        g.DragDropWithinSource = true;

        if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
        {
            // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
            // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
            BeginTooltip();
            if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
            {
                ImGuiWindow* tooltip_window = g.CurrentWindow;
                tooltip_window->SkipItems = true;
                tooltip_window->HiddenFramesCanSkipItems = 1;
            }
        }

        if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
            window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;

        return true;
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x9e334(%rip), %r13     # 0xe3ce0
testb $0x10, %bl
jne 0x459eb
movq 0x1ae0(%r13), %r14
movl 0x124(%r14), %r15d
testl %r15d, %r15d
je 0x45abc
cmpl %r15d, 0x1b30(%r13)
jne 0x45b9d
xorl %r12d, %r12d
cmpb $0x0, 0x130(%r13)
jne 0x45b57
jmp 0x45ba0
leaq 0x59a9e(%rip), %rdi     # 0x9f490
movq $0x0, -0x30(%rbp)
xorl %esi, %esi
xorl %edx, %edx
callq 0x3479a
movl %eax, %r15d
xorl %r14d, %r14d
cmpb $0x0, 0x2004(%r13)
jne 0x45a57
testl %r15d, %r15d
je 0x45bb2
callq 0x3fab3
movl %r15d, 0x2024(%r13)
movl %r14d, 0x2028(%r13)
movb $0x1, 0x2004(%r13)
movl %ebx, 0x2008(%r13)
andl $0x0, 0x2010(%r13)
cmpl 0x1b30(%r13), %r15d
jne 0x45a57
movb $0x1, 0x1b3e(%r13)
movl 0x1a68(%r13), %eax
movl %eax, 0x200c(%r13)
movb $0x1, 0x2005(%r13)
testb $0x1, %bl
jne 0x45aa0
callq 0x44503
cmpl $0x0, 0x2078(%r13)
je 0x45aa0
testb $0x10, 0x206d(%r13)
je 0x45aa0
movq 0x1ae0(%r13), %rax
movb $0x1, %cl
movb %cl, 0x93(%rax)
movb %cl, 0xac(%rax)
movb $0x1, %r12b
testb $0x12, %bl
jne 0x45ba0
movq -0x30(%rbp), %rax
andb $-0x2, 0x128(%rax)
jmp 0x45ba0
cmpb $0x0, 0x130(%r13)
je 0x45b9d
testb $0x8, %bl
je 0x45bd1
testb $0x1, 0x128(%r14)
jne 0x45af8
cmpl $0x0, 0x1b30(%r13)
je 0x45b9d
cmpq %r14, 0x1b60(%r13)
jne 0x45b9d
leaq 0x12c(%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x37226
movl %eax, %r15d
movq %r14, -0x30(%rbp)
movl %eax, 0x124(%r14)
movq %r12, %rdi
movl %eax, %esi
callq 0x37658
movl %eax, %r12d
testb %al, %al
je 0x45b4a
cmpb $0x1, 0x420(%r13)
jne 0x45b4a
movl %r15d, %edi
movq -0x30(%rbp), %r14
movq %r14, %rsi
callq 0x3739b
movq %r14, %rdi
callq 0x37fa1
cmpl %r15d, 0x1b30(%r13)
movq -0x30(%rbp), %r14
jne 0x45b9d
movb %r12b, 0x1b3d(%r13)
movq %r14, -0x30(%rbp)
leaq 0xc8(%r14), %rdi
callq 0x4a148
movl (%rax), %r14d
xorl %r12d, %r12d
movss 0x56474(%rip), %xmm0    # 0x9bff0
xorl %edi, %edi
callq 0x40317
orq $-0x1, 0x1b44(%r13)
orq $-0x1, 0x1b50(%r13)
testb %al, %al
jne 0x45a09
jmp 0x45ba0
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x598e5(%rip), %rdi     # 0x9f49e
leaq 0x575d5(%rip), %rsi     # 0x9d195
leaq 0x59895(%rip), %rcx     # 0x9f45c
movl $0x2577, %edx           # imm = 0x2577
callq 0xc140
leaq 0x59544(%rip), %rdi     # 0x9f11c
leaq 0x575b6(%rip), %rsi     # 0x9d195
leaq 0x59876(%rip), %rcx     # 0x9f45c
movl $0x2548, %edx           # imm = 0x2548
callq 0xc140