// File: /workspace/github_cpp_makefile_star2_O2/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 0x5a514(%rip), %rax     # 0xe3ce0
movq (%rax), %rax
movq 0x1ae0(%rax), %r15
movb $0x1, 0x90(%r15)
cmpb $0x0, 0x93(%r15)
jne 0x89801
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x89809
movl $0x10001e, %r12d        # imm = 0x10001E
cmpb $0x1, (%rbx)
je 0x8980d
xorl %r14d, %r14d
jmp 0x89910
pushq $0x1a
popq %r12
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3700a
orl %r13d, %r12d
movl %eax, %r13d
movl %eax, %edi
movl %r12d, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x88a94
movl %eax, %r14d
testq %rbx, %rbx
je 0x89910
leaq 0x5a49e(%rip), %rax     # 0xe3ce0
movq (%rax), %r12
leaq -0x70(%rbp), %rdi
callq 0x93158
movss 0x134(%r15), %xmm0
movss 0x1598(%r12), %xmm1
addss %xmm1, %xmm1
subss %xmm1, %xmm0
subss 0x1980(%r12), %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 0x17212(%rip), %rdi     # 0xa0abb
xorl %esi, %esi
movl %r13d, %edx
callq 0x42fc0
leaq -0x48(%rbp), %rsi
movaps -0x40(%rbp), %xmm0
movss %xmm0, (%rsi)
movss -0x2c(%rbp), %xmm0
movss %xmm0, 0x4(%rsi)
movl %eax, %edi
callq 0x7a9f1
testb %al, %al
je 0x898d7
movb $0x0, (%rbx)
leaq 0x5a402(%rip), %rax     # 0xe3ce0
movq (%rax), %rax
movq 0x1ae0(%rax), %rax
movl -0x70(%rbp), %ecx
movl %ecx, 0x124(%rax)
movl -0x6c(%rbp), %ecx
movl %ecx, 0x128(%rax)
movups -0x68(%rbp), %xmm0
movups %xmm0, 0x12c(%rax)
movups -0x58(%rbp), %xmm0
movups %xmm0, 0x13c(%rax)
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq