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

    const ImVec2 arrow_button_size(g.FontSize - 2.0f, g.FontSize + g.Style.FramePadding.y * 2.0f);
    const float scrolling_buttons_width = arrow_button_size.x * 2.0f;

    const ImVec2 backup_cursor_pos = window->DC.CursorPos;
    //window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255));

    int select_dir = 0;
    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));
    const float backup_repeat_delay = g.IO.KeyRepeatDelay;
    const float backup_repeat_rate = g.IO.KeyRepeatRate;
    g.IO.KeyRepeatDelay = 0.250f;
    g.IO.KeyRepeatRate = 0.200f;
    float x = ImMax(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.x - scrolling_buttons_width);
    window->DC.CursorPos = ImVec2(x, tab_bar->BarRect.Min.y);
    if (ArrowButtonEx("##<", ImGuiDir_Left, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat))
        select_dir = -1;
    window->DC.CursorPos = ImVec2(x + arrow_button_size.x, tab_bar->BarRect.Min.y);
    if (ArrowButtonEx("##>", ImGuiDir_Right, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat))
        select_dir = +1;
    PopStyleColor(2);
    g.IO.KeyRepeatRate = backup_repeat_rate;
    g.IO.KeyRepeatDelay = backup_repeat_delay;

    ImGuiTabItem* tab_to_scroll_to = NULL;
    if (select_dir != 0)
        if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId))
        {
            int selected_order = tab_bar->GetTabOrder(tab_item);
            int target_order = selected_order + select_dir;

            // Skip tab item buttons until another tab item is found or end is reached
            while (tab_to_scroll_to == NULL)
            {
                // If we are at the end of the list, still scroll to make our tab visible
                tab_to_scroll_to = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order];

                // Cross through buttons
                // (even if first/last item is a button, return it so we can update the scroll)
                if (tab_to_scroll_to->Flags & ImGuiTabItemFlags_Button)
                {
                    target_order += select_dir;
                    selected_order += select_dir;
                    tab_to_scroll_to = (target_order < 0 || target_order >= tab_bar->Tabs.Size) ? tab_to_scroll_to : NULL;
                }
            }
        }
    window->DC.CursorPos = backup_cursor_pos;
    tab_bar->BarRect.Max.x -= scrolling_buttons_width + 1.0f;

    return tab_to_scroll_to;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xb847a(%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), %xmm2
movss 0x3373c(%rip), %xmm1    # 0x18e22c
movaps %xmm2, %xmm0
addss %xmm1, %xmm0
movss 0x159c(%rax), %xmm1
addss %xmm1, %xmm1
addss %xmm2, %xmm1
leaq -0x20(%rbp), %rdi
callq 0xbf4c0
movss -0x20(%rbp), %xmm0
addss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movups 0x1624(%rax), %xmm0
movaps %xmm0, -0x50(%rbp)
movss -0x44(%rbp), %xmm0
movss 0x17488(%rip), %xmm1    # 0x171fd8
mulss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
xorl %edi, %edi
leaq -0x50(%rbp), %rsi
callq 0xc78f0
leaq -0x60(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
xorps %xmm3, %xmm3
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0xbf4f0
movq -0xb0(%rbp), %rsi
movl $0x15, %edi
callq 0xc78f0
movq -0x10(%rbp), %rax
movss 0x94(%rax), %xmm0
movss %xmm0, -0x64(%rbp)
movq -0x10(%rbp), %rax
movss 0x98(%rax), %xmm0
movss %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movl $0x3e800000, 0x94(%rax) # imm = 0x3E800000
movq -0x10(%rbp), %rax
movl $0x3e4ccccd, 0x98(%rax) # imm = 0x3E4CCCCD
movq -0x8(%rbp), %rax
movss 0x2c(%rax), %xmm0
movss 0x34(%rax), %xmm1
movss -0x24(%rbp), %xmm2
subss %xmm2, %xmm1
callq 0x139050
movss %xmm0, -0x6c(%rbp)
movss -0x6c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss 0x30(%rax), %xmm1
leaq -0x74(%rbp), %rdi
callq 0xbf4c0
movq -0x18(%rbp), %rax
movq -0x74(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
xorl %eax, %eax
leaq 0x35ceb(%rip), %rdi     # 0x190917
xorl %esi, %esi
movl $0x410, %edx            # imm = 0x410
callq 0x13ab40
testb $0x1, %al
jne 0x15ac3e
jmp 0x15ac45
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movss -0x6c(%rbp), %xmm0
movss -0x20(%rbp), %xmm1
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss 0x30(%rax), %xmm1
leaq -0x88(%rbp), %rdi
callq 0xbf4c0
movq -0x18(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
leaq 0x35c87(%rip), %rdi     # 0x19091b
movl $0x1, %esi
movl $0x410, %edx            # imm = 0x410
callq 0x13ab40
testb $0x1, %al
jne 0x15aca9
jmp 0x15acb0
movl $0x1, -0x34(%rbp)
movl $0x2, %edi
callq 0xc7990
movss -0x68(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x98(%rax)
movss -0x64(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x94(%rax)
movq $0x0, -0x98(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x15ae19
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x157030
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x15ae17
movq -0x8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x162910
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0xa8(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x15ae15
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpl $0x0, -0xa8(%rbp)
jl 0x15ad79
movl -0xa8(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x15ad79
movl -0xa8(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0x15ad85
movl -0xa4(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0xb8(%rbp), %rdi
movl -0xbc(%rbp), %esi
callq 0xecb00
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200000, %eax         # imm = 0x200000
cmpl $0x0, %eax
je 0x15ae10
movl -0x34(%rbp), %eax
addl -0xa8(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x34(%rbp), %eax
addl -0xa4(%rbp), %eax
movl %eax, -0xa4(%rbp)
cmpl $0x0, -0xa8(%rbp)
jl 0x15ade7
movl -0xa8(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x15adf7
movq -0x98(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x15ae02
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0x15ae02
movq -0xc8(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x15ad3b
jmp 0x15ae17
jmp 0x15ae19
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movss 0x15e0c(%rip), %xmm1    # 0x170c3c
addss -0x24(%rbp), %xmm1
movq -0x8(%rbp), %rax
movss 0x34(%rax), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x34(%rax)
movq -0x98(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)