// File: /workspace/github_cpp_makefile_star2_O2/donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::Combo(char const*, int*, bool (*)(void*, int, char const**), void*, int, int)
bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiState& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);
    const float w = CalcItemWidth();

    const ImVec2 label_size = CalcTextSize(label, NULL, true);
    const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y) + style.FramePadding*2.0f);
    const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
    ItemSize(total_bb, style.FramePadding.y);
    if (!ItemAdd(total_bb, &id))
        return false;

    const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
    const bool hovered = IsHovered(frame_bb, id);

    const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
    RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg), true, style.FrameRounding);
    RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, window->Color(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
    RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);

    if (*current_item >= 0 && *current_item < items_count)
    {
        const char* item_text;
        if (items_getter(data, *current_item, &item_text))
            RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, item_text, NULL, NULL);
    }

    if (label_size.x > 0)
        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);

    bool menu_toggled = false;
    if (hovered)
    {
        g.HoveredId = id;
        if (g.IO.MouseClicked[0])
        {
            SetActiveID(0);
            if (IsPopupOpen(id))
            {
                ClosePopup(id);
            }
            else
            {
                FocusWindow(window);
                ImGui::OpenPopup(label);
                menu_toggled = true;
            }
        }
    }

    bool value_changed = false;
    if (IsPopupOpen(id))
    {
        // Size default to hold ~7 items
        if (height_in_items < 0)
            height_in_items = 7;

        float popup_height = (label_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + (style.FramePadding.y * 3);
        ImRect popup_rect(ImVec2(frame_bb.Min.x, frame_bb.Max.y), ImVec2(frame_bb.Max.x, frame_bb.Max.y + popup_height));
        popup_rect.Max.y = ImMin(popup_rect.Max.y, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y); // Adhoc height limit for Combo. Ideally should be handled in Begin() along with other popups size, we want to have the possibility of moving the popup above as well.
        ImGui::SetNextWindowPos(popup_rect.Min);
        ImGui::SetNextWindowSize(popup_rect.GetSize());
        ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);

        const ImGuiWindowFlags flags = ImGuiWindowFlags_ComboBox | ((window->Flags & ImGuiWindowFlags_ShowBorders) ? ImGuiWindowFlags_ShowBorders : 0);
        if (BeginPopupEx(label, flags))
        {
            // Display items
            ImGui::Spacing();
            for (int i = 0; i < items_count; i++)
            {
                ImGui::PushID((void*)(intptr_t)i);
                const bool item_selected = (i == *current_item);
                const char* item_text;
                if (!items_getter(data, i, &item_text))
                    item_text = "*Unknown item*";
                if (ImGui::Selectable(item_text, item_selected))
                {
                    SetActiveID(0);
                    value_changed = true;
                    *current_item = i;
                }
                if (item_selected && menu_toggled)
                    ImGui::SetScrollHere();
                ImGui::PopID();
            }
            ImGui::EndPopup();
        }
        ImGui::PopStyleVar();
    }
    return value_changed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, -0x70(%rbp)
movq %rdx, -0x68(%rbp)
movq %rsi, -0x48(%rbp)
movq 0x35f60(%rip), %r14     # 0x50480
movq 0x1758(%r14), %r13
movb $0x1, 0x72(%r13)
cmpb $0x0, 0x74(%r13)
jne 0x1aa08
movl %r8d, %r12d
movq %rdi, %rbx
movl %r9d, -0x4c(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x9858
movl %eax, -0x2c(%rbp)
callq 0x1137a
movss %xmm0, -0x60(%rbp)
pushq $0x1
popq %rdx
movss 0x1be36(%rip), %xmm0    # 0x3639c
movq %rbx, -0x40(%rbp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc6e3
movaps %xmm0, %xmm5
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movss -0x60(%rbp), %xmm2
addss 0xa8(%r13), %xmm2
movss 0xac(%r13), %xmm1
movaps %xmm0, -0x100(%rbp)
addss %xmm0, %xmm1
movss 0x1408(%r14), %xmm3
movss 0x140c(%r14), %xmm0
addss %xmm3, %xmm3
movaps %xmm0, %xmm4
addss %xmm0, %xmm4
addss %xmm2, %xmm3
addss %xmm1, %xmm4
movaps %xmm3, %xmm1
unpcklps %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movq 0xa8(%r13), %r15
movq %r15, -0xf0(%rbp)
movaps %xmm1, -0xd0(%rbp)
movlps %xmm1, -0xe8(%rbp)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm5
xorps %xmm2, %xmm2
jbe 0x1a5fc
movss 0x141c(%r14), %xmm2
addss %xmm5, %xmm2
movaps %xmm5, -0x110(%rbp)
addss %xmm3, %xmm2
addss %xmm4, %xmm1
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
leaq -0x120(%rbp), %rbx
movq %r15, (%rbx)
movlps %xmm2, 0x8(%rbx)
movq %rbx, %rdi
movaps %xmm3, -0x60(%rbp)
movaps %xmm4, -0xc0(%rbp)
callq 0x9af8
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x9b28
testb %al, %al
je 0x1aa08
movq %r15, %rax
shrq $0x20, %rax
movq %r15, %xmm0
movdqa %xmm0, -0xb0(%rbp)
movd %eax, %xmm0
movdqa %xmm0, -0xa0(%rbp)
movl %r15d, -0x30(%rbp)
movss 0x1408(%r14), %xmm0
addss %xmm0, %xmm0
addss 0x1718(%r14), %xmm0
movss %xmm0, -0x90(%rbp)
movl -0x2c(%rbp), %esi
leaq -0xf0(%rbp), %rdi
xorl %edx, %edx
callq 0x9d62
movq %r12, %rbx
movl %eax, %r12d
movaps -0x60(%rbp), %xmm0
subss -0x90(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
unpcklps -0xc0(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movq %r15, -0xe0(%rbp)
movlps %xmm0, -0xd8(%rbp)
pushq $0x6
popq %rsi
movss 0x1bcc1(%rip), %xmm0    # 0x36390
movq %r13, %rdi
callq 0x1eae4
movss 0x1410(%r14), %xmm2
pushq $0x1
popq %rsi
movaps -0xb0(%rbp), %xmm0
movaps -0xd0(%rbp), %xmm1
movl %eax, %edi
callq 0xc76b
movb %r12b, -0xb0(%rbp)
movzbl %r12b, %esi
addl $0x15, %esi
movq %r13, %rdi
movss 0x1bc7f(%rip), %xmm0    # 0x36390
callq 0x1eae4
movss 0x1410(%r14), %xmm2
movaps -0x90(%rbp), %xmm0
unpcklps -0xa0(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movaps -0xd0(%rbp), %xmm1
movl %eax, %edi
pushq $0x1
popq %rsi
callq 0xc76b
movaps -0x90(%rbp), %xmm1
addss 0x1408(%r14), %xmm1
movss 0x140c(%r14), %xmm0
addss -0xa0(%rbp), %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movaps %xmm1, %xmm0
pushq $0x1
popq %rdi
movss 0x1bc20(%rip), %xmm1    # 0x36390
xorl %esi, %esi
callq 0xc888
movq -0x48(%rbp), %rax
movl (%rax), %esi
testl %esi, %esi
sets %al
cmpl %ebx, %esi
setge %cl
orb %al, %cl
jne 0x1a7e3
leaq -0x38(%rbp), %rdx
movq -0x70(%rbp), %rdi
callq *-0x68(%rbp)
testb %al, %al
je 0x1a7e3
leaq -0xd8(%rbp), %rsi
movss 0x1408(%r14), %xmm0
addss -0x30(%rbp), %xmm0
movss 0x140c(%r14), %xmm1
addss -0xa0(%rbp), %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
leaq -0x78(%rbp), %rdi
movlps %xmm0, (%rdi)
movq -0x38(%rbp), %rdx
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
pushq $0x9
popq %r9
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xc49f
xorps %xmm0, %xmm0
movaps -0x110(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1a821
movss 0x141c(%r14), %xmm0
addss -0x60(%rbp), %xmm0
movaps -0xa0(%rbp), %xmm1
addss 0x140c(%r14), %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
pushq $0x1
popq %rdx
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0xc16e
cmpb $0x0, -0xb0(%rbp)
je 0x1a872
movl -0x2c(%rbp), %edi
movl %edi, 0x1788(%r14)
cmpb $0x1, 0x354(%r14)
jne 0x1a872
movq 0x35c3b(%rip), %rax     # 0x50480
andl $0x0, 0x1790(%rax)
movw $0x1, 0x1799(%rax)
andq $0x0, 0x17a0(%rax)
callq 0xfa41
testb %al, %al
je 0x1aa33
movl -0x2c(%rbp), %edi
callq 0xfaff
xorl %r12d, %r12d
movl -0x2c(%rbp), %edi
callq 0xfa41
testb %al, %al
je 0x1aa08
movl -0x4c(%rbp), %ecx
testl %ecx, %ecx
pushq $0x7
popq %rax
cmovnsl %ecx, %eax
movaps -0x100(%rbp), %xmm1
addss 0x1418(%r14), %xmm1
cmpl %eax, %ebx
cmovll %ebx, %eax
cvtsi2ss %eax, %xmm0
mulss %xmm1, %xmm0
movss 0x140c(%r14), %xmm1
mulss 0x1bb32(%rip), %xmm1    # 0x363f0
leaq 0x1408(%r14), %rsi
addss %xmm0, %xmm1
movaps -0xc0(%rbp), %xmm2
addss %xmm2, %xmm1
movss 0xc(%r14), %xmm0
subss 0x1454(%r14), %xmm0
minss %xmm0, %xmm1
movq 0x35b92(%rip), %rax     # 0x50480
movl %r15d, 0x1818(%rax)
movss %xmm2, 0x181c(%rax)
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x1834(%rax)
movaps -0x60(%rbp), %xmm0
subss -0x30(%rbp), %xmm0
subss %xmm2, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movlps %xmm0, 0x1820(%rax)
pushq $0x1
popq %rdi
callq 0x116b2
movl $0x80, %esi
andl 0xc(%r13), %esi
orl $0x800000, %esi         # imm = 0x800000
movq -0x40(%rbp), %rdi
callq 0xf89b
xorl %r13d, %r13d
testb %al, %al
je 0x1aa29
callq 0x1ab17
testl %ebx, %ebx
cmovlel %r13d, %ebx
movq %rbx, %r14
xorb $0x1, %r12b
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x1aa24
movq %rbx, %rdi
callq 0x12e66
movq -0x48(%rbp), %rax
movl (%rax), %r15d
movq -0x70(%rbp), %rdi
movl %ebx, %esi
leaq -0x38(%rbp), %rdx
callq *-0x68(%rbp)
testb %al, %al
je 0x1a993
movq -0x38(%rbp), %rdi
jmp 0x1a99e
leaq 0x1cc9f(%rip), %rdi     # 0x37639
movq %rdi, -0x38(%rbp)
xorl %esi, %esi
cmpq %r15, %rbx
sete %sil
andq $0x0, -0x78(%rbp)
xorl %edx, %edx
leaq -0x78(%rbp), %rcx
callq 0x1ab4d
testb %al, %al
je 0x1a9e3
movq 0x35abe(%rip), %rax     # 0x50480
andl $0x0, 0x1790(%rax)
movw $0x1, 0x1799(%rax)
andq $0x0, 0x17a0(%rax)
movq -0x48(%rbp), %rax
movl %ebx, (%rax)
movb $0x1, %r13b
cmpq %r15, %rbx
setne %al
orb %r12b, %al
jne 0x1a9fb
movss 0x1b9da(%rip), %xmm0    # 0x363d0
callq 0x12159
callq 0x12ea2
incq %rbx
jmp 0x1a964
xorl %r13d, %r13d
andb $0x1, %r13b
movl %r13d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xfa7a
pushq $0x1
popq %rdi
callq 0xfb23
jmp 0x1aa0b
movq %r13, %rdi
callq 0xb5a3
movq -0x40(%rbp), %rdi
callq 0xf6de
movb $0x1, %r12b
jmp 0x1a875