// File: 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
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x8(%rbp)
leaq 0xbcf7a(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movb $0x0, 0x6a(%rax)
movl $0x0, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x24, %rcx
movq %rcx, -0x160(%rbp)
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x162d80
movq -0x168(%rbp), %rax
movq -0x160(%rbp), %rcx
addq $0xc, %rax
cmpq %rcx, %rax
movq %rax, -0x158(%rbp)
jne 0x155ff9
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x156208
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xecb00
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jl 0x15606a
movq -0x50(%rbp), %rax
testb $0x1, 0x22(%rax)
je 0x1560bd
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x156084
movq -0x8(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x15609e
movq -0x8(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x1560b8
movq -0x8(%rbp), %rax
movl $0x0, 0x1c(%rax)
jmp 0x1561fa
movl -0x14(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x1560f8
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xecb00
movq %rax, -0x170(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xecb00
movq -0x170(%rbp), %rsi
movq %rax, %rdi
movl $0x23, %edx
callq 0xd0a0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xecb00
movq %rax, -0x50(%rbp)
movl -0x14(%rbp), %eax
movw %ax, %cx
movq -0x50(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x15612f
xorl %eax, %eax
movl %eax, -0x174(%rbp)
jmp 0x156152
movq -0x50(%rbp), %rax
movl 0x4(%rax), %edx
andl $0x80, %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x174(%rbp)
movl -0x174(%rbp), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x1561db
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
subl $0x1, %esi
callq 0xecb00
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x15618d
xorl %eax, %eax
movl %eax, -0x178(%rbp)
jmp 0x1561b0
movq -0x60(%rbp), %rax
movl 0x4(%rax), %edx
andl $0x80, %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x178(%rbp)
movl -0x178(%rbp), %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x1561c9
cmpl $0x0, -0x64(%rbp)
je 0x1561c9
movb $0x1, -0x15(%rbp)
cmpl $0x2, -0x64(%rbp)
jne 0x1561d9
cmpl $0x2, -0x54(%rbp)
je 0x1561d9
movb $0x1, -0x15(%rbp)
jmp 0x1561db
movslq -0x54(%rbp), %rcx
leaq -0x40(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x156031
movq -0x8(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
je 0x15621f
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x162db0
testb $0x1, -0x15(%rbp)
je 0x156245
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movslq (%rax), %rsi
movl $0x24, %edx
leaq 0x4590(%rip), %rcx      # 0x15a7d0
callq 0xd6c0
cmpl $0x0, -0x40(%rbp)
jle 0x15626c
movl -0x34(%rbp), %eax
addl -0x28(%rbp), %eax
cmpl $0x0, %eax
jle 0x15626c
movq -0x10(%rbp), %rax
movss 0x15b0(%rax), %xmm0
movss %xmm0, -0x17c(%rbp)
jmp 0x156279
xorps %xmm0, %xmm0
movss %xmm0, -0x17c(%rbp)
jmp 0x156279
movss -0x17c(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x1562a8
cmpl $0x0, -0x28(%rbp)
jle 0x1562a8
movq -0x10(%rbp), %rax
movss 0x15b0(%rax), %xmm0
movss %xmm0, -0x180(%rbp)
jmp 0x1562b5
xorps %xmm0, %xmm0
movss %xmm0, -0x180(%rbp)
jmp 0x1562b5
movss -0x180(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x1562f6
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x64(%rax)
je 0x156336
movq -0x8(%rbp), %rdi
callq 0x157280
testb $0x1, %al
jne 0x15630f
jmp 0x15632b
movq -0x8(%rbp), %rax
movl 0x64(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x156329
movq -0x8(%rbp), %rax
movl 0x64(%rax), %eax
movl %eax, -0x68(%rbp)
jmp 0x15632b
movq -0x8(%rbp), %rax
movl $0x0, 0x64(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x69(%rbp)
testb $0x1, -0x69(%rbp)
je 0x156377
movq -0x8(%rbp), %rdi
callq 0x15a8a0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x156375
movq -0x78(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
movl %eax, 0x18(%rcx)
movl %eax, -0x68(%rbp)
jmp 0x156377
movl $0x0, -0x84(%rbp)
movl -0x40(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2148, %rdi           # imm = 0x2148
movq -0x8(%rbp), %rax
movl (%rax), %esi
callq 0x162e00
movq $0x0, -0x90(%rbp)
movl $0xffffffff, -0x94(%rbp) # imm = 0xFFFFFFFF
movb $0x0, -0x95(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1566c8
movq -0x8(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0xecb00
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jl 0x156409
jmp 0x156428
leaq 0x3a445(%rip), %rdi     # 0x190855
leaq 0x37fc9(%rip), %rsi     # 0x18e3e0
movl $0x1bcf, %edx           # imm = 0x1BCF
leaq 0x3a465(%rip), %rcx     # 0x190888
callq 0xd180
cmpq $0x0, -0x90(%rbp)
je 0x156448
movq -0x90(%rbp), %rax
movl 0xc(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x15646a
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200000, %eax         # imm = 0x200000
cmpl $0x0, %eax
jne 0x15646a
movq -0xa8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x156483
movb $0x1, -0x95(%rbp)
cmpl $0x0, -0x68(%rbp)
jne 0x1564aa
movq -0x10(%rbp), %rax
movl 0x1cb4(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x1564aa
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0xecb80
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
testl $0x100000, %eax         # imm = 0x100000
sete -0xb1(%rbp)
movq -0xb0(%rbp), %rdi
movzbl -0xb1(%rbp), %esi
andl $0x1, %esi
callq 0x158380
movlpd %xmm0, -0xbc(%rbp)
movss -0xbc(%rbp), %xmm0
movq -0xa8(%rbp), %rax
movss %xmm0, 0x18(%rax)
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x156525
xorl %eax, %eax
movl %eax, -0x184(%rbp)
jmp 0x15654b
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %edx
andl $0x80, %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x184(%rbp)
movl -0x184(%rbp), %eax
movl %eax, -0xc0(%rbp)
movslq -0xc0(%rbp), %rcx
leaq -0x40(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0xa8(%rbp), %rax
movss 0x18(%rax), %xmm0
movss %xmm0, -0x188(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0x94(%rbp), %eax
jne 0x1565a8
movq -0x10(%rbp), %rax
movss 0x15b0(%rax), %xmm0
movss %xmm0, -0x18c(%rbp)
jmp 0x1565b5
xorps %xmm0, %xmm0
movss %xmm0, -0x18c(%rbp)
jmp 0x1565b5
movss -0x188(%rbp), %xmm0
movss -0x18c(%rbp), %xmm1
addss %xmm1, %xmm0
movq -0xc8(%rbp), %rax
addss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rax)
movl -0xc0(%rbp), %eax
movl %eax, -0x94(%rbp)
movslq -0xc0(%rbp), %rcx
movl -0x84(%rbp,%rcx,4), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x84(%rbp,%rcx,4)
movl %eax, -0xcc(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2148, %rdi           # imm = 0x2148
movl -0xcc(%rbp), %esi
callq 0x162e50
movl -0x194(%rbp), %ecx
movl %ecx, (%rax)
movq -0xa8(%rbp), %rax
movss 0x18(%rax), %xmm0
movss %xmm0, -0x190(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2148, %rdi           # imm = 0x2148
movl -0xcc(%rbp), %esi
callq 0x162e50
movss -0x190(%rbp), %xmm0
movss %xmm0, 0x4(%rax)
movq -0xa8(%rbp), %rax
movss 0x18(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x15667d
jmp 0x15669c
leaq 0x3a22c(%rip), %rdi     # 0x1908b0
leaq 0x37d55(%rip), %rsi     # 0x18e3e0
movl $0x1be9, %edx           # imm = 0x1BE9
leaq 0x3a1f1(%rip), %rcx     # 0x190888
callq 0xd180
movq -0xa8(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0xa8(%rbp), %rax
movss %xmm0, 0x14(%rax)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x1563cc
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x48(%rax)
movl $0x0, -0xd0(%rbp)
cmpl $0x3, -0xd0(%rbp)
jge 0x156734
movslq -0xd0(%rbp), %rcx
leaq -0x40(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movslq -0xd0(%rbp), %rcx
leaq -0x40(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
addss 0x48(%rax), %xmm0
movss %xmm0, 0x48(%rax)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x1566de
movq -0x8(%rbp), %rax
movss 0x48(%rax), %xmm0
movss %xmm0, -0x198(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xeb840
movaps %xmm0, %xmm1
movss -0x198(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1567d3
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x1567d3
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x1567d3
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x1567d3
movq -0x8(%rbp), %rdi
callq 0x15aab0
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x1567d1
movq -0xd8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x68(%rbp)
movq -0xd8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200000, %eax         # imm = 0x200000
cmpl $0x0, %eax
jne 0x1567cf
movl -0x68(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x1567d1
jmp 0x1567d3
movss -0x3c(%rbp), %xmm0
addss -0x38(%rbp), %xmm0
movss %xmm0, -0xdc(%rbp)
movss -0x30(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0xe0(%rbp)
movss -0x24(%rbp), %xmm0
addss -0x20(%rbp), %xmm0
movss %xmm0, -0xe4(%rbp)
movss -0xdc(%rbp), %xmm0
addss -0xe4(%rbp), %xmm0
movss %xmm0, -0x19c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xeb840
movss -0x19c(%rbp), %xmm1
ucomiss %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0xe5(%rbp)
testb $0x1, -0xe5(%rbp)
je 0x15689b
movss -0xe0(%rbp), %xmm0
movss %xmm0, -0x1a0(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xeb840
movaps %xmm0, %xmm1
movss -0x1a0(%rbp), %xmm0
subss -0xdc(%rbp), %xmm1
subss -0xe4(%rbp), %xmm1
subss %xmm1, %xmm0
xorps %xmm1, %xmm1
callq 0x139050
movss %xmm0, -0xec(%rbp)
jmp 0x1568d7
movss -0xdc(%rbp), %xmm0
addss -0xe4(%rbp), %xmm0
movss %xmm0, -0x1a4(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xeb840
movaps %xmm0, %xmm1
movss -0x1a4(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0xec(%rbp)
movss -0xec(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x156acc
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x156907
testb $0x1, -0xe5(%rbp)
jne 0x156acc
testb $0x1, -0xe5(%rbp)
je 0x15691b
movl -0x34(%rbp), %eax
movl %eax, -0x1a8(%rbp)
jmp 0x156927
movl -0x40(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x1a8(%rbp)
movl -0x1a8(%rbp), %eax
movl %eax, -0xf0(%rbp)
testb $0x1, -0xe5(%rbp)
je 0x15694a
movl -0x40(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x1ac(%rbp)
jmp 0x156954
xorl %eax, %eax
movl %eax, -0x1ac(%rbp)
jmp 0x156954
movl -0x1ac(%rbp), %eax
movl %eax, -0xf4(%rbp)
movq -0x10(%rbp), %rax
movq 0x2150(%rax), %rdi
movslq -0xf4(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0xf0(%rbp), %esi
movss -0xec(%rbp), %xmm0
callq 0x13e390
movl -0xf4(%rbp), %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
movl -0xf4(%rbp), %ecx
addl -0xf0(%rbp), %ecx
cmpl %ecx, %eax
jge 0x156aca
movq -0x8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2148, %rdi           # imm = 0x2148
movl -0xf8(%rbp), %esi
callq 0x162e50
movq -0x1b8(%rbp), %rdi
movl (%rax), %esi
callq 0xecb00
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2148, %rdi           # imm = 0x2148
movl -0xf8(%rbp), %esi
callq 0x162e50
cvttss2si 0x4(%rax), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x104(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x104(%rbp), %xmm0
jbe 0x156a20
jmp 0x156ab6
movq -0x100(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x156a3c
xorl %eax, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x156a62
movq -0x100(%rbp), %rax
movl 0x4(%rax), %edx
andl $0x80, %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x1bc(%rbp)
movl -0x1bc(%rbp), %eax
movl %eax, -0x108(%rbp)
movq -0x100(%rbp), %rax
movss 0x14(%rax), %xmm1
subss -0x104(%rbp), %xmm1
movslq -0x108(%rbp), %rcx
leaq -0x40(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x4(%rax)
movss -0x104(%rbp), %xmm0
movq -0x100(%rbp), %rax
movss %xmm0, 0x14(%rax)
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x156998
jmp 0x156acc
movl $0x0, -0x10c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x110(%rbp)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x44(%rax)
movl $0x0, -0x114(%rbp)
cmpl $0x3, -0x114(%rbp)
jge 0x156ca6
movslq -0x114(%rbp), %rcx
leaq -0x40(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x120(%rbp)
cmpl $0x2, -0x114(%rbp)
jne 0x156b5f
movq -0x8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xeb840
movaps %xmm0, %xmm1
movq -0x120(%rbp), %rax
subss 0x4(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0x139050
movss -0x110(%rbp), %xmm1
callq 0x13c690
movss %xmm0, -0x110(%rbp)
movl $0x0, -0x124(%rbp)
movl -0x124(%rbp), %eax
movq -0x120(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x156c33
movq -0x8(%rbp), %rdi
movl -0x10c(%rbp), %esi
addl -0x124(%rbp), %esi
callq 0xecb00
movq %rax, -0x130(%rbp)
movss -0x110(%rbp), %xmm0
movq -0x130(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x130(%rbp), %rax
movss 0x14(%rax), %xmm0
movss %xmm0, -0x1c0(%rbp)
movl -0x124(%rbp), %eax
movq -0x120(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x156bee
movq -0x10(%rbp), %rax
movss 0x15b0(%rax), %xmm0
movss %xmm0, -0x1c4(%rbp)
jmp 0x156bfb
xorps %xmm0, %xmm0
movss %xmm0, -0x1c4(%rbp)
jmp 0x156bfb
movss -0x1c0(%rbp), %xmm0
movss -0x1c4(%rbp), %xmm1
addss %xmm1, %xmm0
addss -0x110(%rbp), %xmm0
movss %xmm0, -0x110(%rbp)
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x156b69
movq -0x120(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x120(%rbp), %rax
addss 0x8(%rax), %xmm0
xorps %xmm1, %xmm1
callq 0x139050
movq -0x8(%rbp), %rax
addss 0x44(%rax), %xmm0
movss %xmm0, 0x44(%rax)
movq -0x120(%rbp), %rax
movss 0x8(%rax), %xmm0
addss -0x110(%rbp), %xmm0
movss %xmm0, -0x110(%rbp)
movq -0x120(%rbp), %rax
movl (%rax), %eax
addl -0x10c(%rbp), %eax
movl %eax, -0x10c(%rbp)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x156af7
movb -0x95(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x156cc1
movq -0x8(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x156cf2
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x156cf2
cmpq $0x0, -0x90(%rbp)
je 0x156cf2
movq -0x90(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
movl %eax, 0x18(%rcx)
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x6b(%rax)
cmpl $0x0, -0x68(%rbp)
je 0x156d41
movq -0x8(%rbp), %rdi
movl -0x68(%rbp), %esi
callq 0x157030
movq %rax, -0x138(%rbp)
cmpq $0x0, -0x138(%rbp)
je 0x156d3f
movq -0x8(%rbp), %rdi
movq -0x138(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x15ae60
jmp 0x156d41
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movss 0x4c(%rax), %xmm0
callq 0x15b070
movq -0x8(%rbp), %rax
movss %xmm0, 0x4c(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movss 0x50(%rax), %xmm0
callq 0x15b070
movq -0x8(%rbp), %rax
movss %xmm0, 0x50(%rax)
movq -0x8(%rbp), %rax
movss 0x4c(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x50(%rax), %xmm0
jne 0x156d91
jp 0x156d91
jmp 0x156eb1
movq -0x8(%rbp), %rax
movss 0x58(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x37482(%rip), %xmm1    # 0x18e228
mulss 0x1980(%rax), %xmm1
callq 0x139050
movq -0x8(%rbp), %rax
movss %xmm0, 0x58(%rax)
movq -0x8(%rbp), %rax
movss 0x58(%rax), %xmm0
movq -0x8(%rbp), %rax
movss 0x50(%rax), %xmm1
movq -0x8(%rbp), %rax
subss 0x4c(%rax), %xmm1
movaps 0x1ba22(%rip), %xmm2    # 0x172800
pand %xmm2, %xmm1
movss 0x1b962(%rip), %xmm2    # 0x17274c
divss %xmm2, %xmm1
callq 0x139050
movq -0x8(%rbp), %rax
movss %xmm0, 0x58(%rax)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rdx
movb $0x1, %al
cmpl 0x1a68(%rdx), %ecx
movb %al, -0x1c5(%rbp)
jl 0x156e43
movq -0x8(%rbp), %rax
movss 0x54(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x1b1ad(%rip), %xmm1    # 0x171fdc
mulss 0x1980(%rax), %xmm1
ucomiss %xmm1, %xmm0
seta %al
movb %al, -0x1c5(%rbp)
movb -0x1c5(%rbp), %al
andb $0x1, %al
movb %al, -0x139(%rbp)
testb $0x1, -0x139(%rbp)
je 0x156e6d
movq -0x8(%rbp), %rax
movss 0x50(%rax), %xmm0
movss %xmm0, -0x1cc(%rbp)
jmp 0x156e9e
movq -0x8(%rbp), %rax
movss 0x4c(%rax), %xmm0
movq -0x8(%rbp), %rax
movss 0x50(%rax), %xmm1
movq -0x10(%rbp), %rax
movss 0x18(%rax), %xmm2
movq -0x8(%rbp), %rax
mulss 0x58(%rax), %xmm2
callq 0x15b0e0
movss %xmm0, -0x1cc(%rbp)
movss -0x1cc(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x4c(%rax)
jmp 0x156ebd
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x58(%rax)
movq -0x8(%rbp), %rax
movss 0x2c(%rax), %xmm0
addss -0x3c(%rbp), %xmm0
addss -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x5c(%rax)
movq -0x8(%rbp), %rax
movss 0x34(%rax), %xmm0
subss -0x24(%rbp), %xmm0
subss -0x2c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
jne 0x156f18
movq -0x8(%rbp), %rdi
addq $0x88, %rdi
xorl %esi, %esi
callq 0xe84f0
movq -0x10(%rbp), %rax
movq 0x1ae0(%rax), %rax
movq %rax, -0x148(%rbp)
movq -0x8(%rbp), %rcx
movq -0x148(%rbp), %rax
movq 0x2c(%rcx), %rcx
movq %rcx, 0xd8(%rax)
movq -0x8(%rbp), %rax
movss 0x44(%rax), %xmm0
movss %xmm0, -0x1d0(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xeb860
movaps %xmm0, %xmm1
movss -0x1d0(%rbp), %xmm0
leaq -0x150(%rbp), %rdi
callq 0xbf4c0
movq -0x8(%rbp), %rax
movss 0x7c(%rax), %xmm0
leaq -0x150(%rbp), %rdi
callq 0xd6030
movq -0x148(%rbp), %rax
movss 0xf8(%rax), %xmm0
movq -0x8(%rbp), %rax
movss 0x2c(%rax), %xmm1
movq -0x8(%rbp), %rax
addss 0x48(%rax), %xmm1
callq 0x139050
movq -0x148(%rbp), %rax
movss %xmm0, 0xf8(%rax)
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopl (%rax,%rax)