// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::BeginTabBarEx(ImGuiTabBar*, ImRect const&, int)
bool    ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    if (window->SkipItems)
        return false;

    if ((flags & ImGuiTabBarFlags_DockNode) == 0)
        PushOverrideID(tab_bar->ID);

    // Add to stack
    g.CurrentTabBarStack.push_back(GetTabBarRefFromTabBar(tab_bar));
    g.CurrentTabBar = tab_bar;

    // Append with multiple BeginTabBar()/EndTabBar() pairs.
    tab_bar->BackupCursorPos = window->DC.CursorPos;
    if (tab_bar->CurrFrameVisible == g.FrameCount)
    {
        window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
        tab_bar->BeginCount++;
        return true;
    }

    // Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable
    if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable)))
        if (tab_bar->Tabs.Size > 1)
            ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder);
    tab_bar->TabsAddedNew = false;

    // Flags
    if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
        flags |= ImGuiTabBarFlags_FittingPolicyDefault_;

    tab_bar->Flags = flags;
    tab_bar->BarRect = tab_bar_bb;
    tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab()
    tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible;
    tab_bar->CurrFrameVisible = g.FrameCount;
    tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight;
    tab_bar->CurrTabsContentsHeight = 0.0f;
    tab_bar->ItemSpacingY = g.Style.ItemSpacing.y;
    tab_bar->FramePadding = g.Style.FramePadding;
    tab_bar->TabsActiveCount = 0;
    tab_bar->BeginCount = 1;

    // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap
    window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);

    // Draw separator
    const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
    const float y = tab_bar->BarRect.Max.y - 1.0f;
    {
        const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f);
        const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f);
        window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f);
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq 0xbd563(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x1ae0(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x155a09
movb $0x0, -0x1(%rbp)
jmp 0x155d1b
movl -0x1c(%rbp), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
jne 0x155a22
movq -0x10(%rbp), %rax
movl 0x14(%rax), %edi
callq 0xdb5a0
movq -0x28(%rbp), %rax
addq $0x2138, %rax           # imm = 0x2138
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
callq 0x155d30
movq -0x88(%rbp), %rdi
movl %edx, -0x48(%rbp)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x40(%rbp), %rsi
callq 0x136f50
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x2108(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0xd8(%rcx), %rcx
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1a68(%rcx), %eax
jne 0x155ae2
movq -0x10(%rbp), %rax
movss 0x2c(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x38(%rax), %xmm1
movq -0x10(%rbp), %rax
addss 0x74(%rax), %xmm1
leaq -0x58(%rbp), %rdi
callq 0xbf4c0
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movq -0x10(%rbp), %rax
movb 0x69(%rax), %cl
addb $0x1, %cl
movb %cl, 0x69(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x155d1b
movl -0x1c(%rbp), %eax
andl $0x1, %eax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
andl $0x1, %ecx
cmpl %ecx, %eax
jne 0x155b0b
movq -0x10(%rbp), %rax
testb $0x1, 0x6c(%rax)
je 0x155b36
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x155b36
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x155b34
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rsi
movl $0x24, %edx
leaq 0x271(%rip), %rcx       # 0x155da0
callq 0xd6c0
jmp 0x155b36
movq -0x10(%rbp), %rax
movb $0x0, 0x6c(%rax)
movl -0x1c(%rbp), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
jne 0x155b54
movl -0x1c(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x2c(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x34(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x6a(%rax)
movq -0x10(%rbp), %rax
movl 0x24(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movl 0x1a68(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x10(%rbp), %rax
movss 0x3c(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x40(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x3c(%rax)
movq -0x28(%rbp), %rax
movss 0x15ac(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x74(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x1598(%rcx), %rcx
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x6e(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x69(%rax)
movq -0x10(%rbp), %rax
movss 0x2c(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x38(%rax), %xmm1
movq -0x10(%rbp), %rax
addss 0x74(%rax), %xmm1
leaq -0x60(%rbp), %rdi
callq 0xbf4c0
movq -0x30(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movl -0x1c(%rbp), %ecx
andl $0x200000, %ecx         # imm = 0x200000
movl $0x25, %edi
movl $0x23, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edi
movss 0x1aff4(%rip), %xmm0    # 0x170c3c
callq 0xc76e0
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
movss 0x38(%rax), %xmm0
movss 0x1afdb(%rip), %xmm1    # 0x170c3c
subss %xmm1, %xmm0
movss %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movss 0x2c(%rax), %xmm0
movq -0x30(%rbp), %rax
movss 0x1c359(%rip), %xmm1    # 0x171fd8
mulss 0x40(%rax), %xmm1
cvttss2si %xmm1, %eax
cvtsi2ss %eax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0x6c(%rbp)
movq -0x10(%rbp), %rax
movss 0x34(%rax), %xmm0
movq -0x30(%rbp), %rax
movss 0x1c32e(%rip), %xmm1    # 0x171fd8
mulss 0x40(%rax), %xmm1
cvttss2si %xmm1, %eax
cvtsi2ss %eax, %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq 0x2b8(%rax), %rax
movq %rax, -0x90(%rbp)
movss -0x6c(%rbp), %xmm0
movss -0x68(%rbp), %xmm1
leaq -0x78(%rbp), %rdi
callq 0xbf4c0
movss -0x70(%rbp), %xmm0
movss -0x68(%rbp), %xmm1
leaq -0x80(%rbp), %rdi
callq 0xbf4c0
movq -0x90(%rbp), %rdi
movl -0x64(%rbp), %ecx
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movss 0x1af2a(%rip), %xmm0    # 0x170c3c
callq 0x112e20
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)