// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::CollapsingHeader(char const*, char const*, bool, bool)
bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display_frame, bool default_open)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiState& g = *GImGui;
    const ImGuiStyle& style = g.Style;

    IM_ASSERT(str_id != NULL || label != NULL);
    if (str_id == NULL)
        str_id = label;
    if (label == NULL)
        label = str_id;
    const ImGuiID id = window->GetID(str_id);

    // Framed header expand a little outside the default padding
    const ImVec2 window_padding = window->WindowPadding;
    const ImVec2 label_size = CalcTextSize(label, NULL, true);
    const ImVec2 pos_min = window->DC.CursorPos;
    const ImVec2 pos_max = window->Pos + GetContentRegionMax();
    ImRect bb = ImRect(pos_min, ImVec2(pos_max.x, pos_min.y + label_size.y));
    if (display_frame)
    {
        bb.Min.x -= (float)(int)(window_padding.x*0.5f) - 1;
        bb.Max.x += (float)(int)(window_padding.x*0.5f) - 1;
        bb.Max.y += style.FramePadding.y * 2;
    }

    const float collapser_width = g.FontSize + style.FramePadding.x*2;
    const ImRect text_bb(bb.Min, bb.Min + ImVec2(collapser_width + style.FramePadding.x*2*0 + (label_size.x > 0.0f ? label_size.x : 0.0f), label_size.y));
    ItemSize(ImVec2(text_bb.GetSize().x, bb.GetSize().y), display_frame ? style.FramePadding.y : 0.0f);

    const ImRect interact_bb = display_frame ? bb : ImRect(text_bb.Min, text_bb.Max + ImVec2(style.FramePadding.x*2,0.0f)); // FIXME
    bool opened = TreeNodeBehaviorIsOpened(id, (default_open ? ImGuiTreeNodeFlags_DefaultOpen : 0) | (display_frame ? ImGuiTreeNodeFlags_NoAutoExpandOnLog : 0));

    if (!ItemAdd(interact_bb, &id))
        return opened;

    bool hovered, held;
    bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, false);
    if (pressed)
    {
        opened = !opened;
        window->DC.StateStorage->SetInt(id, opened);
    }

    // Render
    const ImU32 col = window->Color((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
    if (display_frame)
    {
        // Framed type
        RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
        RenderCollapseTriangle(bb.Min + style.FramePadding, opened, 1.0f, true);
        if (g.LogEnabled)
        {
            // NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
            const char log_prefix[] = "\n##";
            LogRenderedText(bb.Min + style.FramePadding, log_prefix, log_prefix+3);
        }
        RenderTextClipped(bb.Min + style.FramePadding + ImVec2(collapser_width,0), bb.Max, label, NULL, &label_size);
        if (g.LogEnabled)
        {
            const char log_suffix[] = "##";
            LogRenderedText(bb.Min + style.FramePadding, log_suffix, log_suffix+2);
        }
    }
    else
    {
        // Unframed typed for tree nodes
        if ((held && hovered) || hovered)
            RenderFrame(bb.Min, bb.Max, col, false);
        RenderCollapseTriangle(bb.Min + ImVec2(style.FramePadding.x, g.FontSize*0.15f), opened, 0.70f, false);
        if (g.LogEnabled)
            LogRenderedText(bb.Min, ">");
        RenderText(bb.Min + ImVec2(collapser_width,0), label);
    }

    return opened;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %cl
movb %cl, -0x19(%rbp)
andb $0x1, %al
movb %al, -0x1a(%rbp)
callq 0x2e220
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x74(%rax)
je 0x1bb1e
movb $0x0, -0x1(%rbp)
jmp 0x1c2f3
movq 0x5d99b(%rip), %rax     # 0x794c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x13e8, %rax           # imm = 0x13E8
movq %rax, -0x38(%rbp)
movb $0x1, %al
cmpq $0x0, -0x18(%rbp)
movb %al, -0x161(%rbp)
jne 0x1bb54
cmpq $0x0, -0x10(%rbp)
setne %al
movb %al, -0x161(%rbp)
movb -0x161(%rbp), %al
testb $0x1, %al
jne 0x1bb60
jmp 0x1bb62
jmp 0x1bb81
leaq 0x402e0(%rip), %rdi     # 0x5be49
leaq 0x3f755(%rip), %rsi     # 0x5b2c5
movl $0x1566, %edx           # imm = 0x1566
leaq 0x402f1(%rip), %rcx     # 0x5be6d
callq 0x7160
cmpq $0x0, -0x18(%rbp)
jne 0x1bb90
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1bb9f
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x178(%rbp)
callq 0xbc60
movq -0x178(%rbp), %rsi
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movss 0x3f49e(%rip), %xmm0    # 0x5b07c
callq 0x10930
movlpd %xmm0, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x170(%rbp)
callq 0xc830
movq -0x170(%rbp), %rdi
movlpd %xmm0, -0x68(%rbp)
leaq -0x68(%rbp), %rsi
callq 0xc7e0
movlpd %xmm0, -0x60(%rbp)
movss -0x60(%rbp), %xmm0
movss -0x54(%rbp), %xmm1
addss -0x4c(%rbp), %xmm1
leaq -0x80(%rbp), %rdi
callq 0x2d280
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x2eb40
testb $0x1, -0x19(%rbp)
je 0x1bcc9
movss 0x3f3c8(%rip), %xmm0    # 0x5b024
mulss -0x48(%rbp), %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm1
movss 0x3f3a7(%rip), %xmm0    # 0x5b018
subss %xmm0, %xmm1
movss -0x78(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x78(%rbp)
movss 0x3f399(%rip), %xmm0    # 0x5b024
mulss -0x48(%rbp), %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movss 0x3f378(%rip), %xmm1    # 0x5b018
subss %xmm1, %xmm0
addss -0x70(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movq -0x38(%rbp), %rax
movss 0x24(%rax), %xmm0
movss -0x6c(%rbp), %xmm1
addss %xmm0, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x6c(%rbp)
movq -0x30(%rbp), %rax
movss 0x1718(%rax), %xmm1
movq -0x38(%rbp), %rax
movss 0x20(%rax), %xmm0
addss %xmm0, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x84(%rbp)
leaq -0x78(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0x78(%rbp), %rax
movq %rax, -0x188(%rbp)
movss -0x84(%rbp), %xmm1
movq -0x38(%rbp), %rax
movss 0x3f3a0(%rip), %xmm0    # 0x5b0b8
mulss 0x20(%rax), %xmm0
xorps %xmm2, %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x17c(%rbp)
movss -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1bd4c
movss -0x50(%rbp), %xmm0
movss %xmm0, -0x194(%rbp)
jmp 0x1bd59
xorps %xmm0, %xmm0
movss %xmm0, -0x194(%rbp)
jmp 0x1bd59
movss -0x17c(%rbp), %xmm0
movss -0x194(%rbp), %xmm1
addss %xmm1, %xmm0
movss -0x4c(%rbp), %xmm1
leaq -0xa4(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x2d280
movq -0x188(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
callq 0xc7e0
movq -0x190(%rbp), %rsi
movlpd %xmm0, -0x9c(%rbp)
leaq -0x94(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq -0x9c(%rbp), %rdx
callq 0x2eb40
movq -0x1a0(%rbp), %rdi
callq 0x2e250
movlpd %xmm0, -0xb4(%rbp)
movss -0xb4(%rbp), %xmm0
movss %xmm0, -0x198(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2e250
movaps %xmm0, %xmm1
movss -0x198(%rbp), %xmm0
movlpd %xmm1, -0xbc(%rbp)
movss -0xb8(%rbp), %xmm1
leaq -0xac(%rbp), %rdi
callq 0x2d280
testb $0x1, -0x19(%rbp)
je 0x1be2e
movq -0x38(%rbp), %rax
movss 0x24(%rax), %xmm0
movss %xmm0, -0x1ac(%rbp)
jmp 0x1be3b
xorps %xmm0, %xmm0
movss %xmm0, -0x1ac(%rbp)
jmp 0x1be3b
movss -0x1ac(%rbp), %xmm0
leaq -0xac(%rbp), %rdi
callq 0xbeb0
testb $0x1, -0x19(%rbp)
je 0x1be6d
movq -0x78(%rbp), %rax
movq %rax, -0xcc(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0xc4(%rbp)
jmp 0x1bee1
leaq -0x94(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x8c(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x38(%rbp), %rax
movss 0x20(%rax), %xmm0
addss %xmm0, %xmm0
leaq -0xdc(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
xorps %xmm1, %xmm1
callq 0x2d280
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rsi
callq 0xc7e0
movq -0x1b8(%rbp), %rsi
movlpd %xmm0, -0xd4(%rbp)
leaq -0xcc(%rbp), %rdi
leaq -0xd4(%rbp), %rdx
callq 0x2eb40
movl -0x3c(%rbp), %edi
movb -0x1a(%rbp), %cl
xorl %esi, %esi
movl $0x1, %eax
testb $0x1, %cl
cmovnel %eax, %esi
movb -0x19(%rbp), %dl
xorl %eax, %eax
movl $0x2, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
orl %eax, %esi
callq 0x1b990
andb $0x1, %al
movb %al, -0xdd(%rbp)
leaq -0xcc(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0xc0a0
testb $0x1, %al
jne 0x1bf37
movb -0xdd(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x1c2f3
movl -0x3c(%rbp), %esi
leaq -0xcc(%rbp), %rdi
leaq -0xde(%rbp), %rdx
leaq -0xdf(%rbp), %rcx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0x17010
andb $0x1, %al
movb %al, -0xe0(%rbp)
testb $0x1, -0xe0(%rbp)
je 0x1bf99
movb -0xdd(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0xdd(%rbp)
movq -0x28(%rbp), %rax
movq 0x110(%rax), %rdi
movl -0x3c(%rbp), %esi
movb -0xdd(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xab80
movq -0x28(%rbp), %rax
movq %rax, -0x1d0(%rbp)
testb $0x1, -0xdf(%rbp)
je 0x1bfc3
testb $0x1, -0xde(%rbp)
je 0x1bfc3
movl $0x1a, %eax
movl %eax, -0x1d4(%rbp)
jmp 0x1bfdf
movb -0xde(%rbp), %dl
movl $0x18, %eax
movl $0x19, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x1d4(%rbp)
movq -0x1d0(%rbp), %rdi
movl -0x1d4(%rbp), %esi
movss 0x3f024(%rip), %xmm0    # 0x5b018
callq 0x2ea40
movl %eax, -0xe4(%rbp)
testb $0x1, -0x19(%rbp)
je 0x1c1b7
movq -0x78(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0xe4(%rbp), %edi
movq -0x38(%rbp), %rax
movss 0x28(%rax), %xmm2
movsd -0xf0(%rbp), %xmm0
movsd -0xf8(%rbp), %xmm1
movl $0x1, %esi
callq 0x10a20
movq -0x38(%rbp), %rsi
addq $0x20, %rsi
leaq -0x78(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x100(%rbp)
movb -0xdd(%rbp), %al
movsd -0x100(%rbp), %xmm0
movzbl %al, %edi
andl $0x1, %edi
movss 0x3ef9b(%rip), %xmm1    # 0x5b018
movl $0x1, %esi
callq 0x10b80
movq -0x30(%rbp), %rax
testb $0x1, 0x2be8(%rax)
je 0x1c0d5
movl $0x23230a, -0x104(%rbp) # imm = 0x23230A
movq -0x38(%rbp), %rsi
addq $0x20, %rsi
leaq -0x78(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x10c(%rbp)
leaq -0x104(%rbp), %rsi
leaq -0x104(%rbp), %rdx
addq $0x3, %rdx
leaq -0x10c(%rbp), %rdi
callq 0x10320
movq -0x38(%rbp), %rsi
addq $0x20, %rsi
leaq -0x78(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x11c(%rbp)
movss -0x84(%rbp), %xmm0
leaq -0x124(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
xorps %xmm1, %xmm1
callq 0x2d280
movq -0x1e0(%rbp), %rsi
leaq -0x11c(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x114(%rbp)
leaq -0x78(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rdx
leaq -0x114(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x50(%rbp), %r8
movl $0x9, %r9d
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x105f0
movq -0x30(%rbp), %rax
testb $0x1, 0x2be8(%rax)
je 0x1c1b2
movb $0x0, -0x126(%rbp)
movw $0x2323, -0x128(%rbp)   # imm = 0x2323
movq -0x38(%rbp), %rsi
addq $0x20, %rsi
leaq -0x78(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x130(%rbp)
leaq -0x128(%rbp), %rsi
leaq -0x128(%rbp), %rdx
addq $0x2, %rdx
leaq -0x130(%rbp), %rdi
callq 0x10320
jmp 0x1c2e8
testb $0x1, -0xdf(%rbp)
je 0x1c1c9
testb $0x1, -0xde(%rbp)
jne 0x1c1d2
testb $0x1, -0xde(%rbp)
je 0x1c208
movq -0x78(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x140(%rbp)
movl -0xe4(%rbp), %edi
movsd -0x138(%rbp), %xmm0
movsd -0x140(%rbp), %xmm1
xorl %esi, %esi
xorps %xmm2, %xmm2
callq 0x10a20
movq -0x38(%rbp), %rax
movss 0x20(%rax), %xmm0
movq -0x30(%rbp), %rax
movss 0x1718(%rax), %xmm1
movss 0x3ee23(%rip), %xmm2    # 0x5b048
mulss %xmm2, %xmm1
leaq -0x150(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x2d280
movq -0x1e8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x148(%rbp)
movb -0xdd(%rbp), %al
movsd -0x148(%rbp), %xmm0
movzbl %al, %edi
andl $0x1, %edi
movss 0x3edb0(%rip), %xmm1    # 0x5b020
xorl %esi, %esi
callq 0x10b80
movq -0x30(%rbp), %rax
testb $0x1, 0x2be8(%rax)
je 0x1c298
leaq -0x78(%rbp), %rdi
leaq 0x42b62(%rip), %rsi     # 0x5edf1
xorl %eax, %eax
movl %eax, %edx
callq 0x10320
movss -0x84(%rbp), %xmm0
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
xorps %xmm1, %xmm1
callq 0x2d280
movq -0x1f0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xc7e0
movlpd %xmm0, -0x158(%rbp)
movq -0x10(%rbp), %rdi
movsd -0x158(%rbp), %xmm0
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x10100
movb -0xdd(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
nopw %cs:(%rax,%rax)