// File: /workspace/github_cpp_makefile_star2_O3/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 0xa3b30(%rip), %r13     # 0xfbcd0
testb $0x10, %bl
jne 0x581df
movq 0x1ae0(%r13), %r14
movl 0x124(%r14), %r15d
testl %r15d, %r15d
je 0x582af
cmpl %r15d, 0x1b30(%r13)
jne 0x583b7
xorl %r12d, %r12d
cmpb $0x0, 0x130(%r13)
jne 0x5833e
jmp 0x583ba
leaq 0x6027a(%rip), %rdi     # 0xb8460
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edx, %edx
callq 0x42033
movl %eax, %r15d
xorl %r12d, %r12d
cmpb $0x0, 0x2004(%r13)
jne 0x58249
testl %r15d, %r15d
je 0x583cc
callq 0x50cb6
movl %r15d, 0x2024(%r13)
movl %r12d, 0x2028(%r13)
movb $0x1, 0x2004(%r13)
movl %ebx, 0x2008(%r13)
movl $0x0, 0x2010(%r13)
cmpl 0x1b30(%r13), %r15d
jne 0x58249
movb $0x1, 0x1b3e(%r13)
movl 0x1a68(%r13), %eax
movl %eax, 0x200c(%r13)
movb $0x1, 0x2005(%r13)
testb $0x1, %bl
jne 0x58296
xorl %edi, %edi
xorl %esi, %esi
callq 0x56a80
cmpl $0x0, 0x2078(%r13)
je 0x58296
testb $0x10, 0x206d(%r13)
je 0x58296
movq 0x1ae0(%r13), %rax
movb $0x1, %cl
movb %cl, 0x93(%rax)
movb %cl, 0xac(%rax)
movb $0x1, %r12b
testb $0x12, %bl
jne 0x583ba
andb $-0x2, 0x128(%r14)
jmp 0x583ba
cmpb $0x0, 0x130(%r13)
je 0x583b7
testb $0x8, %bl
je 0x5840a
testb $0x1, 0x128(%r14)
jne 0x582eb
cmpl $0x0, 0x1b30(%r13)
je 0x583b7
cmpq %r14, 0x1b60(%r13)
jne 0x583b7
leaq 0x12c(%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x45c5e
movl %eax, %r15d
movl %eax, 0x124(%r14)
movq %r12, %rdi
movl %eax, %esi
callq 0x4632f
movl %eax, %r12d
testb %al, %al
je 0x58335
cmpb $0x1, 0x420(%r13)
jne 0x58335
movl %r15d, %edi
movq %r14, %rsi
callq 0x4603f
movq %r14, %rdi
callq 0x4726c
cmpl %r15d, 0x1b30(%r13)
jne 0x583b7
movb %r12b, 0x1b3d(%r13)
movslq 0xc8(%r14), %rax
testq %rax, %rax
jle 0x583eb
movq 0xa3974(%rip), %rcx     # 0xfbcd0
cmpb $0x0, 0x130(%rcx)
je 0x583a2
movq 0xd0(%r14), %rdx
movss 0x38(%rcx), %xmm0
movss 0x48c(%rcx), %xmm1
mulss %xmm0, %xmm0
ucomiss %xmm0, %xmm1
movl -0x4(%rdx,%rax,4), %r12d
movq $-0x1, %rax
movq %rax, 0x1b44(%r13)
movq %rax, 0x1b50(%r13)
jae 0x581f8
jmp 0x583b7
movq $-0x1, %rax
movq %rax, 0x1b44(%r13)
movq %rax, 0x1b50(%r13)
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6009b(%rip), %rdi     # 0xb846e
leaq 0x5dd8b(%rip), %rsi     # 0xb6165
leaq 0x6004b(%rip), %rcx     # 0xb842c
movl $0x2577, %edx           # imm = 0x2577
callq 0xc140
leaq 0x755b8(%rip), %rdi     # 0xcd9aa
leaq 0x61292(%rip), %rsi     # 0xb968b
leaq 0x625f8(%rip), %rcx     # 0xba9f8
movl $0x666, %edx            # imm = 0x666
callq 0xc140
leaq 0x5fcdb(%rip), %rdi     # 0xb80ec
leaq 0x5dd4d(%rip), %rsi     # 0xb6165
leaq 0x6000d(%rip), %rcx     # 0xb842c
movl $0x2548, %edx           # imm = 0x2548
callq 0xc140