// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.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 popup_max_height_in_items)
{
    ImGuiContext& g = *GImGui;

    // Call the getter to obtain the preview string which is a parameter to BeginCombo()
    const char* preview_value = NULL;
    if (*current_item >= 0 && *current_item < items_count)
        items_getter(data, *current_item, &preview_value);

    // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here.
    if (popup_max_height_in_items != -1 && !(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint))
        SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items)));

    if (!BeginCombo(label, preview_value, ImGuiComboFlags_None))
        return false;

    // Display items
    // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed)
    bool value_changed = false;
    for (int i = 0; i < items_count; i++)
    {
        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 (Selectable(item_text, item_selected))
        {
            value_changed = true;
            *current_item = i;
        }
        if (item_selected)
            SetItemDefaultFocus();
        PopID();
    }

    EndCombo();
    if (value_changed)
        MarkItemEdited(g.CurrentWindow->DC.LastItemId);

    return value_changed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r13d
movl %r8d, %ebx
movq %rcx, -0x48(%rbp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
andq $0x0, -0x50(%rbp)
leaq 0x665f7(%rip), %rax     # 0xe3ce0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movl (%rsi), %esi
testl %esi, %esi
sets %al
cmpl %r8d, %esi
setge %cl
orb %al, %cl
jne 0x7d70c
leaq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rdi
callq *%r15
cmpl $-0x1, %r13d
je 0x7d74b
movq -0x38(%rbp), %rax
testb $0x10, 0x1b88(%rax)
jne 0x7d74b
leaq -0x30(%rbp), %rax
andq $0x0, (%rax)
movl %r13d, %edi
callq 0x7d661
leaq -0x58(%rbp), %rsi
movl $0x7f7fffff, (%rsi)     # imm = 0x7F7FFFFF
movss %xmm0, 0x4(%rsi)
leaq -0x30(%rbp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x429f0
movq -0x50(%rbp), %rsi
xorl %r13d, %r13d
movq %r14, %rdi
xorl %edx, %edx
callq 0x7cfa7
testb %al, %al
je 0x7d80a
testl %ebx, %ebx
cmovlel %r13d, %ebx
movq $0x0, -0x40(%rbp)
cmpq %r13, %rbx
je 0x7d7e1
movq %r13, %rdi
callq 0x42f1f
movl (%r12), %r14d
movq -0x48(%rbp), %rdi
movl %r13d, %esi
leaq -0x30(%rbp), %rdx
callq *%r15
testb %al, %al
je 0x7d79b
movq -0x30(%rbp), %rdi
jmp 0x7d7a6
leaq 0x3b0cc(%rip), %rdi     # 0xb886e
movq %rdi, -0x30(%rbp)
xorl %esi, %esi
cmpq %r14, %r13
sete %sil
andq $0x0, -0x58(%rbp)
xorl %edx, %edx
leaq -0x58(%rbp), %rcx
callq 0x7d81c
testb %al, %al
je 0x7d7cd
movl %r13d, (%r12)
movb $0x1, %al
movq %rax, -0x40(%rbp)
cmpq %r14, %r13
jne 0x7d7d7
callq 0x42cc0
callq 0x42fea
incq %r13
jmp 0x7d772
callq 0x44bbe
testb $0x1, -0x40(%rbp)
je 0x7d807
movq -0x38(%rbp), %rax
movq 0x1ae0(%rax), %rax
movl 0x124(%rax), %edi
callq 0x3749e
movb $0x1, %r13b
jmp 0x7d80a
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq