// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::BeginCombo(char const*, char const*, int)
bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags)
{
    // Always consume the SetNextWindowSizeConstraint() call in our early return paths
    ImGuiContext& g = *GImGui;
    bool has_window_size_constraint = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) != 0;
    g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint;

    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together

    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);

    const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
    const ImVec2 label_size = CalcTextSize(label, NULL, true);
    const float expected_w = CalcItemWidth();
    const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : expected_w;
    const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 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, &frame_bb))
        return false;

    bool hovered, held;
    bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
    bool popup_open = IsPopupOpen(id, ImGuiPopupFlags_None);

    const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
    const float value_x2 = ImMax(frame_bb.Min.x, frame_bb.Max.x - arrow_size);
    RenderNavHighlight(frame_bb, id);
    if (!(flags & ImGuiComboFlags_NoPreview))
        window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(value_x2, frame_bb.Max.y), frame_col, style.FrameRounding, (flags & ImGuiComboFlags_NoArrowButton) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Left);
    if (!(flags & ImGuiComboFlags_NoArrowButton))
    {
        ImU32 bg_col = GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
        ImU32 text_col = GetColorU32(ImGuiCol_Text);
        window->DrawList->AddRectFilled(ImVec2(value_x2, frame_bb.Min.y), frame_bb.Max, bg_col, style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right);
        if (value_x2 + arrow_size - style.FramePadding.x <= frame_bb.Max.x)
            RenderArrow(window->DrawList, ImVec2(value_x2 + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), text_col, ImGuiDir_Down, 1.0f);
    }
    RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding);
    if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview))
        RenderTextClipped(frame_bb.Min + style.FramePadding, ImVec2(value_x2, frame_bb.Max.y), preview_value, NULL, NULL, ImVec2(0.0f, 0.0f));
    if (label_size.x > 0)
        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);

    if ((pressed || g.NavActivateId == id) && !popup_open)
    {
        if (window->DC.NavLayerCurrent == 0)
            window->NavLastIds[0] = id;
        OpenPopupEx(id, ImGuiPopupFlags_None);
        popup_open = true;
    }

    if (!popup_open)
        return false;

    if (has_window_size_constraint)
    {
        g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint;
        g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w);
    }
    else
    {
        if ((flags & ImGuiComboFlags_HeightMask_) == 0)
            flags |= ImGuiComboFlags_HeightRegular;
        IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiComboFlags_HeightMask_));    // Only one
        int popup_max_height_in_items = -1;
        if (flags & ImGuiComboFlags_HeightRegular)     popup_max_height_in_items = 8;
        else if (flags & ImGuiComboFlags_HeightSmall)  popup_max_height_in_items = 4;
        else if (flags & ImGuiComboFlags_HeightLarge)  popup_max_height_in_items = 20;
        SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items)));
    }

    char name[16];
    ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth

    // Position the window given a custom constraint (peak into expected window size so we can position it)
    // This might be easier to express with an hypothetical SetNextWindowPosConstraints() function.
    if (ImGuiWindow* popup_window = FindWindowByName(name))
        if (popup_window->WasActive)
        {
            // Always override 'AutoPosLastDirection' to not leave a chance for a past value to affect us.
            ImVec2 size_expected = CalcWindowNextAutoFitSize(popup_window);
            if (flags & ImGuiComboFlags_PopupAlignLeft)
                popup_window->AutoPosLastDirection = ImGuiDir_Left; // "Below, Toward Left"
            else
                popup_window->AutoPosLastDirection = ImGuiDir_Down; // "Below, Toward Right (default)"
            ImRect r_outer = GetWindowAllowedExtentRect(popup_window);
            ImVec2 pos = FindBestWindowPosForPopupEx(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, r_outer, frame_bb, ImGuiPopupPositionPolicy_ComboBox);
            SetNextWindowPos(pos);
        }

    // We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx()
    ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove;

    // Horizontally align ourselves with the framed text
    PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(style.FramePadding.x, style.WindowPadding.y));
    bool ret = Begin(name, NULL, window_flags);
    PopStyleVar();
    if (!ret)
    {
        EndPopup();
        IM_ASSERT(0);   // This should never happen as we tested for IsPopupOpen() above
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
leaq 0x66d1e(%rip), %rax     # 0xe3ce0
movq (%rax), %r12
movl 0x1b88(%r12), %r15d
movl %r15d, %eax
andl $-0x11, %eax
movl %eax, 0x1b88(%r12)
movq 0x1ae0(%r12), %r14
movb $0x1, 0x90(%r14)
cmpb $0x0, 0x93(%r14)
jne 0x7d3f1
movl %edx, %r13d
movq %rsi, -0xd8(%rbp)
movl %edx, %eax
notl %eax
testb $0x60, %al
je 0x7d5ff
movq %rdi, %rcx
movq %r14, %rdi
movq %rcx, -0x98(%rbp)
movq %rcx, %rsi
xorl %edx, %edx
callq 0x3700a
movl %eax, %ebx
xorps %xmm0, %xmm0
testb $0x20, %r13b
jne 0x7d036
callq 0x43ec9
movss %xmm0, -0x34(%rbp)
pushq $0x1
popq %rdx
movss 0x1efaa(%rip), %xmm0    # 0x9bff0
movq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x365e8
movaps %xmm0, -0xd0(%rbp)
callq 0x43d17
movss -0x34(%rbp), %xmm3
testb $0x40, %r13b
jne 0x7d06e
movaps %xmm0, %xmm3
movl %r13d, -0x30(%rbp)
movaps -0xd0(%rbp), %xmm5
movaps %xmm5, %xmm2
shufps $0x55, %xmm5, %xmm2     # xmm2 = xmm2[1,1],xmm5[1,1]
movss 0x159c(%r12), %xmm0
movaps %xmm0, %xmm1
addss %xmm0, %xmm1
addss %xmm2, %xmm1
movss 0xd8(%r14), %xmm2
movaps %xmm3, -0xb0(%rbp)
addss %xmm3, %xmm2
addss 0xdc(%r14), %xmm1
movaps %xmm2, %xmm3
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
movq 0xd8(%r14), %rax
movq %rax, -0x50(%rbp)
movlps %xmm3, -0x48(%rbp)
xorps %xmm4, %xmm4
ucomiss %xmm4, %xmm5
xorps %xmm3, %xmm3
jbe 0x7d0e4
movss 0x15b0(%r12), %xmm3
addss -0xd0(%rbp), %xmm3
addss %xmm2, %xmm3
addss %xmm4, %xmm1
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
leaq -0x110(%rbp), %r13
movq %rax, (%r13)
movlps %xmm3, 0x8(%r13)
movq %r13, %rdi
callq 0x4388d
leaq -0x50(%rbp), %rdx
movq %r13, %rdi
movl %ebx, %esi
callq 0x40ea5
testb %al, %al
je 0x7d3f1
movl %r15d, -0x74(%rbp)
leaq -0x50(%rbp), %r13
leaq -0x2b(%rbp), %r15
leaq -0x51(%rbp), %rcx
movq %r13, %rdi
movl %ebx, %esi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x79dde
movb %al, -0x29(%rbp)
movl %ebx, %edi
xorl %esi, %esi
callq 0x384af
movb %al, -0x2a(%rbp)
movzbl (%r15), %edi
addl $0x7, %edi
movss 0x1ee9d(%rip), %xmm0    # 0x9bff8
callq 0x35d33
movl %eax, %r15d
movss (%r13), %xmm0
movaps %xmm0, -0x70(%rbp)
movss 0x8(%r13), %xmm0
movaps %xmm0, -0xc0(%rbp)
pushq $0x1
popq %rdx
movq %r13, %rdi
movl %ebx, %r13d
movl %ebx, %esi
callq 0x36c91
movaps -0xc0(%rbp), %xmm0
subss -0x34(%rbp), %xmm0
movaps %xmm0, %xmm1
movaps %xmm0, %xmm3
movaps -0x70(%rbp), %xmm2
cmpless %xmm2, %xmm1
movaps %xmm1, %xmm0
andnps %xmm3, %xmm0
andps %xmm2, %xmm1
orps %xmm0, %xmm1
movaps %xmm1, -0x70(%rbp)
movl -0x30(%rbp), %ebx
testb $0x40, %bl
jne 0x7d201
testb $0x20, %bl
movq 0x2b8(%r14), %rdi
leaq -0x50(%rbp), %rsi
movss 0xc(%rsi), %xmm0
leaq -0x90(%rbp), %rdx
movaps -0x70(%rbp), %xmm1
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
movss 0x15a0(%r12), %xmm0
pushq $0x5
popq %rax
pushq $0xf
popq %r8
cmovel %eax, %r8d
movl %r15d, %ecx
callq 0x64020
testb $0x20, %bl
movb -0x2a(%rbp), %bl
jne 0x7d2ea
movb -0x2b(%rbp), %al
orb %bl, %al
movzbl %al, %edi
andl $0x1, %edi
addl $0x15, %edi
movss 0x1edd5(%rip), %xmm0    # 0x9bff8
callq 0x35d33
movl %eax, %r15d
xorl %edi, %edi
movss 0x1edc3(%rip), %xmm0    # 0x9bff8
callq 0x35d33
movl %eax, -0xc0(%rbp)
movq 0x2b8(%r14), %rdi
leaq -0x48(%rbp), %rdx
movss -0x4(%rdx), %xmm0
leaq -0x90(%rbp), %rsi
movaps -0x70(%rbp), %xmm1
movss %xmm1, (%rsi)
movss %xmm0, 0x4(%rsi)
movss 0x15a0(%r12), %xmm0
xorl %eax, %eax
movss -0x34(%rbp), %xmm1
ucomiss -0xb0(%rbp), %xmm1
setae %al
leal (%rax,%rax,4), %r8d
addl $0xa, %r8d
movl %r15d, %ecx
callq 0x64020
movss -0x34(%rbp), %xmm0
addss -0x70(%rbp), %xmm0
subss 0x1598(%r12), %xmm0
movaps %xmm0, %xmm1
leaq -0x48(%rbp), %rax
movss (%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x7d2ea
movq 0x2b8(%r14), %rdi
movss 0x159c(%r12), %xmm1
movaps -0x70(%rbp), %xmm0
addss %xmm1, %xmm0
addss -0x4c(%rbp), %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
pushq $0x3
popq %rdx
movss 0x1ed19(%rip), %xmm1    # 0x9bff8
movl -0xc0(%rbp), %esi
callq 0x6b8b0
movl -0x30(%rbp), %r15d
andl $0x40, %r15d
shrl $0x6, %r15d
movsd -0x50(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movss 0x15a0(%r12), %xmm2
callq 0x36b98
movq -0xd8(%rbp), %rdx
testq %rdx, %rdx
sete %al
orb %r15b, %al
jne 0x7d37f
movss -0x50(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
addss 0x1598(%r12), %xmm0
addss 0x159c(%r12), %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
leaq -0x90(%rbp), %rdi
movlps %xmm0, (%rdi)
movss -0x44(%rbp), %xmm0
leaq -0xf0(%rbp), %rsi
movaps -0x70(%rbp), %xmm1
movss %xmm1, (%rsi)
movss %xmm0, 0x4(%rsi)
leaq -0xf8(%rbp), %r9
andq $0x0, (%r9)
andq $0x0, (%rsp)
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x36673
xorps %xmm0, %xmm0
movaps -0xd0(%rbp), %xmm1
ucomiss %xmm0, %xmm1
movl -0x74(%rbp), %r15d
jbe 0x7d3c4
movss -0x48(%rbp), %xmm0
addss 0x15b0(%r12), %xmm0
movss -0x4c(%rbp), %xmm1
addss 0x159c(%r12), %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
pushq $0x1
popq %rdx
movq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x36156
cmpb $0x0, -0x29(%rbp)
je 0x7d3d7
testb %bl, %bl
movaps -0xb0(%rbp), %xmm2
jne 0x7d41a
jmp 0x7d3f8
cmpl %r13d, 0x1ca0(%r12)
setne %al
orb %bl, %al
movaps -0xb0(%rbp), %xmm2
je 0x7d3f8
testb %bl, %bl
jne 0x7d41a
xorl %eax, %eax
jmp 0x7d5ed
cmpl $0x0, 0x14c(%r14)
jne 0x7d409
movl %r13d, 0x3b0(%r14)
movl %r13d, %edi
xorl %esi, %esi
callq 0x4472e
movaps -0xb0(%rbp), %xmm2
testb $0x10, %r15b
jne 0x7d461
movl -0x30(%rbp), %eax
movl %eax, %r15d
orl $0x4, %r15d
testb $0x1e, %al
cmovnel %eax, %r15d
movl %r15d, %eax
andl $0x1e, %eax
leal -0x1(%rax), %ecx
xorl %ecx, %eax
cmpl %ecx, %eax
jbe 0x7d642
testb $0x4, %r15b
jne 0x7d495
testb $0x2, %r15b
jne 0x7d499
movl %r15d, %eax
andl $0x8, %eax
xorl %edi, %edi
cmpl $0x1, %eax
sbbl %edi, %edi
orl $0x14, %edi
jmp 0x7d49c
orb $0x10, 0x1b88(%r12)
movss 0x1bc4(%r12), %xmm0
movaps %xmm2, %xmm1
cmpless %xmm0, %xmm1
andps %xmm1, %xmm0
andnps %xmm2, %xmm1
orps %xmm0, %xmm1
movss %xmm1, 0x1bc4(%r12)
movl -0x30(%rbp), %r15d
jmp 0x7d4ce
pushq $0x8
jmp 0x7d49b
pushq $0x4
popq %rdi
leaq -0x90(%rbp), %rbx
movss %xmm2, (%rbx)
andl $0x0, 0x4(%rbx)
callq 0x7d661
leaq -0xf0(%rbp), %rsi
movl $0x7f7fffff, (%rsi)     # imm = 0x7F7FFFFF
movss %xmm0, 0x4(%rsi)
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x429f0
movl 0x1c80(%r12), %ecx
leaq 0x3b384(%rip), %rdx     # 0xb8861
leaq -0x90(%rbp), %rbx
pushq $0x10
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3468c
movq %rbx, %rdi
callq 0x412c3
testq %rax, %rax
je 0x7d59b
movq %rax, %r14
cmpb $0x1, 0x8f(%rax)
jne 0x7d59b
movq %r14, %rdi
callq 0x412d8
leaq -0xf8(%rbp), %rbx
movlps %xmm0, (%rbx)
xorl %eax, %eax
testb $0x1, %r15b
sete %al
leal (%rax,%rax,2), %eax
movq %r14, %r15
addq $0xa8, %r15
movl %eax, 0xa8(%r14)
movq %r14, %rdi
callq 0x4539b
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
leaq -0xf0(%rbp), %rcx
movups %xmm0, (%rcx)
leaq -0x50(%rbp), %r8
movaps (%r8), %xmm0
shufps $0xec, %xmm0, %xmm0     # xmm0 = xmm0[0,3,2,3]
leaq -0xe0(%rbp), %r14
movlps %xmm0, (%r14)
pushq $0x1
popq %r9
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x44ffe
leaq -0x100(%rbp), %rdi
movlps %xmm0, (%rdi)
andq $0x0, (%r14)
leaq -0xe0(%rbp), %rdx
xorl %esi, %esi
callq 0x42997
movss 0x1568(%r12), %xmm0
movss 0x1598(%r12), %xmm1
leaq -0xf0(%rbp), %rsi
movss %xmm1, (%rsi)
movss %xmm0, 0x4(%rsi)
pushq $0x1
popq %rbx
movl %ebx, %edi
callq 0x35fca
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x4000147, %edx        # imm = 0x4000147
callq 0x3bad8
movl %eax, %r14d
movl %ebx, %edi
callq 0x3605c
testb %r14b, %r14b
je 0x7d61e
movb $0x1, %al
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b15e(%rip), %rdi     # 0xb8764
leaq 0x3ad7b(%rip), %rsi     # 0xb8388
leaq 0x3b1d5(%rip), %rcx     # 0xb87e9
movl $0x609, %edx            # imm = 0x609
callq 0xc140
callq 0x44bbe
leaq 0x21af2(%rip), %rdi     # 0x9f11c
leaq 0x3ad57(%rip), %rsi     # 0xb8388
leaq 0x3b1b1(%rip), %rcx     # 0xb87e9
movl $0x668, %edx            # imm = 0x668
callq 0xc140
leaq 0x3b1e4(%rip), %rdi     # 0xb882d
leaq 0x3ad38(%rip), %rsi     # 0xb8388
leaq 0x3b192(%rip), %rcx     # 0xb87e9
movl $0x643, %edx            # imm = 0x643
callq 0xc140