// File: /workspace/github_cpp_makefile_star2_O1/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 0xa49bd(%rip), %r13     # 0xfdcd0
testb $0x10, %bl
jne 0x593b1
movq 0x1ae0(%r13), %r14
movl 0x124(%r14), %r15d
testl %r15d, %r15d
je 0x5933c
cmpl %r15d, 0x1b30(%r13)
jne 0x594a9
cmpb $0x0, 0x130(%r13)
je 0x594a9
testl %r15d, %r15d
je 0x59483
xorl %r12d, %r12d
movb %r12b, 0x1b3d(%r13)
cmpl %r15d, 0x1b30(%r13)
jne 0x594a9
movslq 0xc8(%r14), %rcx
testq %rcx, %rcx
jle 0x59556
movq 0xd0(%r14), %rdx
movq 0xa4948(%rip), %rax     # 0xfdcd0
cmpb $0x1, 0x130(%rax)
jne 0x59516
movss 0x38(%rax), %xmm0
movss 0x48c(%rax), %xmm1
mulss %xmm0, %xmm0
ucomiss %xmm0, %xmm1
setae %al
jmp 0x59518
leaq 0x610a8(%rip), %rdi     # 0xba460
xorl %r12d, %r12d
xorl %esi, %esi
xorl %edx, %edx
callq 0x428dc
movl %eax, %r15d
movb $0x1, %al
xorl %r14d, %r14d
testb %al, %al
je 0x594a9
cmpb $0x0, 0x2004(%r13)
jne 0x59425
testl %r15d, %r15d
je 0x59537
callq 0x51c8d
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 0x59425
movb $0x1, 0x1b3e(%r13)
movl 0x1a68(%r13), %eax
movl %eax, 0x200c(%r13)
movb $0x1, 0x2005(%r13)
testb $0x1, %bl
jne 0x59472
xorl %edi, %edi
xorl %esi, %esi
callq 0x57b95
cmpl $0x0, 0x2078(%r13)
je 0x59472
testb $0x10, 0x206d(%r13)
je 0x59472
movq 0x1ae0(%r13), %rax
movb $0x1, %cl
movb %cl, 0x93(%rax)
movb %cl, 0xac(%rax)
movb $0x1, %al
testb $0x12, %bl
jne 0x594ab
andb $-0x2, 0x128(%r14)
jmp 0x594ab
testb $0x8, %bl
je 0x59575
testb $0x1, 0x128(%r14)
jne 0x594ba
cmpl $0x0, 0x1b30(%r13)
je 0x594a9
cmpq %r14, 0x1b60(%r13)
je 0x594ba
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12c(%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x467ac
movl %eax, %r15d
movl %eax, 0x124(%r14)
movq %r12, %rdi
movl %eax, %esi
callq 0x46e45
movl %eax, %r12d
testb %al, %al
je 0x59504
cmpb $0x1, 0x420(%r13)
jne 0x59504
movl %r15d, %edi
movq %r14, %rsi
callq 0x46b95
movq %r14, %rdi
callq 0x47d9b
cmpl %r15d, 0x1b30(%r13)
je 0x59356
jmp 0x5935d
xorl %eax, %eax
movl -0x4(%rdx,%rcx,4), %r12d
movq $-0x1, %rcx
movq %rcx, 0x1b44(%r13)
movq %rcx, 0x1b50(%r13)
jmp 0x593cc
leaq 0x60f30(%rip), %rdi     # 0xba46e
leaq 0x5ec20(%rip), %rsi     # 0xb8165
leaq 0x60ee0(%rip), %rcx     # 0xba42c
movl $0x2577, %edx           # imm = 0x2577
callq 0xc140
leaq 0x7647d(%rip), %rdi     # 0xcf9da
leaq 0x62127(%rip), %rsi     # 0xbb68b
leaq 0x6348d(%rip), %rcx     # 0xbc9f8
movl $0x666, %edx            # imm = 0x666
callq 0xc140
leaq 0x60b70(%rip), %rdi     # 0xba0ec
leaq 0x5ebe2(%rip), %rsi     # 0xb8165
leaq 0x60ea2(%rip), %rcx     # 0xba42c
movl $0x2548, %edx           # imm = 0x2548
callq 0xc140