// File: 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
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
leaq 0xd3e36(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jl 0x13f141
movq -0x18(%rbp), %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jge 0x13f141
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl (%rcx), %esi
leaq -0x40(%rbp), %rdx
callq *%rax
cmpl $-0x1, -0x30(%rbp)
je 0x13f198
movq -0x38(%rbp), %rax
movl 0x1b88(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x13f198
leaq -0x48(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
movl -0x30(%rbp), %edi
callq 0x13f040
movaps %xmm0, %xmm1
leaq -0x50(%rbp), %rdi
movss 0x32e35(%rip), %xmm0    # 0x171fb4
callq 0xbf4c0
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0xdac00
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x13e6c0
testb $0x1, %al
jne 0x13f1b4
movb $0x0, -0x1(%rbp)
jmp 0x13f293
movb $0x0, -0x51(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x13f26a
movslq -0x58(%rbp), %rdi
callq 0xdb500
movl -0x58(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
sete %al
andb $0x1, %al
movb %al, -0x59(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rdi
movl -0x58(%rbp), %esi
leaq -0x68(%rbp), %rdx
callq *%rax
testb $0x1, %al
jne 0x13f205
leaq 0x4f6c5(%rip), %rax     # 0x18e8c6
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movb -0x59(%rbp), %al
movb %al, -0x79(%rbp)
leaq -0x70(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
movb -0x79(%rbp), %al
movq -0x78(%rbp), %rdi
xorl %edx, %edx
leaq -0x70(%rbp), %rcx
andb $0x1, %al
movzbl %al, %esi
callq 0x13f2b0
testb $0x1, %al
jne 0x13f23f
jmp 0x13f24c
movb $0x1, -0x51(%rbp)
movl -0x58(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
testb $0x1, -0x59(%rbp)
je 0x13f257
callq 0xdb110
callq 0xdb640
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x13f1bf
callq 0x13f0d0
testb $0x1, -0x51(%rbp)
je 0x13f28b
movq -0x38(%rbp), %rax
movq 0x1ae0(%rax), %rax
movl 0x124(%rax), %edi
callq 0xca110
movb -0x51(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)