// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::TabBarLayout(ImGuiTabBar*)
static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
{
    ImGuiContext& g = *GImGui;
    tab_bar->WantLayout = false;

    // Garbage collect by compacting list
    // Detect if we need to sort out tab list (e.g. in rare case where a tab changed section)
    int tab_dst_n = 0;
    bool need_sort_by_section = false;
    ImGuiTabBarSection sections[3]; // Layout sections: Leading, Central, Trailing
    for (int tab_src_n = 0; tab_src_n < tab_bar->Tabs.Size; tab_src_n++)
    {
        ImGuiTabItem* tab = &tab_bar->Tabs[tab_src_n];
        if (tab->LastFrameVisible < tab_bar->PrevFrameVisible || tab->WantClose)
        {
            // Remove tab
            if (tab_bar->VisibleTabId == tab->ID) { tab_bar->VisibleTabId = 0; }
            if (tab_bar->SelectedTabId == tab->ID) { tab_bar->SelectedTabId = 0; }
            if (tab_bar->NextSelectedTabId == tab->ID) { tab_bar->NextSelectedTabId = 0; }
            continue;
        }
        if (tab_dst_n != tab_src_n)
            tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n];

        tab = &tab_bar->Tabs[tab_dst_n];
        tab->IndexDuringLayout = (ImS16)tab_dst_n;

        // We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another)
        int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
        if (tab_dst_n > 0)
        {
            ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1];
            int prev_tab_section_n = (prev_tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (prev_tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
            if (curr_tab_section_n == 0 && prev_tab_section_n != 0)
                need_sort_by_section = true;
            if (prev_tab_section_n == 2 && curr_tab_section_n != 2)
                need_sort_by_section = true;
        }

        sections[curr_tab_section_n].TabCount++;
        tab_dst_n++;
    }
    if (tab_bar->Tabs.Size != tab_dst_n)
        tab_bar->Tabs.resize(tab_dst_n);

    if (need_sort_by_section)
        ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerBySection);

    // Calculate spacing between sections
    sections[0].Spacing = sections[0].TabCount > 0 && (sections[1].TabCount + sections[2].TabCount) > 0 ? g.Style.ItemInnerSpacing.x : 0.0f;
    sections[1].Spacing = sections[1].TabCount > 0 && sections[2].TabCount > 0 ? g.Style.ItemInnerSpacing.x : 0.0f;

    // Setup next selected tab
    ImGuiID scroll_track_selected_tab_id = 0;
    if (tab_bar->NextSelectedTabId)
    {
        tab_bar->SelectedTabId = tab_bar->NextSelectedTabId;
        tab_bar->NextSelectedTabId = 0;
        scroll_track_selected_tab_id = tab_bar->SelectedTabId;
    }

    // Process order change request (we could probably process it when requested but it's just saner to do it in a single spot).
    if (tab_bar->ReorderRequestTabId != 0)
    {
        if (TabBarProcessReorder(tab_bar))
            if (tab_bar->ReorderRequestTabId == tab_bar->SelectedTabId)
                scroll_track_selected_tab_id = tab_bar->ReorderRequestTabId;
        tab_bar->ReorderRequestTabId = 0;
    }

    // Tab List Popup (will alter tab_bar->BarRect and therefore the available width!)
    const bool tab_list_popup_button = (tab_bar->Flags & ImGuiTabBarFlags_TabListPopupButton) != 0;
    if (tab_list_popup_button)
        if (ImGuiTabItem* tab_to_select = TabBarTabListPopupButton(tab_bar)) // NB: Will alter BarRect.Min.x!
            scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID;

    // Leading/Trailing tabs will be shrink only if central one aren't visible anymore, so layout the shrink data as: leading, trailing, central
    // (whereas our tabs are stored as: leading, central, trailing)
    int shrink_buffer_indexes[3] = { 0, sections[0].TabCount + sections[2].TabCount, sections[0].TabCount };
    g.ShrinkWidthBuffer.resize(tab_bar->Tabs.Size);

    // Compute ideal tabs widths + store them into shrink buffer
    ImGuiTabItem* most_recently_selected_tab = NULL;
    int curr_section_n = -1;
    bool found_selected_tab_id = false;
    for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
    {
        ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
        IM_ASSERT(tab->LastFrameVisible >= tab_bar->PrevFrameVisible);

        if ((most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected) && !(tab->Flags & ImGuiTabItemFlags_Button))
            most_recently_selected_tab = tab;
        if (tab->ID == tab_bar->SelectedTabId)
            found_selected_tab_id = true;
        if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID)
            scroll_track_selected_tab_id = tab->ID;

        // Refresh tab width immediately, otherwise changes of style e.g. style.FramePadding.x would noticeably lag in the tab bar.
        // Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet,
        // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
        const char* tab_name = tab_bar->GetTabName(tab);
        const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true;
        tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x;

        int section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
        ImGuiTabBarSection* section = &sections[section_n];
        section->Width += tab->ContentWidth + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f);
        curr_section_n = section_n;

        // Store data so we can build an array sorted by width if we need to shrink tabs down
        int shrink_buffer_index = shrink_buffer_indexes[section_n]++;
        g.ShrinkWidthBuffer[shrink_buffer_index].Index = tab_n;
        g.ShrinkWidthBuffer[shrink_buffer_index].Width = tab->ContentWidth;

        IM_ASSERT(tab->ContentWidth > 0.0f);
        tab->Width = tab->ContentWidth;
    }

    // Compute total ideal width (used for e.g. auto-resizing a window)
    tab_bar->WidthAllTabsIdeal = 0.0f;
    for (int section_n = 0; section_n < 3; section_n++)
        tab_bar->WidthAllTabsIdeal += sections[section_n].Width + sections[section_n].Spacing;

    // Horizontal scrolling buttons
    // (note that TabBarScrollButtons() will alter BarRect.Max.x)
    if ((tab_bar->WidthAllTabsIdeal > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll))
        if (ImGuiTabItem* scroll_track_selected_tab = TabBarScrollingButtons(tab_bar))
        {
            scroll_track_selected_tab_id = scroll_track_selected_tab->ID;
            if (!(scroll_track_selected_tab->Flags & ImGuiTabItemFlags_Button))
                tab_bar->SelectedTabId = scroll_track_selected_tab_id;
        }

    // Shrink widths if full tabs don't fit in their allocated space
    float section_0_w = sections[0].Width + sections[0].Spacing;
    float section_1_w = sections[1].Width + sections[1].Spacing;
    float section_2_w = sections[2].Width + sections[2].Spacing;
    bool central_section_is_visible = (section_0_w + section_2_w) < tab_bar->BarRect.GetWidth();
    float width_excess;
    if (central_section_is_visible)
        width_excess = ImMax(section_1_w - (tab_bar->BarRect.GetWidth() - section_0_w - section_2_w), 0.0f); // Excess used to shrink central section
    else
        width_excess = (section_0_w + section_2_w) - tab_bar->BarRect.GetWidth(); // Excess used to shrink leading/trailing section

    // With ImGuiTabBarFlags_FittingPolicyScroll policy, we will only shrink leading/trailing if the central section is not visible anymore
    if (width_excess > 0.0f && ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown) || !central_section_is_visible))
    {
        int shrink_data_count = (central_section_is_visible ? sections[1].TabCount : sections[0].TabCount + sections[2].TabCount);
        int shrink_data_offset = (central_section_is_visible ? sections[0].TabCount + sections[2].TabCount : 0);
        ShrinkWidths(g.ShrinkWidthBuffer.Data + shrink_data_offset, shrink_data_count, width_excess);

        // Apply shrunk values into tabs and sections
        for (int tab_n = shrink_data_offset; tab_n < shrink_data_offset + shrink_data_count; tab_n++)
        {
            ImGuiTabItem* tab = &tab_bar->Tabs[g.ShrinkWidthBuffer[tab_n].Index];
            float shrinked_width = IM_FLOOR(g.ShrinkWidthBuffer[tab_n].Width);
            if (shrinked_width < 0.0f)
                continue;

            int section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
            sections[section_n].Width -= (tab->Width - shrinked_width);
            tab->Width = shrinked_width;
        }
    }

    // Layout all active tabs
    int section_tab_index = 0;
    float tab_offset = 0.0f;
    tab_bar->WidthAllTabs = 0.0f;
    for (int section_n = 0; section_n < 3; section_n++)
    {
        ImGuiTabBarSection* section = &sections[section_n];
        if (section_n == 2)
            tab_offset = ImMin(ImMax(0.0f, tab_bar->BarRect.GetWidth() - section->Width), tab_offset);

        for (int tab_n = 0; tab_n < section->TabCount; tab_n++)
        {
            ImGuiTabItem* tab = &tab_bar->Tabs[section_tab_index + tab_n];
            tab->Offset = tab_offset;
            tab_offset += tab->Width + (tab_n < section->TabCount - 1 ? g.Style.ItemInnerSpacing.x : 0.0f);
        }
        tab_bar->WidthAllTabs += ImMax(section->Width + section->Spacing, 0.0f);
        tab_offset += section->Spacing;
        section_tab_index += section->TabCount;
    }

    // If we have lost the selected tab, select the next most recently active one
    if (found_selected_tab_id == false)
        tab_bar->SelectedTabId = 0;
    if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL)
        scroll_track_selected_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;

    // Lock in visible tab
    tab_bar->VisibleTabId = tab_bar->SelectedTabId;
    tab_bar->VisibleTabWasSubmitted = false;

    // Update scrolling
    if (scroll_track_selected_tab_id)
        if (ImGuiTabItem* scroll_track_selected_tab = TabBarFindTabByID(tab_bar, scroll_track_selected_tab_id))
            TabBarScrollToTab(tab_bar, scroll_track_selected_tab, sections);
    tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim);
    tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget);
    if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget)
    {
        // Scrolling speed adjust itself so we can always reach our target in 1/3 seconds.
        // Teleport if we are aiming far off the visible line
        tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, 70.0f * g.FontSize);
        tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, ImFabs(tab_bar->ScrollingTarget - tab_bar->ScrollingAnim) / 0.3f);
        const bool teleport = (tab_bar->PrevFrameVisible + 1 < g.FrameCount) || (tab_bar->ScrollingTargetDistToVisibility > 10.0f * g.FontSize);
        tab_bar->ScrollingAnim = teleport ? tab_bar->ScrollingTarget : ImLinearSweep(tab_bar->ScrollingAnim, tab_bar->ScrollingTarget, g.IO.DeltaTime * tab_bar->ScrollingSpeed);
    }
    else
    {
        tab_bar->ScrollingSpeed = 0.0f;
    }
    tab_bar->ScrollingRectMinX = tab_bar->BarRect.Min.x + sections[0].Width + sections[0].Spacing;
    tab_bar->ScrollingRectMaxX = tab_bar->BarRect.Max.x - sections[2].Width - sections[1].Spacing;

    // Clear name buffers
    if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0)
        tab_bar->TabsNames.Buf.resize(0);

    // Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame)
    ImGuiWindow* window = g.CurrentWindow;
    window->DC.CursorPos = tab_bar->BarRect.Min;
    ItemSize(ImVec2(tab_bar->WidthAllTabs, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
    window->DC.IdealMaxPos.x = ImMax(window->DC.IdealMaxPos.x, tab_bar->BarRect.Min.x + tab_bar->WidthAllTabsIdeal);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %rbx
leaq 0x57c54(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movb $0x0, 0x6a(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movl $0x0, -0x70(%rbp)
movl (%rdi), %eax
testl %eax, %eax
jle 0xa41ec
movq 0x8(%rbx), %r8
xorl %ecx, %ecx
movl $0xc0, %edx
movl $0x80, %esi
xorl %edi, %edi
xorl %r15d, %r15d
xorl %r13d, %r13d
leaq (%r8,%rcx), %r10
movl 0x8(%r8,%rcx), %r9d
cmpl 0x28(%rbx), %r9d
jl 0xa40d5
cmpb $0x1, 0x22(%r8,%rcx)
jne 0xa4108
movl (%r10), %r9d
cmpl %r9d, 0x20(%rbx)
jne 0xa40e5
movl $0x0, 0x20(%rbx)
cmpl %r9d, 0x18(%rbx)
jne 0xa40f2
movl $0x0, 0x18(%rbx)
cmpl %r9d, 0x1c(%rbx)
jne 0xa41d7
movl $0x0, 0x1c(%rbx)
jmp 0xa41d7
movl %r15d, %r9d
cmpq %r9, %rdi
je 0xa4145
testl %r15d, %r15d
js 0xa4fde
cmpl %r15d, %eax
jle 0xa4fde
leaq (%r9,%r9,8), %rax
movl 0x1f(%r10), %r11d
movl %r11d, 0x1f(%r8,%rax,4)
movups (%r10), %xmm0
movups 0x10(%r10), %xmm1
movups %xmm1, 0x10(%r8,%rax,4)
movups %xmm0, (%r8,%rax,4)
movl (%rbx), %eax
cmpl %r15d, %eax
jle 0xa4fde
movq 0x8(%rbx), %r8
leaq (%r9,%r9,8), %r9
movw %r15w, 0x20(%r8,%r9,4)
movl 0x4(%r8,%r9,4), %r10d
xorl %r11d, %r11d
testb %r10b, %r10b
sets %r11b
incq %r11
testb $0x40, %r10b
movl $0x0, %r9d
cmoveq %r11, %r9
testl %r15d, %r15d
je 0xa41c8
cmpl %r15d, %eax
jl 0xa4fde
movl %r10d, %r11d
shrb $0x6, %r11b
movslq %r15d, %r14
leaq (%r14,%r14,8), %r14
movl -0x20(%r8,%r14,4), %r14d
testb $0x40, %r14b
sete %r12b
andb %r11b, %r12b
andl %edx, %r14d
cmpl %esi, %r14d
sete %r11b
andl %edx, %r10d
cmpl %esi, %r10d
setne %r10b
andb %r11b, %r10b
orb %r13b, %r12b
orb %r10b, %r12b
movl %r12d, %r13d
leaq (%r9,%r9,2), %r9
incl -0x90(%rbp,%r9,4)
incl %r15d
incq %rdi
movslq %eax, %r9
addq $0x24, %rcx
cmpq %r9, %rdi
jl 0xa40be
jmp 0xa41f2
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpl %r15d, %eax
je 0xa4265
movl 0x4(%rbx), %eax
cmpl %r15d, %eax
jge 0xa4262
testl %eax, %eax
je 0xa4215
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
addl %eax, %r12d
jmp 0xa421b
movl $0x8, %r12d
cmpl %r15d, %r12d
cmovlel %r15d, %r12d
movslq %r12d, %rax
shlq $0x2, %rax
leaq (%rax,%rax,8), %rdi
callq 0x41c63
movq %rax, %r14
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0xa425a
movslq (%rbx), %rax
shlq $0x2, %rax
leaq (%rax,%rax,8), %rdx
movq %r14, %rdi
callq 0xc080
movq 0x8(%rbx), %rdi
callq 0x41d3c
movq %r14, 0x8(%rbx)
movl %r12d, 0x4(%rbx)
movl %r15d, (%rbx)
testb $0x1, %r13b
je 0xa4283
movq 0x8(%rbx), %rdi
movslq %r15d, %rsi
leaq 0x2f70(%rip), %rcx      # 0xa71e9
movl $0x24, %edx
callq 0xc620
movl -0x90(%rbp), %r14d
movl -0x84(%rbp), %r13d
testl %r14d, %r14d
setg %al
movl -0x78(%rbp), %edx
leal (%rdx,%r13), %ecx
testl %ecx, %ecx
setg %cl
andb %al, %cl
xorps %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
cmpb $0x1, %cl
movq -0x38(%rbp), %r15
jne 0xa42bf
movss 0x15b0(%r15), %xmm0
movss %xmm0, -0x3c(%rbp)
movss %xmm0, -0x88(%rbp)
testl %r13d, %r13d
setg %al
movq %rdx, -0x60(%rbp)
testl %edx, %edx
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa42f0
movss 0x15b0(%r15), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x40(%rbp), %xmm0
movss %xmm0, -0x7c(%rbp)
movl 0x1c(%rbx), %edx
testl %edx, %edx
je 0xa430b
movl %edx, 0x18(%rbx)
movl $0x0, 0x1c(%rbx)
cmpl $0x0, 0x64(%rbx)
je 0xa4338
movl %edx, %r12d
movq %rbx, %rdi
callq 0xa51e9
testb %al, %al
je 0xa432e
movl 0x64(%rbx), %eax
cmpl 0x18(%rbx), %eax
movl %r12d, %edx
cmovel %eax, %edx
jmp 0xa4331
movl %r12d, %edx
movl $0x0, 0x64(%rbx)
testb $0x4, 0x10(%rbx)
movq %r13, -0x58(%rbp)
movl %r14d, -0x4c(%rbp)
je 0xa44e6
movl %edx, -0x2c(%rbp)
leaq 0x5797c(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %r12
movss 0x159c(%rax), %xmm0
movss 0x1980(%rax), %xmm1
addss %xmm0, %xmm1
movq 0xd8(%r12), %rcx
movq %rcx, -0x48(%rbp)
movss 0x2c(%rbx), %xmm2
subss %xmm0, %xmm2
movl 0x30(%rbx), %ecx
movss %xmm2, 0xd8(%r12)
movl %ecx, 0xdc(%r12)
addss 0x2c(%rbx), %xmm1
movss %xmm1, 0x2c(%rbx)
movups 0x1624(%rax), %xmm0
leaq -0x110(%rbp), %rsi
movaps %xmm0, (%rsi)
movss 0xc(%rsi), %xmm0
mulss 0x10c40(%rip), %xmm0    # 0xb5004
movss %xmm0, 0xc(%rsi)
xorl %edi, %edi
callq 0x43e1b
xorps %xmm0, %xmm0
leaq -0xf0(%rbp), %rsi
movaps %xmm0, (%rsi)
movl $0x15, %edi
callq 0x43e1b
leaq 0x1b6f1(%rip), %rdi     # 0xbfadf
xorl %esi, %esi
movl $0x50, %edx
callq 0x93d73
movl %eax, %r15d
movl $0x2, %edi
callq 0x43f55
testb %r15b, %r15b
je 0xa44d3
movl (%rbx), %eax
testl %eax, %eax
jle 0xa44ce
movq %r12, -0xa0(%rbp)
xorl %r15d, %r15d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x8(%rbx), %r14
testb $0x20, 0x6(%r14,%r15)
jne 0xa448b
movswl 0x1c(%r14,%r15), %eax
cmpl $-0x1, %eax
je 0xa5014
cmpl %eax, 0x88(%rbx)
jle 0xa5014
addq %r15, %r14
movslq %eax, %rdi
addq 0x90(%rbx), %rdi
movl 0x18(%rbx), %eax
xorl %esi, %esi
cmpl (%r14), %eax
sete %sil
movq $0x0, -0xf0(%rbp)
xorl %edx, %edx
leaq -0xf0(%rbp), %rcx
callq 0x94650
testb %al, %al
cmovneq %r14, %r12
movl (%rbx), %eax
incq %r13
movslq %eax, %rcx
addq $0x24, %r15
cmpq %rcx, %r13
jl 0xa442a
callq 0x5732f
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0xd8(%rax)
testq %r12, %r12
movq -0x38(%rbp), %r15
movl -0x4c(%rbp), %r14d
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %r13
je 0xa44e6
movl (%r12), %edx
movl %edx, 0x18(%rbx)
jmp 0xa44e6
callq 0x5732f
movq -0x48(%rbp), %rax
movq %rax, 0xd8(%r12)
movq -0x38(%rbp), %r15
movl -0x2c(%rbp), %edx
movl $0x0, -0xac(%rbp)
movq -0x60(%rbp), %rax
addl %r14d, %eax
movl %eax, -0xa8(%rbp)
movl %r14d, -0xa4(%rbp)
movl (%rbx), %r14d
movl 0x214c(%r15), %eax
movl %r14d, %ecx
cmpl %r14d, %eax
jge 0xa4594
testl %eax, %eax
movl %edx, -0x2c(%rbp)
je 0xa452f
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
addl %eax, %r12d
jmp 0xa4535
movl $0x8, %r12d
cmpl %r14d, %r12d
cmovlel %r14d, %r12d
movslq %r12d, %rdi
shlq $0x3, %rdi
callq 0x41c63
movq %rax, %r15
movq -0x38(%rbp), %r13
movq 0x2150(%r13), %rsi
testq %rsi, %rsi
je 0xa457a
movslq 0x2148(%r13), %rdx
shlq $0x3, %rdx
movq %r15, %rdi
callq 0xc080
movq 0x2150(%r13), %rdi
callq 0x41d3c
movq %r15, 0x2150(%r13)
movl %r12d, 0x214c(%r13)
movl (%rbx), %ecx
movq %r13, %r15
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %r13
movl %r14d, 0x2148(%r15)
movq $0x0, -0xa0(%rbp)
testl %ecx, %ecx
jle 0xa473c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edi, %edi
movq 0x8(%rbx), %r12
movl 0x8(%r12,%r13), %eax
cmpl 0x28(%rbx), %eax
jl 0xa5033
leaq (%r12,%r13), %rax
testq %rsi, %rsi
je 0xa45e3
movl 0xc(%rsi), %ecx
cmpl 0xc(%r12,%r13), %ecx
jge 0xa45ed
testb $0x20, 0x6(%r12,%r13)
cmoveq %rax, %rsi
movq %rsi, -0x60(%rbp)
movl (%rax), %eax
cmpl 0x18(%rbx), %eax
movzbl %dil, %edi
movl $0x1, %ecx
cmovel %ecx, %edi
movl %edi, -0x48(%rbp)
testl %edx, %edx
jne 0xa461d
movq -0x38(%rbp), %rcx
cmpl %eax, 0x1cb4(%rcx)
movl $0x0, %ecx
cmovnel %ecx, %eax
movl %eax, %edx
movl %edx, -0x2c(%rbp)
movswl 0x1c(%r12,%r13), %eax
cmpl $-0x1, %eax
je 0xa5014
cmpl %eax, 0x88(%rbx)
jle 0xa5014
movslq %eax, %rdi
addq 0x90(%rbx), %rdi
xorl %esi, %esi
btl $0x14, 0x4(%r12,%r13)
setae %sil
callq 0xa5e25
movss %xmm0, 0x18(%r12,%r13)
movl 0x4(%r12,%r13), %ecx
xorl %eax, %eax
testb %cl, %cl
sets %al
incl %eax
testb $0x40, %cl
movl $0x0, %ecx
cmovnel %ecx, %eax
xorps %xmm1, %xmm1
cmpl %r15d, %eax
movq -0x38(%rbp), %rsi
jne 0xa468b
movss 0x15b0(%rsi), %xmm1
addss %xmm0, %xmm1
leaq (%rax,%rax,2), %rcx
addss -0x8c(%rbp,%rcx,4), %xmm1
movss %xmm1, -0x8c(%rbp,%rcx,4)
movslq -0xac(%rbp,%rax,4), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0xac(%rbp,%rax,4)
testq %rcx, %rcx
js 0xa4ffd
cmpl %ecx, 0x2148(%rsi)
jle 0xa4ffd
movq 0x2150(%rsi), %rdx
movl %r14d, (%rdx,%rcx,8)
cmpl %ecx, 0x2148(%rsi)
jle 0xa4ffd
movss %xmm0, 0x4(%rdx,%rcx,8)
ucomiss 0x11154(%rip), %xmm0    # 0xb5844
jbe 0xa5052
movss %xmm0, 0x14(%r12,%r13)
incq %r14
movslq (%rbx), %rcx
addq $0x24, %r13
movl %eax, %r15d
cmpq %rcx, %r14
movl -0x2c(%rbp), %edx
movq -0x60(%rbp), %rsi
movl -0x48(%rbp), %edi
jl 0xa45be
cmpl $0x2, %ecx
setge %al
movq %rax, -0xa0(%rbp)
testb $0x1, %dil
sete -0x48(%rbp)
movq -0x38(%rbp), %r15
movq -0x58(%rbp), %r13
jmp 0xa4748
movb $0x1, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
xorps %xmm0, %xmm0
movl $0x8, %eax
movss -0x94(%rbp,%rax), %xmm1
addss -0x90(%rbp,%rax), %xmm1
addss %xmm1, %xmm0
addq $0xc, %rax
cmpq $0x2c, %rax
jne 0xa4750
movss %xmm0, 0x48(%rbx)
movss 0x34(%rbx), %xmm1
movaps %xmm1, %xmm2
subss 0x2c(%rbx), %xmm2
ucomiss %xmm2, %xmm0
seta %al
testb %al, -0xa0(%rbp)
je 0xa49a8
movl $0x90, %eax
andl 0x10(%rbx), %eax
cmpl $0x80, %eax
jne 0xa49a8
movl %edx, -0x2c(%rbp)
leaq 0x5751f(%rip), %rax     # 0xfbcd0
movq (%rax), %r12
movq 0x1ae0(%r12), %r14
movss 0x1980(%r12), %xmm0
movss 0x110be(%rip), %xmm1    # 0xb588c
addss %xmm0, %xmm1
movaps %xmm1, -0xa0(%rbp)
movss 0x159c(%r12), %xmm2
addss %xmm2, %xmm2
addss %xmm0, %xmm2
movaps %xmm2, -0xd0(%rbp)
addss %xmm1, %xmm1
movaps %xmm1, -0xe0(%rbp)
movq 0xd8(%r14), %rax
movq %rax, -0xb8(%rbp)
movups 0x1624(%r12), %xmm0
leaq -0x110(%rbp), %rsi
movaps %xmm0, (%rsi)
movss 0xc(%rsi), %xmm0
mulss 0x107d9(%rip), %xmm0    # 0xb5004
movss %xmm0, 0xc(%rsi)
xorl %edi, %edi
callq 0x43e1b
xorps %xmm0, %xmm0
leaq -0xf0(%rbp), %rsi
movaps %xmm0, (%rsi)
movl $0x15, %edi
callq 0x43e1b
movq 0x94(%r12), %rax
movq %rax, -0xf8(%rbp)
movabsq $0x3e4ccccd3e800000, %rax # imm = 0x3E4CCCCD3E800000
movq %rax, 0x94(%r12)
movss 0x2c(%rbx), %xmm0
movss 0x34(%rbx), %xmm1
subss -0xe0(%rbp), %xmm1
movaps %xmm1, %xmm3
cmpless %xmm0, %xmm3
movaps %xmm3, %xmm2
andnps %xmm1, %xmm2
andps %xmm0, %xmm3
orps %xmm2, %xmm3
movaps %xmm3, -0x120(%rbp)
movl 0x30(%rbx), %eax
movss %xmm3, 0xd8(%r14)
movl %eax, 0xdc(%r14)
movaps -0xa0(%rbp), %xmm0
unpcklps -0xd0(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movaps %xmm0, -0xd0(%rbp)
leaq 0x2e954(%rip), %rdi     # 0xd321f
xorl %esi, %esi
movl $0x410, %edx            # imm = 0x410
callq 0x915ac
movzbl %al, %r15d
negl %r15d
movaps -0x120(%rbp), %xmm0
addss -0xa0(%rbp), %xmm0
movl 0x30(%rbx), %eax
movss %xmm0, 0xd8(%r14)
movl %eax, 0xdc(%r14)
leaq 0x2e91c(%rip), %rdi     # 0xd3223
movl $0x1, %r13d
movl $0x1, %esi
movaps -0xd0(%rbp), %xmm0
movl $0x410, %edx            # imm = 0x410
callq 0x915ac
testb %al, %al
cmovnel %r13d, %r15d
movl $0x2, %edi
callq 0x43f55
movq -0xf8(%rbp), %rax
movq %rax, 0x94(%r12)
testl %r15d, %r15d
movss -0x3c(%rbp), %xmm0
je 0xa4970
movl 0x18(%rbx), %eax
testl %eax, %eax
je 0xa4970
movslq (%rbx), %rcx
testq %rcx, %rcx
jle 0xa4970
movq 0x8(%rbx), %rsi
cmpl %eax, (%rsi)
je 0xa4f4a
addq $0x24, %rsi
decq %rcx
jne 0xa495f
movaps -0xe0(%rbp), %xmm2
addss 0x10665(%rip), %xmm2    # 0xb4fe4
movq -0xb8(%rbp), %rax
movq %rax, 0xd8(%r14)
movss 0x34(%rbx), %xmm1
subss %xmm2, %xmm1
movss %xmm1, 0x34(%rbx)
movq -0x38(%rbp), %r15
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %r13
jmp 0xa49ad
movss -0x3c(%rbp), %xmm0
movl %edx, %r12d
movss -0x8c(%rbp), %xmm4
addss %xmm0, %xmm4
xorps %xmm3, %xmm3
movss -0x74(%rbp), %xmm5
addss %xmm3, %xmm5
movaps %xmm4, %xmm2
addss %xmm5, %xmm2
subss 0x2c(%rbx), %xmm1
ucomiss %xmm2, %xmm1
ja 0xa49e2
movaps %xmm2, %xmm0
subss %xmm1, %xmm0
jmp 0xa4a04
movss -0x80(%rbp), %xmm0
addss -0x40(%rbp), %xmm0
movaps %xmm1, %xmm6
subss %xmm4, %xmm6
subss %xmm5, %xmm6
subss %xmm6, %xmm0
ucomiss %xmm3, %xmm0
jb 0xa4af3
ucomiss %xmm3, %xmm0
jbe 0xa4af3
ucomiss %xmm2, %xmm1
jbe 0xa4a1e
movl 0x10(%rbx), %eax
andl $0x40, %eax
je 0xa4af3
movl -0x78(%rbp), %eax
addl -0x4c(%rbp), %eax
xorl %r14d, %r14d
ucomiss %xmm2, %xmm1
cmovbel %eax, %r13d
cmoval %eax, %r14d
movslq %r14d, %rdi
shlq $0x3, %rdi
addq 0x2150(%r15), %rdi
movl %r13d, %esi
callq 0x93bdf
testl %r13d, %r13d
jle 0xa4af3
addl %r14d, %r13d
movl %r14d, %eax
xorl %ecx, %ecx
testl %r14d, %r14d
js 0xa4ffd
cmpl %eax, 0x2148(%r15)
jle 0xa4ffd
movq 0x2150(%r15), %rsi
movslq (%rsi,%rax,8), %rdx
testq %rdx, %rdx
js 0xa4fde
cmpl %edx, (%rbx)
jle 0xa4fde
cvttss2si 0x4(%rsi,%rax,8), %esi
testl %esi, %esi
js 0xa4ae7
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
movq 0x8(%rbx), %rsi
leaq (%rdx,%rdx,8), %rdx
movl 0x4(%rsi,%rdx,4), %edi
xorl %r8d, %r8d
testb %dil, %dil
sets %r8b
incq %r8
testb $0x40, %dil
cmovneq %rcx, %r8
movss 0x14(%rsi,%rdx,4), %xmm1
subss %xmm0, %xmm1
leaq (%r8,%r8,2), %rdi
movss -0x8c(%rbp,%rdi,4), %xmm2
subss %xmm1, %xmm2
movss %xmm2, -0x8c(%rbp,%rdi,4)
movss %xmm0, 0x14(%rsi,%rdx,4)
incq %rax
cmpl %eax, %r13d
jg 0xa4a59
movl $0x0, 0x44(%rbx)
xorl %eax, %eax
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %ecx, %ecx
leaq (%rax,%rax,2), %rdx
leaq -0x90(,%rdx,4), %rdx
addq %rbp, %rdx
cmpq $0x2, %rax
jne 0xa4b3d
movss 0x34(%rbx), %xmm3
subss 0x2c(%rbx), %xmm3
subss 0x4(%rdx), %xmm3
movaps %xmm3, %xmm4
cmpless %xmm0, %xmm4
andnps %xmm3, %xmm4
minss %xmm2, %xmm4
movaps %xmm4, %xmm2
movslq (%rdx), %rsi
testq %rsi, %rsi
jle 0xa4ba1
leal -0x1(%rsi), %edi
movl %ecx, %r8d
leaq (%r8,%r8,8), %r9
leaq 0x14(,%r9,4), %r9
xorl %r10d, %r10d
testl %ecx, %ecx
js 0xa4fde
leal (%r8,%r10), %r11d
cmpl %r11d, (%rbx)
jle 0xa4fde
movq 0x8(%rbx), %r11
movss %xmm2, -0x4(%r11,%r9)
xorps %xmm3, %xmm3
cmpq %rdi, %r10
jae 0xa4b8b
movss 0x15b0(%r15), %xmm3
addss (%r11,%r9), %xmm3
addss %xmm3, %xmm2
incq %r10
addq $0x24, %r9
cmpq %r10, %rsi
jne 0xa4b5a
movss 0x8(%rdx), %xmm3
movss 0x4(%rdx), %xmm4
addss %xmm3, %xmm4
xorps %xmm5, %xmm5
cmpless %xmm4, %xmm5
andps %xmm4, %xmm5
addss %xmm5, %xmm1
movss %xmm1, 0x44(%rbx)
addss %xmm3, %xmm2
addl %ecx, %esi
incq %rax
movl %esi, %ecx
cmpq $0x3, %rax
jne 0xa4b07
cmpb $0x0, -0x48(%rbp)
je 0xa4be7
movl $0x0, 0x18(%rbx)
jmp 0xa4bee
movl 0x18(%rbx), %eax
testl %eax, %eax
jne 0xa4c07
xorl %eax, %eax
cmpl $0x0, 0x1c(%rbx)
jne 0xa4c07
movq -0x60(%rbp), %rcx
testq %rcx, %rcx
je 0xa4c07
movl (%rcx), %eax
movl %eax, 0x18(%rbx)
movl %eax, %r12d
movl %eax, 0x20(%rbx)
movb $0x0, 0x6b(%rbx)
testl %r12d, %r12d
je 0xa4d26
movslq (%rbx), %rax
testq %rax, %rax
jle 0xa4d26
movq 0x8(%rbx), %r14
cmpl %r12d, (%r14)
je 0xa4c3a
addq $0x24, %r14
decq %rax
jne 0xa4c27
jmp 0xa4d26
testb $-0x40, 0x4(%r14)
jne 0xa4d26
leaq 0x57084(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movss 0x1980(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xac098
movss 0x34(%rbx), %xmm2
subss 0x2c(%rbx), %xmm2
movss -0x8c(%rbp), %xmm1
movss 0x10(%r14), %xmm0
subss %xmm1, %xmm0
cmpl -0x4c(%rbp), %eax
jl 0xa4c92
movss -0x2c(%rbp), %xmm4
movaps %xmm4, %xmm3
jmp 0xa4c9f
movss 0x2c0ea(%rip), %xmm3    # 0xd0d84
movss -0x2c(%rbp), %xmm4
subss %xmm1, %xmm2
movaps %xmm0, %xmm1
subss %xmm3, %xmm1
addss 0x14(%r14), %xmm0
incl %eax
movl (%rbx), %ecx
subl -0x78(%rbp), %ecx
cmpl %ecx, %eax
jl 0xa4cc3
movss 0x10321(%rip), %xmm4    # 0xb4fe4
addss %xmm4, %xmm0
subss -0x74(%rbp), %xmm2
movl $0x0, 0x54(%rbx)
movss 0x50(%rbx), %xmm3
ucomiss %xmm1, %xmm3
ja 0xa4d08
subss -0x40(%rbp), %xmm2
movaps %xmm0, %xmm4
subss %xmm1, %xmm4
ucomiss %xmm2, %xmm4
jae 0xa4d08
subss %xmm2, %xmm0
ucomiss %xmm3, %xmm0
jbe 0xa4d26
subss %xmm2, %xmm1
subss 0x4c(%rbx), %xmm1
movaps %xmm1, %xmm2
movaps %xmm0, %xmm1
jmp 0xa4d11
movss 0x4c(%rbx), %xmm2
subss %xmm0, %xmm2
xorps %xmm0, %xmm0
cmpless %xmm2, %xmm0
andps %xmm2, %xmm0
movss %xmm0, 0x54(%rbx)
movss %xmm1, 0x50(%rbx)
movss 0x4c(%rbx), %xmm4
movss 0x44(%rbx), %xmm5
movss 0x2c(%rbx), %xmm1
movss 0x34(%rbx), %xmm0
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
subss %xmm2, %xmm5
minss %xmm5, %xmm4
xorps %xmm3, %xmm3
xorps %xmm2, %xmm2
cmpless %xmm4, %xmm2
andps %xmm4, %xmm2
movss %xmm2, 0x4c(%rbx)
movss 0x50(%rbx), %xmm4
minss %xmm5, %xmm4
cmpless %xmm4, %xmm3
andps %xmm4, %xmm3
movss %xmm3, 0x50(%rbx)
ucomiss %xmm3, %xmm2
jne 0xa4d7d
jnp 0xa4e08
movss 0x58(%rbx), %xmm4
movss 0x1980(%r15), %xmm5
movss 0x16159(%rip), %xmm6    # 0xbaeec
mulss %xmm5, %xmm6
movaps %xmm6, %xmm7
cmpless %xmm4, %xmm7
andps %xmm7, %xmm4
andnps %xmm6, %xmm7
movaps %xmm3, %xmm6
subss %xmm2, %xmm6
andps 0x10a1d(%rip), %xmm6    # 0xb57d0
divss 0x10b31(%rip), %xmm6    # 0xb58ec
orps %xmm4, %xmm7
movaps %xmm6, %xmm4
cmpless %xmm7, %xmm4
movaps %xmm4, %xmm8
andps %xmm7, %xmm8
andnps %xmm6, %xmm4
orps %xmm8, %xmm4
movss %xmm4, 0x58(%rbx)
movl 0x28(%rbx), %eax
incl %eax
cmpl 0x1a68(%r15), %eax
jl 0xa4dfe
movss 0x54(%rbx), %xmm6
mulss 0x10213(%rip), %xmm5    # 0xb5008
ucomiss %xmm5, %xmm6
jbe 0xa4f0c
movaps %xmm3, %xmm2
movss %xmm2, 0x4c(%rbx)
jmp 0xa4e0f
movl $0x0, 0x58(%rbx)
addss -0x8c(%rbp), %xmm1
movss -0x3c(%rbp), %xmm2
addss %xmm1, %xmm2
movss %xmm2, 0x5c(%rbx)
subss -0x74(%rbp), %xmm0
subss -0x40(%rbp), %xmm0
movss %xmm0, 0x60(%rbx)
testb $0x10, 0x12(%rbx)
jne 0xa4e8f
cmpl $0x0, 0x8c(%rbx)
jns 0xa4e85
xorl %edi, %edi
callq 0x41c63
movq %rax, %r14
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0xa4e74
movslq 0x88(%rbx), %rdx
movq %r14, %rdi
callq 0xc080
movq 0x90(%rbx), %rdi
callq 0x41d3c
movq %r14, 0x90(%rbx)
movl $0x0, 0x8c(%rbx)
movl $0x0, 0x88(%rbx)
movq 0x1ae0(%r15), %r14
movq 0x2c(%rbx), %rax
movq %rax, 0xd8(%r14)
movss 0x38(%rbx), %xmm0
movss 0x44(%rbx), %xmm1
subss 0x30(%rbx), %xmm0
leaq -0x110(%rbp), %rdi
movss %xmm1, (%rdi)
movss %xmm0, 0x4(%rdi)
movss 0x7c(%rbx), %xmm0
callq 0x52315
movss 0x2c(%rbx), %xmm0
addss 0x48(%rbx), %xmm0
movss 0xf8(%r14), %xmm1
movaps %xmm0, %xmm2
cmpless %xmm1, %xmm2
movaps %xmm2, %xmm3
andnps %xmm0, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movss %xmm2, 0xf8(%r14)
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
mulss 0x18(%r15), %xmm4
ucomiss %xmm2, %xmm3
jbe 0xa4f27
addss %xmm2, %xmm4
minss %xmm3, %xmm4
movaps %xmm4, %xmm2
jmp 0xa4e01
ucomiss %xmm3, %xmm2
jbe 0xa4e01
subss %xmm4, %xmm2
movaps %xmm3, %xmm4
cmpless %xmm2, %xmm4
andps %xmm4, %xmm2
andnps %xmm3, %xmm4
orps %xmm4, %xmm2
jmp 0xa4e01
movq %rbx, %rdi
callq 0xac098
movss -0x3c(%rbp), %xmm0
movl (%rbx), %ecx
leal (%r15,%r15), %edx
movq -0x58(%rbp), %r13
leal (%r15,%rax), %esi
cmpl %ecx, %esi
movl %eax, %r8d
cmovll %esi, %r8d
testl %esi, %esi
cmovsl %eax, %r8d
testl %r8d, %r8d
js 0xa4fde
cmpl %r8d, %ecx
jle 0xa4fde
movq 0x8(%rbx), %rdi
movl %r8d, %r8d
leaq (%r8,%r8,8), %r8
testb $0x20, 0x6(%rdi,%r8,4)
je 0xa4f9b
addl %edx, %eax
js 0xa4f9b
cmpl %ecx, %eax
movl %esi, %eax
jl 0xa4f61
leaq (%rdi,%r8,4), %rax
movq -0xb8(%rbp), %rcx
movq %rcx, 0xd8(%r14)
movaps -0xe0(%rbp), %xmm2
addss 0x10028(%rip), %xmm2    # 0xb4fe4
movss 0x34(%rbx), %xmm1
subss %xmm2, %xmm1
movss %xmm1, 0x34(%rbx)
movl (%rax), %edx
testb $0x20, 0x6(%rax)
jne 0xa4fd5
movl %edx, 0x18(%rbx)
movq -0x38(%rbp), %r15
jmp 0xa49ad
leaq 0x14693(%rip), %rdi     # 0xb9678
leaq 0x1469f(%rip), %rsi     # 0xb968b
leaq 0x2e283(%rip), %rcx     # 0xd3276
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x14674(%rip), %rdi     # 0xb9678
leaq 0x14680(%rip), %rsi     # 0xb968b
leaq 0x2e1bf(%rip), %rcx     # 0xd31d1
jmp 0xa4ff3
leaq 0x156fa(%rip), %rdi     # 0xba715
leaq 0x1461d(%rip), %rsi     # 0xb963f
leaq 0x1572f(%rip), %rcx     # 0xba758
movl $0x765, %edx            # imm = 0x765
callq 0xc140
leaq 0x2e123(%rip), %rdi     # 0xd315d
leaq 0x2bfd7(%rip), %rsi     # 0xd1018
leaq 0x2e148(%rip), %rcx     # 0xd3190
movl $0x1bcf, %edx           # imm = 0x1BCF
callq 0xc140
leaq 0x2e15f(%rip), %rdi     # 0xd31b8
leaq 0x2bfb8(%rip), %rsi     # 0xd1018
leaq 0x2e129(%rip), %rcx     # 0xd3190
movl $0x1be9, %edx           # imm = 0x1BE9
callq 0xc140