// File: /workspace/github_cpp_makefile_star2_O1/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 0x5abc3(%rip), %rax     # 0xfdcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %r15
movb $0x1, 0x90(%r15)
cmpb $0x0, 0x93(%r15)
jne 0xa3142
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0xa314a
movl $0x10001e, %r12d        # imm = 0x10001E
cmpb $0x1, (%rbx)
je 0xa3150
xorl %r14d, %r14d
jmp 0xa3277
movl $0x1a, %r12d
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x46258
orl %r13d, %r12d
movl %eax, %r13d
movl %eax, %edi
movl %r12d, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xa2328
movl %eax, %r14d
testq %rbx, %rbx
je 0xa3277
leaq 0x5ab4b(%rip), %rax     # 0xfdcd0
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 0x18892(%rip), %rdi     # 0xbbaa1
xorl %esi, %esi
movl %r13d, %edx
callq 0x5614c
leaq -0x48(%rbp), %rsi
movaps -0x40(%rbp), %xmm0
movss %xmm0, (%rsi)
movss -0x2c(%rbp), %xmm0
movss %xmm0, 0x4(%rsi)
movl %eax, %edi
callq 0x934c0
testb %al, %al
je 0xa323d
movb $0x0, (%rbx)
leaq 0x5aa8c(%rip), %rax     # 0xfdcd0
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