// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::TreeNodeBehaviorIsOpened(unsigned int, int)
bool ImGui::TreeNodeBehaviorIsOpened(ImGuiID id, ImGuiTreeNodeFlags flags)
{
    // We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions)
    ImGuiState& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    ImGuiStorage* storage = window->DC.StateStorage;

    bool opened;
    if (g.SetNextTreeNodeOpenedCond != 0)
    {
        if (g.SetNextTreeNodeOpenedCond & ImGuiSetCond_Always)
        {
            opened = g.SetNextTreeNodeOpenedVal;
            storage->SetInt(id, opened);
        }
        else
        {
            // We treat ImGuiSetCondition_Once and ImGuiSetCondition_FirstUseEver the same because tree node state are not saved persistently.
            const int stored_value = storage->GetInt(id, -1);
            if (stored_value == -1)
            {
                opened = g.SetNextTreeNodeOpenedVal;
                storage->SetInt(id, opened);
            }
            else
            {
                opened = stored_value != 0;
            }
        }
        g.SetNextTreeNodeOpenedCond = 0;
    }
    else
    {
        opened = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
    }

    // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
    // NB- If we are above max depth we still allow manually opened nodes to be logged.
    if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoExpandOnLog) && window->DC.TreeDepth < g.LogAutoExpandMaxDepth)
        opened = true;

    return opened;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq 0x5db1b(%rip), %rax     # 0x794c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x1758(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1848(%rax)
je 0x1ba6c
movq -0x10(%rbp), %rax
movl 0x1848(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1ba0f
movq -0x10(%rbp), %rax
movb 0x1845(%rax), %al
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x20(%rbp), %rdi
movl -0x4(%rbp), %esi
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xab80
jmp 0x1ba5c
movq -0x20(%rbp), %rdi
movl -0x4(%rbp), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xa7d0
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x1ba4e
movq -0x10(%rbp), %rax
movb 0x1845(%rax), %al
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x20(%rbp), %rdi
movl -0x4(%rbp), %esi
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xab80
jmp 0x1ba5a
cmpl $0x0, -0x28(%rbp)
setne %al
andb $0x1, %al
movb %al, -0x21(%rbp)
jmp 0x1ba5c
movq -0x10(%rbp), %rax
movl $0x0, 0x1848(%rax)
jmp 0x1ba96
movq -0x20(%rbp), %rdi
movl -0x4(%rbp), %esi
movl -0x8(%rbp), %ecx
andl $0x1, %ecx
xorl %edx, %edx
movl $0x1, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0xa7d0
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0x2be8(%rax)
je 0x1bac8
movl -0x8(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x1bac8
movq -0x18(%rbp), %rax
movl 0xdc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x2c04(%rcx), %eax
jge 0x1bac8
movb $0x1, -0x21(%rbp)
movb -0x21(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)