// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::CollapsingHeader(char const*, bool*, int)
bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    if (p_visible && !*p_visible)
        return false;

    ImGuiID id = window->GetID(label);
    flags |= ImGuiTreeNodeFlags_CollapsingHeader;
    if (p_visible)
        flags |= ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
    bool is_open = TreeNodeBehavior(id, flags, label);
    if (p_visible != NULL)
    {
        // Create a small overlapping close button
        // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc.
        // FIXME: CloseButton can overlap into text, need find a way to clip the text somehow.
        ImGuiContext& g = *GImGui;
        ImGuiLastItemDataBackup last_item_backup;
        float button_size = g.FontSize;
        float button_x = ImMax(window->DC.LastItemRect.Min.x, window->DC.LastItemRect.Max.x - g.Style.FramePadding.x * 2.0f - button_size);
        float button_y = window->DC.LastItemRect.Min.y;
        ImGuiID close_button_id = GetIDWithSeed("#CLOSE", NULL, id);
        if (CloseButton(close_button_id, ImVec2(button_x, button_y)))
            *p_visible = false;
        last_item_backup.Restore();
    }

    return is_open;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0x5a508(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %r15
movb $0x1, 0x90(%r15)
cmpb $0x0, 0x93(%r15)
jne 0xa17fd
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0xa1805
movl $0x10001e, %r12d        # imm = 0x10001E
cmpb $0x1, (%rbx)
je 0xa180b
xorl %r14d, %r14d
jmp 0xa1932
movl $0x1a, %r12d
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4570a
orl %r13d, %r12d
movl %eax, %r13d
movl %eax, %edi
movl %r12d, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xa09cd
movl %eax, %r14d
testq %rbx, %rbx
je 0xa1932
leaq 0x5a490(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %rcx
movl 0x124(%rcx), %edx
movl %edx, -0x30(%rbp)
movl 0x128(%rcx), %r12d
movups 0x12c(%rcx), %xmm0
leaq -0x60(%rbp), %rdx
movaps %xmm0, -0x10(%rdx)
movups 0x13c(%rcx), %xmm0
movaps %xmm0, (%rdx)
movss 0x134(%r15), %xmm0
movss 0x1598(%rax), %xmm1
addss %xmm1, %xmm1
subss %xmm1, %xmm0
subss 0x1980(%rax), %xmm0
movss 0x12c(%r15), %xmm1
movss 0x130(%r15), %xmm2
movss %xmm2, -0x2c(%rbp)
movaps %xmm0, %xmm3
cmpless %xmm1, %xmm3
movaps %xmm3, %xmm2
andnps %xmm0, %xmm2
andps %xmm1, %xmm3
orps %xmm2, %xmm3
movaps %xmm3, -0x40(%rbp)
leaq 0x181d7(%rip), %rdi     # 0xb9aa1
xorl %esi, %esi
movl %r13d, %edx
callq 0x55046
leaq -0x48(%rbp), %rsi
movaps -0x40(%rbp), %xmm0
movss %xmm0, (%rsi)
movss -0x2c(%rbp), %xmm0
movss %xmm0, 0x4(%rsi)
movl %eax, %edi
callq 0x917d0
testb %al, %al
je 0xa18f8
movb $0x0, (%rbx)
leaq 0x5a3d1(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %rax
movl -0x30(%rbp), %ecx
movl %ecx, 0x124(%rax)
movl %r12d, 0x128(%rax)
movaps -0x70(%rbp), %xmm0
movups %xmm0, 0x12c(%rax)
leaq -0x60(%rbp), %rcx
movups (%rcx), %xmm0
movups %xmm0, 0x13c(%rax)
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq