// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::BeginMenu(char const*, bool)
bool ImGui::BeginMenu(const char* label, bool enabled)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);
    bool menu_is_open = IsPopupOpen(id, ImGuiPopupFlags_None);

    // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
    ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
    if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu))
        flags |= ImGuiWindowFlags_ChildWindow;

    // If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin().
    // We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame.
    // If somehow this is ever becoming a problem we can switch to use e.g. ImGuiStorage mapping key to last frame used.
    if (g.MenusIdSubmittedThisFrame.contains(id))
    {
        if (menu_is_open)
            menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
        else
            g.NextWindowData.ClearFlags();          // we behave like Begin() and need to consume those values
        return menu_is_open;
    }

    // Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu
    g.MenusIdSubmittedThisFrame.push_back(id);

    ImVec2 label_size = CalcTextSize(label, NULL, true);
    bool pressed;
    bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].OpenParentId == window->IDStack.back());
    ImGuiWindow* backed_nav_window = g.NavWindow;
    if (menuset_is_open)
        g.NavWindow = window;  // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent)

    // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu,
    // However the final position is going to be different! It is chosen by FindBestWindowPosForPopup().
    // e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering.
    ImVec2 popup_pos, pos = window->DC.CursorPos;
    if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
    {
        // Menu inside an horizontal menu bar
        // Selectable extend their highlight by half ItemSpacing in each direction.
        // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin()
        popup_pos = ImVec2(pos.x - 1.0f - IM_FLOOR(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight());
        window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f);
        PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
        float w = label_size.x;
        pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
        PopStyleVar();
        window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
    }
    else
    {
        // Menu inside a menu
        // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
        //  Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
        popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
        float min_w = window->DC.MenuColumns.DeclColumns(label_size.x, 0.0f, IM_FLOOR(g.FontSize * 1.20f)); // Feedback to next frame
        float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
        pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(min_w, 0.0f));
        ImU32 text_col = GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled);
        RenderArrow(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), text_col, ImGuiDir_Right);
    }

    const bool hovered = enabled && ItemHoverable(window->DC.LastItemRect, id);
    if (menuset_is_open)
        g.NavWindow = backed_nav_window;

    bool want_open = false;
    bool want_close = false;
    if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
    {
        // Close menu when not hovering it anymore unless we are moving roughly in the direction of the menu
        // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive.
        bool moving_toward_other_child_menu = false;

        ImGuiWindow* child_menu_window = (g.BeginPopupStack.Size < g.OpenPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].SourceWindow == window) ? g.OpenPopupStack[g.BeginPopupStack.Size].Window : NULL;
        if (g.HoveredWindow == window && child_menu_window != NULL && !(window->Flags & ImGuiWindowFlags_MenuBar))
        {
            // FIXME-DPI: Values should be derived from a master "scale" factor.
            ImRect next_window_rect = child_menu_window->Rect();
            ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta;
            ImVec2 tb = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR();
            ImVec2 tc = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR();
            float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, 5.0f, 30.0f);    // add a bit of extra slack.
            ta.x += (window->Pos.x < child_menu_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues
            tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f);                // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale?
            tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f);
            moving_toward_other_child_menu = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos);
            //GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG]
        }
        if (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_toward_other_child_menu)
            want_close = true;

        if (!menu_is_open && hovered && pressed) // Click to open
            want_open = true;
        else if (!menu_is_open && hovered && !moving_toward_other_child_menu) // Hover to open
            want_open = true;

        if (g.NavActivateId == id)
        {
            want_close = menu_is_open;
            want_open = !menu_is_open;
        }
        if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open
        {
            want_open = true;
            NavMoveRequestCancel();
        }
    }
    else
    {
        // Menu bar
        if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it
        {
            want_close = true;
            want_open = menu_is_open = false;
        }
        else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others
        {
            want_open = true;
        }
        else if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Down) // Nav-Down to open
        {
            want_open = true;
            NavMoveRequestCancel();
        }
    }

    if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
        want_close = true;
    if (want_close && IsPopupOpen(id, ImGuiPopupFlags_None))
        ClosePopupToLevel(g.BeginPopupStack.Size, true);

    IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0));

    if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size)
    {
        // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame.
        OpenPopup(label);
        return false;
    }

    menu_is_open |= want_open;
    if (want_open)
        OpenPopup(label);

    if (menu_is_open)
    {
        SetNextWindowPos(popup_pos, ImGuiCond_Always);
        menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
    }
    else
    {
        g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
    }

    return menu_is_open;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
callq 0xeb270
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x1547c6
movb $0x0, -0x1(%rbp)
jmp 0x1552a8
leaq 0xbe773(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x1560, %rax           # imm = 0x1560
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xc9910
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
xorl %esi, %esi
callq 0xcbb60
andb $0x1, %al
movb %al, -0x35(%rbp)
movl $0x10080145, -0x3c(%rbp) # imm = 0x10080145
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x14000000, %eax       # imm = 0x14000000
cmpl $0x0, %eax
je 0x154828
movl -0x3c(%rbp), %eax
orl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x30c0, %rdi           # imm = 0x30C0
leaq -0x34(%rbp), %rsi
callq 0x1626b0
testb $0x1, %al
jne 0x154842
jmp 0x154877
testb $0x1, -0x35(%rbp)
je 0x15485a
movl -0x34(%rbp), %edi
movl -0x3c(%rbp), %esi
callq 0xde410
andb $0x1, %al
movb %al, -0x35(%rbp)
jmp 0x15486a
movq -0x28(%rbp), %rdi
addq $0x1b88, %rdi           # imm = 0x1B88
callq 0xebb30
movb -0x35(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x1552a8
movq -0x28(%rbp), %rdi
addq $0x30c0, %rdi           # imm = 0x30C0
leaq -0x34(%rbp), %rsi
callq 0xe8e70
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
movss 0x1d6e0(%rip), %xmm0    # 0x171f80
callq 0xc87e0
movlpd %xmm0, -0x44(%rbp)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x4000000, %ecx        # imm = 0x4000000
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xf5(%rbp)
jne 0x154935
movq -0x28(%rbp), %rax
movl 0x1c70(%rax), %ecx
movq -0x28(%rbp), %rdx
xorl %eax, %eax
cmpl 0x1c80(%rdx), %ecx
movb %al, -0xf6(%rbp)
jle 0x154929
movq -0x28(%rbp), %rdi
addq $0x1c70, %rdi           # imm = 0x1C70
movq -0x28(%rbp), %rax
movl 0x1c80(%rax), %esi
callq 0xeb4c0
movl 0x1c(%rax), %eax
movl %eax, -0xfc(%rbp)
movq -0x20(%rbp), %rdi
addq $0xc8, %rdi
callq 0xe9130
movq %rax, %rcx
movl -0xfc(%rbp), %eax
cmpl (%rcx), %eax
sete %al
movb %al, -0xf6(%rbp)
movb -0xf6(%rbp), %al
movb %al, -0xf5(%rbp)
movb -0xf5(%rbp), %al
andb $0x1, %al
movb %al, -0x46(%rbp)
movq -0x28(%rbp), %rax
movq 0x1c90(%rax), %rax
movq %rax, -0x50(%rbp)
testb $0x1, -0x46(%rbp)
je 0x154964
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x1c90(%rax)
leaq -0x58(%rbp), %rdi
callq 0xe7de0
movq -0x20(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1bc(%rax)
jne 0x154b17
movss -0x60(%rbp), %xmm0
movss 0x1c2a2(%rip), %xmm1    # 0x170c3c
subss %xmm1, %xmm0
movq -0x30(%rbp), %rax
movss 0x1d62e(%rip), %xmm1    # 0x171fd8
mulss 0x48(%rax), %xmm1
cvttss2si %xmm1, %eax
cvtsi2ss %eax, %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0x110(%rbp)
movss -0x5c(%rbp), %xmm0
movq -0x30(%rbp), %rax
subss 0x3c(%rax), %xmm0
movss %xmm0, -0x114(%rbp)
movq -0x20(%rbp), %rdi
callq 0xeb760
movss -0x114(%rbp), %xmm1
movaps %xmm0, %xmm2
movss -0x110(%rbp), %xmm0
addss %xmm2, %xmm1
leaq -0x68(%rbp), %rdi
callq 0xbf4c0
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movss 0x1d5c2(%rip), %xmm0    # 0x171fd8
mulss 0x48(%rax), %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movq -0x20(%rbp), %rax
addss 0xd8(%rax), %xmm0
movss %xmm0, 0xd8(%rax)
movq -0x30(%rbp), %rax
movss 0x1d589(%rip), %xmm0    # 0x171fcc
mulss 0x48(%rax), %xmm0
movq -0x30(%rbp), %rax
movss 0x4c(%rax), %xmm1
leaq -0x70(%rbp), %rdi
callq 0xbf4c0
movl $0xd, %edi
leaq -0x70(%rbp), %rsi
callq 0xc7b50
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movb -0x35(%rbp), %al
movb %al, -0x109(%rbp)
movb -0x11(%rbp), %dl
xorb $-0x1, %dl
xorl %eax, %eax
movl $0x8, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
orl $0x300001, %eax         # imm = 0x300001
movl %eax, -0x100(%rbp)
movss -0x74(%rbp), %xmm0
leaq -0x7c(%rbp), %rdi
xorps %xmm1, %xmm1
callq 0xbf4c0
movb -0x109(%rbp), %al
movq -0x108(%rbp), %rdi
movl -0x100(%rbp), %edx
leaq -0x7c(%rbp), %rcx
andb $0x1, %al
movzbl %al, %esi
callq 0x13f2b0
andb $0x1, %al
movb %al, -0x45(%rbp)
movl $0x1, %edi
callq 0xc7c10
movq -0x30(%rbp), %rax
movss 0x3970b(%rip), %xmm0    # 0x18e1fc
mulss 0x48(%rax), %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movq -0x20(%rbp), %rax
addss 0xd8(%rax), %xmm0
movss %xmm0, 0xd8(%rax)
jmp 0x154cf6
movss -0x60(%rbp), %xmm0
movss -0x5c(%rbp), %xmm1
movq -0x30(%rbp), %rax
movss 0x8(%rax), %xmm2
subss %xmm2, %xmm1
leaq -0x84(%rbp), %rdi
callq 0xbf4c0
movq -0x84(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
addq $0x168, %rdi            # imm = 0x168
movss -0x44(%rbp), %xmm0
movq -0x28(%rbp), %rax
movss 0x1980(%rax), %xmm1
movss 0x3968b(%rip), %xmm2    # 0x18e1f4
mulss %xmm2, %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm2
xorps %xmm1, %xmm1
movss %xmm1, -0x12c(%rbp)
callq 0x153fb0
movss %xmm0, -0x88(%rbp)
callq 0xd5b40
movaps %xmm0, %xmm1
movss -0x12c(%rbp), %xmm0
movlpd %xmm1, -0x94(%rbp)
movss -0x94(%rbp), %xmm1
movss -0x88(%rbp), %xmm2
subss %xmm2, %xmm1
callq 0x139050
movss -0x12c(%rbp), %xmm1
movss %xmm0, -0x8c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
movb -0x11(%rbp), %al
notb %al
movzbl %al, %ecx
andl $0x1, %ecx
movl %ecx, %eax
leal 0xb00001(,%rax,8), %eax
movl %eax, -0x13c(%rbp)
movss -0x88(%rbp), %xmm0
movzbl -0x35(%rbp), %eax
movl %eax, -0x14c(%rbp)
leaq -0x9c(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0xbf4c0
movl -0x14c(%rbp), %esi
movq -0x148(%rbp), %rdi
movl -0x13c(%rbp), %edx
movq -0x138(%rbp), %rcx
andl $0x1, %esi
callq 0x13f2b0
movb %al, -0x45(%rbp)
movb -0x11(%rbp), %al
notb %al
movzbl %al, %edi
andl $0x1, %edi
movss 0x1bfed(%rip), %xmm0    # 0x170c3c
callq 0xc76e0
movss -0x12c(%rbp), %xmm1
movl %eax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq 0x2b8(%rax), %rcx
movq %rcx, -0x120(%rbp)
movss 0x17c(%rax), %xmm2
movss -0x8c(%rbp), %xmm0
addss %xmm0, %xmm2
movq -0x28(%rbp), %rax
movss 0x1980(%rax), %xmm0
movss 0x1dab0(%rip), %xmm3    # 0x17274c
mulss %xmm3, %xmm0
addss %xmm2, %xmm0
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0xbf4c0
movq -0x128(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x139090
movq -0x120(%rbp), %rdi
movlpd %xmm0, -0xa8(%rbp)
movl -0xa0(%rbp), %esi
movsd -0xa8(%rbp), %xmm0
movl $0x1, %edx
movss 0x1bf4b(%rip), %xmm1    # 0x170c3c
callq 0x11ca10
xorl %eax, %eax
testb $0x1, -0x11(%rbp)
movb %al, -0x14d(%rbp)
je 0x154d21
movq -0x20(%rbp), %rdi
addq $0xd8, %rdi
addq $0x54, %rdi
movl -0x34(%rbp), %esi
callq 0xca460
movb %al, -0x14d(%rbp)
movb -0x14d(%rbp), %al
andb $0x1, %al
movb %al, -0xb1(%rbp)
testb $0x1, -0x46(%rbp)
je 0x154d44
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x1c90(%rax)
movb $0x0, -0xb2(%rbp)
movb $0x0, -0xb3(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x1, 0x1bc(%rax)
jne 0x155121
movb $0x0, -0xb4(%rbp)
movq -0x28(%rbp), %rax
movl 0x1c80(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1c70(%rcx), %eax
jge 0x154dcb
movq -0x28(%rbp), %rdi
addq $0x1c70, %rdi           # imm = 0x1C70
movq -0x28(%rbp), %rax
movl 0x1c80(%rax), %esi
callq 0xeb4c0
movq 0x10(%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x154dcb
movq -0x28(%rbp), %rdi
addq $0x1c70, %rdi           # imm = 0x1C70
movq -0x28(%rbp), %rax
movl 0x1c80(%rax), %esi
callq 0xeb4c0
movq 0x8(%rax), %rax
movq %rax, -0x158(%rbp)
jmp 0x154dd6
xorl %eax, %eax
movq %rax, -0x158(%rbp)
jmp 0x154dd6
movq -0x158(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x28(%rbp), %rax
movq 0x1ae8(%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x155035
cmpq $0x0, -0xc0(%rbp)
je 0x155035
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x155035
movq -0xc0(%rbp), %rdi
callq 0xeb880
movlpd %xmm0, -0xd0(%rbp)
movlpd %xmm1, -0xc8(%rbp)
movq -0x28(%rbp), %rsi
movq %rsi, %rdi
addq $0x128, %rdi            # imm = 0x128
addq $0x3b8, %rsi            # imm = 0x3B8
callq 0x1390e0
movlpd %xmm0, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movss 0x10(%rax), %xmm1
movq -0xc0(%rbp), %rax
movss 0x10(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x154e8a
leaq -0xd0(%rbp), %rdi
callq 0x162710
movlpd %xmm0, -0xe0(%rbp)
jmp 0x154e9e
leaq -0xd0(%rbp), %rdi
callq 0x162730
movlpd %xmm0, -0xe0(%rbp)
movq -0x20(%rbp), %rax
movss 0x10(%rax), %xmm1
movq -0xc0(%rbp), %rax
movss 0x10(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x154ece
leaq -0xd0(%rbp), %rdi
callq 0xee510
movlpd %xmm0, -0xe8(%rbp)
jmp 0x154ee2
leaq -0xd0(%rbp), %rdi
callq 0xee540
movlpd %xmm0, -0xe8(%rbp)
movss -0xd8(%rbp), %xmm0
subss -0xe0(%rbp), %xmm0
movaps 0x1d907(%rip), %xmm1    # 0x172800
pand %xmm1, %xmm0
movss 0x1d847(%rip), %xmm1    # 0x17274c
mulss %xmm1, %xmm0
movss 0x1d83f(%rip), %xmm1    # 0x172750
movss 0x23697(%rip), %xmm2    # 0x1785b0
callq 0x13c020
movss %xmm0, -0xec(%rbp)
movq -0x20(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0xc0(%rbp), %rax
movss 0x10(%rax), %xmm1
movss 0x392b9(%rip), %xmm3    # 0x18e1fc
movss 0x1d08d(%rip), %xmm2    # 0x171fd8
cmpltss %xmm1, %xmm0
movaps %xmm0, %xmm1
andps %xmm3, %xmm1
andnps %xmm2, %xmm0
orps %xmm1, %xmm0
addss -0xd8(%rbp), %xmm0
movss %xmm0, -0xd8(%rbp)
movss -0xd4(%rbp), %xmm0
movss %xmm0, -0x160(%rbp)
movss -0xdc(%rbp), %xmm0
subss -0xec(%rbp), %xmm0
subss -0xd4(%rbp), %xmm0
movss 0x23678(%rip), %xmm1    # 0x178614
callq 0x139050
movaps %xmm0, %xmm1
movss -0x160(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0xdc(%rbp)
movss -0xd4(%rbp), %xmm0
movss %xmm0, -0x15c(%rbp)
movss -0xe4(%rbp), %xmm0
addss -0xec(%rbp), %xmm0
subss -0xd4(%rbp), %xmm0
movss 0x1d790(%rip), %xmm1    # 0x172778
callq 0x13c690
movaps %xmm0, %xmm1
movss -0x15c(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0xe4(%rbp)
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
addq $0x120, %rcx            # imm = 0x120
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0xc4240
andb $0x1, %al
movb %al, -0xb4(%rbp)
testb $0x1, -0x35(%rbp)
je 0x155081
testb $0x1, -0xb1(%rbp)
jne 0x155081
movq -0x28(%rbp), %rax
movq 0x1ae8(%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x155081
movq -0x28(%rbp), %rax
cmpl $0x0, 0x1b20(%rax)
je 0x155081
movq -0x28(%rbp), %rax
movl 0x1b20(%rax), %eax
cmpl -0x34(%rbp), %eax
je 0x155081
testb $0x1, -0xb4(%rbp)
jne 0x155081
movb $0x1, -0xb3(%rbp)
testb $0x1, -0x35(%rbp)
jne 0x15509f
testb $0x1, -0xb1(%rbp)
je 0x15509f
testb $0x1, -0x45(%rbp)
je 0x15509f
movb $0x1, -0xb2(%rbp)
jmp 0x1550c0
testb $0x1, -0x35(%rbp)
jne 0x1550be
testb $0x1, -0xb1(%rbp)
je 0x1550be
testb $0x1, -0xb4(%rbp)
jne 0x1550be
movb $0x1, -0xb2(%rbp)
jmp 0x1550c0
movq -0x28(%rbp), %rax
movl 0x1ca0(%rax), %eax
cmpl -0x34(%rbp), %eax
jne 0x1550e7
movb -0x35(%rbp), %al
andb $0x1, %al
movb %al, -0xb3(%rbp)
movb -0x35(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0xb2(%rbp)
movq -0x28(%rbp), %rax
movl 0x1c98(%rax), %eax
cmpl -0x34(%rbp), %eax
jne 0x15511c
movq -0x28(%rbp), %rax
testb $0x1, 0x1d00(%rax)
je 0x15511c
movq -0x28(%rbp), %rax
cmpl $0x1, 0x1d10(%rax)
jne 0x15511c
movb $0x1, -0xb2(%rbp)
callq 0xdf680
jmp 0x1551a6
testb $0x1, -0x35(%rbp)
je 0x155147
testb $0x1, -0x45(%rbp)
je 0x155147
testb $0x1, -0x46(%rbp)
je 0x155147
movb $0x1, -0xb3(%rbp)
movb $0x0, -0x35(%rbp)
movb $0x0, -0xb2(%rbp)
jmp 0x1551a4
testb $0x1, -0x45(%rbp)
jne 0x155162
testb $0x1, -0xb1(%rbp)
je 0x15516b
testb $0x1, -0x46(%rbp)
je 0x15516b
testb $0x1, -0x35(%rbp)
jne 0x15516b
movb $0x1, -0xb2(%rbp)
jmp 0x1551a2
movq -0x28(%rbp), %rax
movl 0x1c98(%rax), %eax
cmpl -0x34(%rbp), %eax
jne 0x1551a0
movq -0x28(%rbp), %rax
testb $0x1, 0x1d00(%rax)
je 0x1551a0
movq -0x28(%rbp), %rax
cmpl $0x3, 0x1d10(%rax)
jne 0x1551a0
movb $0x1, -0xb2(%rbp)
callq 0xdf680
jmp 0x1551a2
jmp 0x1551a4
jmp 0x1551a6
testb $0x1, -0x11(%rbp)
jne 0x1551b3
movb $0x1, -0xb3(%rbp)
testb $0x1, -0xb3(%rbp)
je 0x1551e0
movl -0x34(%rbp), %edi
xorl %esi, %esi
callq 0xcbb60
testb $0x1, %al
jne 0x1551cc
jmp 0x1551e0
movq -0x28(%rbp), %rax
movl 0x1c80(%rax), %edi
movl $0x1, %esi
callq 0xde1b0
jmp 0x1551e2
jmp 0x1551e4
testb $0x1, -0x35(%rbp)
jne 0x15521d
testb $0x1, -0xb2(%rbp)
je 0x15521d
movq -0x28(%rbp), %rax
movl 0x1c70(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1c80(%rcx), %eax
jle 0x15521d
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0xdde00
movb $0x0, -0x1(%rbp)
jmp 0x1552a8
movb -0xb2(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movb -0x35(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
orl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x35(%rbp)
testb $0x1, -0xb2(%rbp)
je 0x155251
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0xdde00
testb $0x1, -0x35(%rbp)
je 0x155290
leaq -0xf4(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
leaq -0x58(%rbp), %rdi
movl $0x1, %esi
leaq -0xf4(%rbp), %rdx
callq 0xdab40
movl -0x34(%rbp), %edi
movl -0x3c(%rbp), %esi
callq 0xde410
andb $0x1, %al
movb %al, -0x35(%rbp)
jmp 0x1552a0
movq -0x28(%rbp), %rdi
addq $0x1b88, %rdi           # imm = 0x1B88
callq 0xebb30
movb -0x35(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)