// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::TabBarTabListPopupButton(ImGuiTabBar*)
static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;

    // We use g.Style.FramePadding.y to match the square ArrowButton size
    const float tab_list_popup_button_width = g.FontSize + g.Style.FramePadding.y;
    const ImVec2 backup_cursor_pos = window->DC.CursorPos;
    window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x - g.Style.FramePadding.y, tab_bar->BarRect.Min.y);
    tab_bar->BarRect.Min.x += tab_list_popup_button_width;

    ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text];
    arrow_col.w *= 0.5f;
    PushStyleColor(ImGuiCol_Text, arrow_col);
    PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
    bool open = BeginCombo("##v", NULL, ImGuiComboFlags_NoPreview | ImGuiComboFlags_HeightLargest);
    PopStyleColor(2);

    ImGuiTabItem* tab_to_select = NULL;
    if (open)
    {
        for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
        {
            ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
            if (tab->Flags & ImGuiTabItemFlags_Button)
                continue;

            const char* tab_name = tab_bar->GetTabName(tab);
            if (Selectable(tab_name, tab_bar->SelectedTabId == tab->ID))
                tab_to_select = tab;
        }
        EndCombo();
    }

    window->DC.CursorPos = backup_cursor_pos;
    return tab_to_select;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xb868a(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x1ae0(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movss 0x1980(%rax), %xmm0
movq -0x10(%rbp), %rax
addss 0x159c(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movss 0x2c(%rax), %xmm0
movq -0x10(%rbp), %rax
subss 0x159c(%rax), %xmm0
movq -0x8(%rbp), %rax
movss 0x30(%rax), %xmm1
leaq -0x2c(%rbp), %rdi
callq 0xbf4c0
movq -0x18(%rbp), %rax
movq -0x2c(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movss -0x1c(%rbp), %xmm0
movq -0x8(%rbp), %rax
addss 0x2c(%rax), %xmm0
movss %xmm0, 0x2c(%rax)
movq -0x10(%rbp), %rax
movq 0x1624(%rax), %rcx
movq %rcx, -0x3c(%rbp)
movq 0x162c(%rax), %rax
movq %rax, -0x34(%rbp)
movss 0x17675(%rip), %xmm0    # 0x171fd8
mulss -0x30(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
xorl %edi, %edi
leaq -0x3c(%rbp), %rsi
callq 0xc78f0
leaq -0x4c(%rbp), %rdi
xorps %xmm3, %xmm3
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0xbf4f0
movl $0x15, %edi
leaq -0x4c(%rbp), %rsi
callq 0xc78f0
leaq 0x226b2(%rip), %rdi     # 0x17d054
xorl %eax, %eax
movl %eax, %esi
movl $0x50, %edx
callq 0x13e6c0
andb $0x1, %al
movb %al, -0x4d(%rbp)
movl $0x2, %edi
callq 0xc7990
movq $0x0, -0x58(%rbp)
testb $0x1, -0x4d(%rbp)
je 0x15aa86
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x15aa81
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0xecb00
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200000, %eax         # imm = 0x200000
cmpl $0x0, %eax
je 0x15aa0a
jmp 0x15aa73
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0xecb80
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x68(%rbp), %rcx
cmpl (%rcx), %eax
sete %al
movb %al, -0x81(%rbp)
leaq -0x78(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
movb -0x81(%rbp), %al
movq -0x80(%rbp), %rdi
movzbl %al, %esi
andl $0x1, %esi
xorl %edx, %edx
leaq -0x78(%rbp), %rcx
callq 0x13f2b0
testb $0x1, %al
jne 0x15aa69
jmp 0x15aa71
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x15aa73
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x15a9d8
callq 0x13f0d0
movq -0x18(%rbp), %rax
movq -0x24(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movq -0x58(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)