// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::ShrinkWidths(ImGuiShrinkWidthItem*, int, float)
void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess)
{
    if (count == 1)
    {
        if (items[0].Width >= 0.0f)
            items[0].Width = ImMax(items[0].Width - width_excess, 1.0f);
        return;
    }
    ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer);
    int count_same_width = 1;
    while (width_excess > 0.0f && count_same_width < count)
    {
        while (count_same_width < count && items[0].Width <= items[count_same_width].Width)
            count_same_width++;
        float max_width_to_remove_per_item = (count_same_width < count && items[count_same_width].Width >= 0.0f) ? (items[0].Width - items[count_same_width].Width) : (items[0].Width - 1.0f);
        if (max_width_to_remove_per_item <= 0.0f)
            break;
        float width_to_remove_per_item = ImMin(width_excess / count_same_width, max_width_to_remove_per_item);
        for (int item_n = 0; item_n < count_same_width; item_n++)
            items[item_n].Width -= width_to_remove_per_item;
        width_excess -= width_to_remove_per_item * count_same_width;
    }

    // Round width and redistribute remainder left-to-right (could make it an option of the function?)
    // Ensure that e.g. the right-most tab of a shrunk tab-bar always reaches exactly at the same distance from the right-most edge of the tab bar separator.
    width_excess = 0.0f;
    for (int n = 0; n < count; n++)
    {
        float width_rounded = ImFloor(items[n].Width);
        width_excess += items[n].Width - width_rounded;
        items[n].Width = width_rounded;
    }
    if (width_excess > 0.0f)
        for (int n = 0; n < count; n++)
            if (items[n].Index < (int)(width_excess + 0.01f))
                items[n].Width += 1.0f;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x1, %esi
jne 0x958ac
movss 0x4(%rbx), %xmm2
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm2
jb 0x959e4
subss %xmm0, %xmm2
maxss 0x21742(%rip), %xmm2    # 0xb6fe4
movss %xmm2, 0x4(%rbx)
jmp 0x959e4
movl %esi, %r14d
movslq %esi, %rsi
leaq 0x134(%rip), %rcx       # 0x959ed
movl $0x8, %edx
movq %rbx, %rdi
movss %xmm0, -0x14(%rbp)
callq 0xc620
movss -0x14(%rbp), %xmm6
leaq 0x4(%rbx), %rax
movl $0x1, %ecx
xorps %xmm0, %xmm0
movss 0x216ec(%rip), %xmm1    # 0xb6fd0
cmpl %r14d, %ecx
jge 0x9596e
ucomiss %xmm0, %xmm6
jbe 0x9596e
movss 0x4(%rbx), %xmm2
movslq %ecx, %rdx
leaq (%rax,%rdx,8), %rdx
movss (%rdx), %xmm3
ucomiss %xmm2, %xmm3
jb 0x95914
incl %ecx
addq $0x8, %rdx
cmpl %ecx, %r14d
jne 0x958fe
jmp 0x95919
ucomiss %xmm0, %xmm3
jae 0x95924
movss 0x4(%rbx), %xmm2
addss %xmm1, %xmm2
jmp 0x95928
subss %xmm3, %xmm2
ucomiss %xmm2, %xmm0
jae 0x95965
xorps %xmm4, %xmm4
cvtsi2ss %ecx, %xmm4
movaps %xmm6, %xmm3
divss %xmm4, %xmm3
minss %xmm2, %xmm3
testl %ecx, %ecx
jle 0x9595d
movl %ecx, %edx
xorl %esi, %esi
movss (%rax,%rsi,8), %xmm5
subss %xmm3, %xmm5
movss %xmm5, (%rax,%rsi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x95947
mulss %xmm4, %xmm3
subss %xmm3, %xmm6
ucomiss %xmm2, %xmm0
jb 0x958e4
xorps %xmm1, %xmm1
movl %r14d, %eax
xorps %xmm0, %xmm0
testl %r14d, %r14d
jle 0x959a1
xorl %ecx, %ecx
movss 0x4(%rbx,%rcx,8), %xmm2
cvttps2dq %xmm2, %xmm3
cvtdq2ps %xmm3, %xmm3
subss %xmm3, %xmm2
addss %xmm2, %xmm0
movss %xmm3, 0x4(%rbx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x9597e
ucomiss %xmm1, %xmm0
setbe %cl
testl %r14d, %r14d
setle %dl
orb %cl, %dl
jne 0x959e4
addss 0x2755b(%rip), %xmm0    # 0xbcf14
cvttss2si %xmm0, %ecx
xorl %edx, %edx
movss 0x2161d(%rip), %xmm0    # 0xb6fe4
cmpl %ecx, (%rbx,%rdx,8)
jge 0x959dc
movss 0x4(%rbx,%rdx,8), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x4(%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x959c7
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq