// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::SetDragDropPayload(char const*, void const*, unsigned long, int)
bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond)
{
    ImGuiContext& g = *GImGui;
    ImGuiPayload& payload = g.DragDropPayload;
    if (cond == 0)
        cond = ImGuiCond_Always;

    IM_ASSERT(type != NULL);
    IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
    IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
    IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
    IM_ASSERT(payload.SourceId != 0);                               // Not called between BeginDragDropSource() and EndDragDropSource()

    if (cond == ImGuiCond_Always || payload.DataFrameCount == -1)
    {
        // Copy payload
        ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType));
        g.DragDropPayloadBufHeap.resize(0);
        if (data_size > sizeof(g.DragDropPayloadBufLocal))
        {
            // Store in heap
            g.DragDropPayloadBufHeap.resize((int)data_size);
            payload.Data = g.DragDropPayloadBufHeap.Data;
            memcpy(payload.Data, data, data_size);
        }
        else if (data_size > 0)
        {
            // Store locally
            memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
            payload.Data = g.DragDropPayloadBufLocal;
            memcpy(payload.Data, data, data_size);
        }
        else
        {
            payload.Data = NULL;
        }
        payload.DataSize = (int)data_size;
    }
    payload.DataFrameCount = g.FrameCount;

    return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq 0x132ef2(%rip), %rax    # 0x212f40
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x2018, %rax           # imm = 0x2018
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0xe006d
movl $0x1, -0x1c(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xe0076
jmp 0xe0095
leaq 0x954a0(%rip), %rdi     # 0x17551d
leaq 0x92e85(%rip), %rsi     # 0x172f09
movl $0x25b1, %edx           # imm = 0x25B1
leaq 0x9549c(%rip), %rcx     # 0x17552c
callq 0xd180
movq -0x8(%rbp), %rdi
callq 0xd410
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x21, %rcx
movb %al, -0x31(%rbp)
jae 0xe00b3
movb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0xe00b3
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xe00bc
jmp 0xe00be
jmp 0xe00dd
leaq 0x954e4(%rip), %rdi     # 0x1755a9
leaq 0x92e3d(%rip), %rsi     # 0x172f09
movl $0x25b2, %edx           # imm = 0x25B2
leaq 0x95454(%rip), %rcx     # 0x17552c
callq 0xd180
cmpq $0x0, -0x10(%rbp)
je 0xe00f0
movb $0x1, %al
cmpq $0x0, -0x18(%rbp)
movb %al, -0x32(%rbp)
ja 0xe010d
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x33(%rbp)
jne 0xe0107
cmpq $0x0, -0x18(%rbp)
sete %al
movb %al, -0x33(%rbp)
movb -0x33(%rbp), %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0xe0116
jmp 0xe0118
jmp 0xe0137
leaq 0x9550d(%rip), %rdi     # 0x17562c
leaq 0x92de3(%rip), %rsi     # 0x172f09
movl $0x25b3, %edx           # imm = 0x25B3
leaq 0x953fa(%rip), %rcx     # 0x17552c
callq 0xd180
movb $0x1, %al
cmpl $0x1, -0x1c(%rbp)
movb %al, -0x34(%rbp)
je 0xe014c
cmpl $0x2, -0x1c(%rbp)
sete %al
movb %al, -0x34(%rbp)
movb -0x34(%rbp), %al
testb $0x1, %al
jne 0xe0155
jmp 0xe0157
jmp 0xe0176
leaq 0x95516(%rip), %rdi     # 0x175674
leaq 0x92da4(%rip), %rsi     # 0x172f09
movl $0x25b4, %edx           # imm = 0x25B4
leaq 0x953bb(%rip), %rcx     # 0x17552c
callq 0xd180
movq -0x30(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0xe0182
jmp 0xe01a1
leaq 0x9551e(%rip), %rdi     # 0x1756a7
leaq 0x92d79(%rip), %rsi     # 0x172f09
movl $0x25b5, %edx           # imm = 0x25B5
leaq 0x95390(%rip), %rcx     # 0x17552c
callq 0xd180
cmpl $0x1, -0x1c(%rbp)
je 0xe01b5
movq -0x30(%rbp), %rax
cmpl $-0x1, 0x14(%rax)
jne 0xe0282
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
movq -0x8(%rbp), %rsi
movl $0x21, %edx
callq 0xc4780
movq -0x28(%rbp), %rdi
addq $0x2088, %rdi           # imm = 0x2088
xorl %esi, %esi
callq 0xec1d0
cmpq $0x10, -0x18(%rbp)
jbe 0xe0222
movq -0x28(%rbp), %rdi
addq $0x2088, %rdi           # imm = 0x2088
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0xec1d0
movq -0x28(%rbp), %rax
movq 0x2090(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xd0a0
jmp 0xe0275
cmpq $0x0, -0x18(%rbp)
jbe 0xe0268
movq -0x28(%rbp), %rdi
addq $0x2098, %rdi           # imm = 0x2098
xorl %esi, %esi
movl $0x10, %edx
callq 0xd2f0
movq -0x28(%rbp), %rcx
addq $0x2098, %rcx           # imm = 0x2098
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xd0a0
jmp 0xe0273
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
jmp 0xe0275
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x28(%rbp), %rax
movl 0x1a68(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x28(%rbp), %rax
movl 0x207c(%rax), %ecx
movq -0x28(%rbp), %rdx
movb $0x1, %al
cmpl 0x1a68(%rdx), %ecx
movb %al, -0x35(%rbp)
je 0xe02cd
movq -0x28(%rbp), %rax
movl 0x207c(%rax), %eax
movq -0x28(%rbp), %rcx
movl 0x1a68(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)