// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::ButtonBehavior(ImRect const&, unsigned int, bool*, bool*, bool, int)
bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, bool allow_key_modifiers, ImGuiButtonFlags flags)
{
    ImGuiState& g = *GImGui;
    ImGuiWindow* window = GetCurrentWindow();

    if (flags & ImGuiButtonFlags_Disabled)
    {
        if (out_hovered) *out_hovered = false;
        if (out_held) *out_held = false;
        if (g.ActiveId == id) SetActiveID(0);
        return false;
    }

    bool pressed = false;
    const bool hovered = IsHovered(bb, id, (flags & ImGuiButtonFlags_FlattenChilds) != 0);
    if (hovered)
    {
        g.HoveredId = id;
        if (allow_key_modifiers || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
        {
            if (g.IO.MouseClicked[0])
            {
                if (flags & ImGuiButtonFlags_PressedOnClick)
                {
                    pressed = true;
                    SetActiveID(0);
                }
                else
                {
                    SetActiveID(id, window);
                }
                FocusWindow(window);
            }
            else if (g.IO.MouseReleased[0] && (flags & ImGuiButtonFlags_PressedOnRelease))
            {
                pressed = true;
                SetActiveID(0);
            }
            else if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && ImGui::IsMouseClicked(0, true))
            {
                pressed = true;
            }
        }
    }

    bool held = false;
    if (g.ActiveId == id)
    {
        if (g.IO.MouseDown[0])
        {
            held = true;
        }
        else
        {
            if (hovered)
                pressed = true;
            SetActiveID(0);
        }
    }

    if (out_hovered) *out_hovered = hovered;
    if (out_held) *out_held = held;

    return pressed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movl %r9d, -0x30(%rbp)
movq 0x62486(%rip), %rax     # 0x794c0
movq %rax, -0x38(%rbp)
callq 0x2e220
movq %rax, -0x40(%rbp)
movl -0x30(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x17091
cmpq $0x0, -0x20(%rbp)
je 0x17060
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x1706e
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x38(%rbp), %rax
movl 0x1790(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x17088
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe60
movb $0x0, -0x1(%rbp)
jmp 0x17214
movb $0x0, -0x41(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x30(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
setne %al
movzbl %al, %edx
andl $0x1, %edx
callq 0xc3f0
andb $0x1, %al
movb %al, -0x42(%rbp)
testb $0x1, -0x42(%rbp)
je 0x171a9
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x1788(%rax)
testb $0x1, -0x29(%rbp)
jne 0x17108
movq -0x38(%rbp), %rax
testb $0x1, 0x105(%rax)
jne 0x171a7
movq -0x38(%rbp), %rax
testb $0x1, 0x106(%rax)
jne 0x171a7
movq -0x38(%rbp), %rax
testb $0x1, 0x107(%rax)
jne 0x171a7
movq -0x38(%rbp), %rax
testb $0x1, 0x354(%rax)
je 0x17148
movl -0x30(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x17131
movb $0x1, -0x41(%rbp)
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe60
jmp 0x1713d
movl -0x14(%rbp), %edi
movq -0x40(%rbp), %rsi
callq 0xbe60
movq -0x40(%rbp), %rdi
callq 0xef00
jmp 0x171a5
movq -0x38(%rbp), %rax
testb $0x1, 0x39d(%rax)
je 0x17171
movl -0x30(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x17171
movb $0x1, -0x41(%rbp)
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe60
jmp 0x171a3
movl -0x30(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x171a1
movq -0x38(%rbp), %rax
movl 0x1790(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x171a1
xorl %edi, %edi
movl $0x1, %esi
callq 0x11740
testb $0x1, %al
jne 0x1719d
jmp 0x171a1
movb $0x1, -0x41(%rbp)
jmp 0x171a3
jmp 0x171a5
jmp 0x171a7
jmp 0x171a9
movb $0x0, -0x43(%rbp)
movq -0x38(%rbp), %rax
movl 0x1790(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x171e6
movq -0x38(%rbp), %rax
testb $0x1, 0xf8(%rax)
je 0x171cf
movb $0x1, -0x43(%rbp)
jmp 0x171e4
testb $0x1, -0x42(%rbp)
je 0x171d9
movb $0x1, -0x41(%rbp)
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe60
jmp 0x171e6
cmpq $0x0, -0x20(%rbp)
je 0x171f9
movb -0x42(%rbp), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x1720c
movb -0x43(%rbp), %cl
movq -0x28(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
movb -0x41(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nop