// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::TabItemLabelAndCloseButton(ImDrawList*, ImRect const&, int, ImVec2, char const*, unsigned int, unsigned int, bool, bool*, bool*)
void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped)
{
    ImGuiContext& g = *GImGui;
    ImVec2 label_size = CalcTextSize(label, NULL, true);

    if (out_just_closed)
        *out_just_closed = false;
    if (out_text_clipped)
        *out_text_clipped = false;

    if (bb.GetWidth() <= 1.0f)
        return;

    // In Style V2 we'll have full override of all colors per state (e.g. focused, selected)
    // But right now if you want to alter text color of tabs this is what you need to do.
#if 0
    const float backup_alpha = g.Style.Alpha;
    if (!is_contents_visible)
        g.Style.Alpha *= 0.7f;
#endif

    // Render text label (with clipping + alpha gradient) + unsaved marker
    const char* TAB_UNSAVED_MARKER = "*";
    ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y);
    if (flags & ImGuiTabItemFlags_UnsavedDocument)
    {
        text_pixel_clip_bb.Max.x -= CalcTextSize(TAB_UNSAVED_MARKER, NULL, false).x;
        ImVec2 unsaved_marker_pos(ImMin(bb.Min.x + frame_padding.x + label_size.x + 2, text_pixel_clip_bb.Max.x), bb.Min.y + frame_padding.y + IM_FLOOR(-g.FontSize * 0.25f));
        RenderTextClippedEx(draw_list, unsaved_marker_pos, bb.Max - frame_padding, TAB_UNSAVED_MARKER, NULL, NULL);
    }
    ImRect text_ellipsis_clip_bb = text_pixel_clip_bb;

    // Return clipped state ignoring the close button
    if (out_text_clipped)
    {
        *out_text_clipped = (text_ellipsis_clip_bb.Min.x + label_size.x) > text_pixel_clip_bb.Max.x;
        //draw_list->AddCircle(text_ellipsis_clip_bb.Min, 3.0f, *out_text_clipped ? IM_COL32(255, 0, 0, 255) : IM_COL32(0, 255, 0, 255));
    }

    // Close Button
    // We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap()
    //  'hovered' will be true when hovering the Tab but NOT when hovering the close button
    //  'g.HoveredId==id' will be true when hovering the Tab including when hovering the close button
    //  'g.ActiveId==close_button_id' will be true when we are holding on the close button, in which case both hovered booleans are false
    bool close_button_pressed = false;
    bool close_button_visible = false;
    if (close_button_id != 0)
        if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForCloseButton)
            if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == tab_id || g.ActiveId == close_button_id)
                close_button_visible = true;
    if (close_button_visible)
    {
        ImGuiLastItemDataBackup last_item_backup;
        const float close_button_sz = g.FontSize;
        PushStyleVar(ImGuiStyleVar_FramePadding, frame_padding);
        if (CloseButton(close_button_id, ImVec2(bb.Max.x - frame_padding.x * 2.0f - close_button_sz, bb.Min.y)))
            close_button_pressed = true;
        PopStyleVar();
        last_item_backup.Restore();

        // Close with middle mouse button
        if (!(flags & ImGuiTabItemFlags_NoCloseWithMiddleMouseButton) && IsMouseClicked(2))
            close_button_pressed = true;

        text_pixel_clip_bb.Max.x -= close_button_sz;
    }

    // FIXME: if FramePadding is noticeably large, ellipsis_max_x will be wrong here (e.g. #3497), maybe for consistency that parameter of RenderTextEllipsis() shouldn't exist..
    float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f;
    RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size);

#if 0
    if (!is_contents_visible)
        g.Style.Alpha = backup_alpha;
#endif

    if (out_just_closed)
        *out_just_closed = close_button_pressed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %r9d, %r12d
movl %r8d, -0x30(%rbp)
movl %edx, -0x34(%rbp)
movq %rsi, %r13
movq %rdi, -0x68(%rbp)
movq 0x20(%rbp), %r15
movq 0x18(%rbp), %rbx
movaps %xmm0, -0x60(%rbp)
movlps %xmm0, -0x80(%rbp)
leaq 0x562d1(%rip), %rax     # 0xe3ce0
movq (%rax), %r14
pushq $0x1
popq %rdx
movss 0xe5d3(%rip), %xmm0     # 0x9bff0
movq %rcx, -0x70(%rbp)
movq %rcx, %rdi
xorl %esi, %esi
callq 0x365e8
movlps %xmm0, -0x78(%rbp)
testq %rbx, %rbx
je 0x8da37
movb $0x0, (%rbx)
testq %r15, %r15
je 0x8da40
movb $0x0, (%r15)
movss (%r13), %xmm4
movss 0x8(%r13), %xmm2
movaps %xmm2, %xmm3
subss %xmm4, %xmm3
movss 0xe59d(%rip), %xmm1     # 0x9bff8
ucomiss %xmm3, %xmm1
jae 0x8dd2f
movaps %xmm0, -0xa0(%rbp)
movaps -0x60(%rbp), %xmm0
movaps %xmm0, %xmm5
shufps $0x55, %xmm0, %xmm5     # xmm5 = xmm5[1,1],xmm0[1,1]
addss %xmm0, %xmm4
movss 0x4(%r13), %xmm1
addss %xmm5, %xmm1
subss %xmm0, %xmm2
movss 0xc(%r13), %xmm3
testb $0x1, -0x34(%rbp)
je 0x8db92
leaq 0x12873(%rip), %rbx     # 0xa0312
movss 0xe549(%rip), %xmm0     # 0x9bff0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movss %xmm2, -0x2c(%rbp)
movss %xmm4, -0x40(%rbp)
movss %xmm1, -0x3c(%rbp)
movss %xmm3, -0x38(%rbp)
movaps %xmm5, -0xb0(%rbp)
callq 0x365e8
movss (%r13), %xmm1
movaps -0x60(%rbp), %xmm3
addss %xmm3, %xmm1
addss -0xa0(%rbp), %xmm1
addss 0xeda8(%rip), %xmm1     # 0x9c894
movss -0x2c(%rbp), %xmm2
subss %xmm0, %xmm2
movss %xmm2, -0x2c(%rbp)
minss -0x2c(%rbp), %xmm1
movss 0x4(%r13), %xmm0
movaps -0xb0(%rbp), %xmm4
addss %xmm4, %xmm0
movss 0x1980(%r14), %xmm2
mulss 0xedd7(%rip), %xmm2     # 0x9c8f8
cvttps2dq %xmm2, %xmm2
cvtdq2ps %xmm2, %xmm2
addss %xmm0, %xmm2
leaq -0xd8(%rbp), %rsi
movss %xmm1, (%rsi)
movss %xmm2, 0x4(%rsi)
movss 0x8(%r13), %xmm0
movss 0xc(%r13), %xmm1
subss %xmm3, %xmm0
subss %xmm4, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
leaq -0x50(%rbp), %rdx
movlps %xmm0, (%rdx)
leaq -0x88(%rbp), %rax
andq $0x0, (%rax)
movq -0x68(%rbp), %rdi
movq %rbx, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq %rax
callq 0x36445
movss -0x38(%rbp), %xmm3
movss -0x3c(%rbp), %xmm1
movss -0x40(%rbp), %xmm4
movss -0x2c(%rbp), %xmm2
addq $0x10, %rsp
movss %xmm4, -0x50(%rbp)
movss %xmm1, -0x4c(%rbp)
movss %xmm2, -0x48(%rbp)
movss %xmm3, -0x44(%rbp)
testq %r15, %r15
je 0x8dbba
addss -0xa0(%rbp), %xmm4
ucomiss %xmm2, %xmm4
seta (%r15)
leaq -0x48(%rbp), %rbx
testl %r12d, %r12d
je 0x8dcf4
cmpb $0x0, 0x10(%rbp)
jne 0x8dbe7
movss 0x8(%r13), %xmm0
subss (%r13), %xmm0
ucomiss 0x15ec(%r14), %xmm0
jb 0x8dcf4
movl 0x1b1c(%r14), %eax
cmpl -0x30(%rbp), %eax
sete %cl
cmpl %r12d, %eax
sete %al
orb %cl, %al
jne 0x8dc19
movl 0x1b30(%r14), %eax
cmpl -0x30(%rbp), %eax
setne %cl
cmpl %r12d, %eax
setne %al
testb %al, %cl
jne 0x8dcf4
movss %xmm2, -0x2c(%rbp)
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
callq 0x93158
movss 0x1980(%r14), %xmm0
movss %xmm0, -0x60(%rbp)
pushq $0xa
popq %rdi
leaq -0x80(%rbp), %r14
movq %r14, %rsi
callq 0x35fca
movss 0x4(%r13), %xmm0
movss 0x8(%r13), %xmm1
movss (%r14), %xmm2
addss %xmm2, %xmm2
subss %xmm2, %xmm1
subss -0x60(%rbp), %xmm1
leaq -0x88(%rbp), %rsi
movss %xmm1, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %r12d, %edi
callq 0x7a9f1
movl %eax, %r14d
pushq $0x1
popq %r12
movl %r12d, %edi
callq 0x3605c
leaq 0x5604a(%rip), %rax     # 0xe3ce0
movq (%rax), %rax
movq 0x1ae0(%rax), %rax
movl (%r15), %ecx
movl %ecx, 0x124(%rax)
movl 0x4(%r15), %ecx
movl %ecx, 0x128(%rax)
movups 0x8(%r15), %xmm0
movups %xmm0, 0x12c(%rax)
movups 0x18(%r15), %xmm0
movups %xmm0, 0x13c(%rax)
testb $0x4, -0x34(%rbp)
jne 0x8dce5
pushq $0x2
popq %rdi
xorl %esi, %esi
callq 0x401cd
movzbl %r14b, %r14d
testb %al, %al
cmovnel %r12d, %r14d
movss -0x2c(%rbp), %xmm2
subss -0x60(%rbp), %xmm2
movaps %xmm2, %xmm1
jmp 0x8dd05
movss 0x8(%r13), %xmm1
addss 0xe2ee(%rip), %xmm1     # 0x9bff0
xorl %r14d, %r14d
leaq -0x50(%rbp), %rsi
leaq -0x78(%rbp), %r9
movq -0x68(%rbp), %rdi
movq %rbx, %rdx
movaps %xmm2, %xmm0
movq -0x70(%rbp), %rcx
xorl %r8d, %r8d
callq 0x36718
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0x8dd2f
movb %r14b, (%rax)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq