// File: /workspace/github_cpp_makefile_star2_O3/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, -0x38(%rbp)
movl %edx, -0x30(%rbp)
movq %rsi, %r13
movq %rdi, -0x78(%rbp)
movq 0x20(%rbp), %r14
movq 0x18(%rbp), %rbx
movaps %xmm0, -0x70(%rbp)
movlps %xmm0, -0x90(%rbp)
leaq 0x55936(%rip), %rax     # 0xfbcd0
movq (%rax), %r15
movss 0xec2b(%rip), %xmm0     # 0xb4fd0
movq %rcx, -0x80(%rbp)
movq %rcx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x44a23
movlps %xmm0, -0x88(%rbp)
testq %rbx, %rbx
je 0xa63c7
movb $0x0, (%rbx)
testq %r14, %r14
je 0xa63d0
movb $0x0, (%r14)
movss (%r13), %xmm4
movss 0x8(%r13), %xmm2
movaps %xmm2, %xmm3
subss %xmm4, %xmm3
movss 0xebf9(%rip), %xmm1     # 0xb4fe4
ucomiss %xmm3, %xmm1
jae 0xa66ed
movaps %xmm0, -0xb0(%rbp)
movaps -0x70(%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, -0x30(%rbp)
je 0xa6523
leaq 0x12eb3(%rip), %rdi     # 0xb92e2
xorl %ebx, %ebx
movss 0xeb97(%rip), %xmm0     # 0xb4fd0
xorl %esi, %esi
xorl %edx, %edx
movss %xmm2, -0x2c(%rbp)
movss %xmm4, -0x54(%rbp)
movss %xmm1, -0x50(%rbp)
movss %xmm3, -0x4c(%rbp)
movaps %xmm5, -0xe0(%rbp)
callq 0x44a23
movss -0x2c(%rbp), %xmm1
subss %xmm0, %xmm1
movss %xmm1, -0x2c(%rbp)
movss (%r13), %xmm0
movaps -0x70(%rbp), %xmm3
addss %xmm3, %xmm0
addss -0xb0(%rbp), %xmm0
addss 0xf3df(%rip), %xmm0     # 0xb5868
minss -0x2c(%rbp), %xmm0
movss 0x4(%r13), %xmm1
movss 0x1980(%r15), %xmm2
mulss 0xf423(%rip), %xmm2     # 0xb58c8
movaps -0xe0(%rbp), %xmm4
addss %xmm4, %xmm1
cvttps2dq %xmm2, %xmm2
cvtdq2ps %xmm2, %xmm2
addss %xmm1, %xmm2
leaq -0xd0(%rbp), %rsi
movss %xmm0, (%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 -0x48(%rbp), %rdx
movlps %xmm0, (%rdx)
leaq -0x98(%rbp), %rax
movq %rbx, (%rax)
movq -0x78(%rbp), %rdi
leaq 0x12de4(%rip), %rcx     # 0xb92e2
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq %rax
callq 0x447fc
movss -0x4c(%rbp), %xmm3
movss -0x50(%rbp), %xmm1
movss -0x54(%rbp), %xmm4
movss -0x2c(%rbp), %xmm2
addq $0x10, %rsp
movss %xmm4, -0x48(%rbp)
movss %xmm1, -0x44(%rbp)
movss %xmm2, -0x40(%rbp)
movss %xmm3, -0x3c(%rbp)
testq %r14, %r14
je 0xa654b
addss -0xb0(%rbp), %xmm4
ucomiss %xmm2, %xmm4
seta (%r14)
leaq -0x40(%rbp), %rdx
testl %r12d, %r12d
je 0xa66b2
cmpb $0x0, 0x10(%rbp)
jne 0xa6578
movss 0x8(%r13), %xmm0
subss (%r13), %xmm0
ucomiss 0x15ec(%r15), %xmm0
jb 0xa66b2
movl 0x1b1c(%r15), %eax
cmpl -0x38(%rbp), %eax
sete %cl
cmpl %r12d, %eax
sete %al
orb %cl, %al
jne 0xa65aa
movl 0x1b30(%r15), %eax
cmpl -0x38(%rbp), %eax
setne %cl
cmpl %r12d, %eax
setne %al
testb %al, %cl
jne 0xa66b2
movss %xmm2, -0x2c(%rbp)
leaq 0x5571a(%rip), %rbx     # 0xfbcd0
movq (%rbx), %rax
movq 0x1ae0(%rax), %rax
movq 0x124(%rax), %rcx
movq %rcx, -0x38(%rbp)
movups 0x12c(%rax), %xmm0
movaps %xmm0, -0xd0(%rbp)
movups 0x13c(%rax), %xmm0
movaps %xmm0, -0xc0(%rbp)
movss 0x1980(%r15), %xmm0
movss %xmm0, -0x70(%rbp)
leaq -0x90(%rbp), %r14
movl $0xa, %edi
movq %r14, %rsi
callq 0x4417f
movss 0x4(%r13), %xmm0
movss 0x8(%r13), %xmm1
movss (%r14), %xmm2
addss %xmm2, %xmm2
subss %xmm2, %xmm1
subss -0x70(%rbp), %xmm1
leaq -0x98(%rbp), %rsi
movss %xmm1, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %r12d, %edi
callq 0x917d0
movl %eax, %r14d
movl $0x1, %r15d
movl $0x1, %edi
callq 0x44325
movq (%rbx), %rax
movq 0x1ae0(%rax), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x124(%rax)
movaps -0xd0(%rbp), %xmm0
movups %xmm0, 0x12c(%rax)
movaps -0xc0(%rbp), %xmm0
movups %xmm0, 0x13c(%rax)
testb $0x4, -0x30(%rbp)
jne 0xa669f
movl $0x2, %edi
xorl %esi, %esi
callq 0x51653
movzbl %r14b, %r14d
testb %al, %al
cmovnel %r15d, %r14d
movss -0x2c(%rbp), %xmm2
subss -0x70(%rbp), %xmm2
movaps %xmm2, %xmm1
leaq -0x40(%rbp), %rdx
jmp 0xa66c3
movss 0x8(%r13), %xmm1
addss 0xe910(%rip), %xmm1     # 0xb4fd0
xorl %r14d, %r14d
leaq -0x48(%rbp), %rsi
leaq -0x88(%rbp), %r9
movq -0x78(%rbp), %rdi
movaps %xmm2, %xmm0
movq -0x80(%rbp), %rcx
xorl %r8d, %r8d
callq 0x44b6c
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0xa66ed
movb %r14b, (%rax)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq