// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableSetColumnWidth(int, float)
void ImGui::TableSetColumnWidth(int column_n, float width)
{
    ImGuiContext& g = *GImGui;
    ImGuiTable* table = g.CurrentTable;
    IM_ASSERT(table != NULL && table->IsLayoutLocked == false);
    IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount);
    ImGuiTableColumn* column_0 = &table->Columns[column_n];
    float column_0_width = width;

    // Apply constraints early
    // Compare both requested and actual given width to avoid overwriting requested width when column is stuck (minimum size, bounded)
    IM_ASSERT(table->MinColumnWidth > 0.0f);
    const float min_width = table->MinColumnWidth;
    const float max_width = ImMax(min_width, TableGetMaxColumnWidth(table, column_n));
    column_0_width = ImClamp(column_0_width, min_width, max_width);
    if (column_0->WidthGiven == column_0_width || column_0->WidthRequest == column_0_width)
        return;

    //IMGUI_DEBUG_LOG("TableSetColumnWidth(%d, %.1f->%.1f)\n", column_0_idx, column_0->WidthGiven, column_0_width);
    ImGuiTableColumn* column_1 = (column_0->NextEnabledColumn != -1) ? &table->Columns[column_0->NextEnabledColumn] : NULL;

    // In this surprisingly not simple because of how we support mixing Fixed and multiple Stretch columns.
    // - All fixed: easy.
    // - All stretch: easy.
    // - One or more fixed + one stretch: easy.
    // - One or more fixed + more than one stretch: tricky.
    // Qt when manual resize is enabled only support a single _trailing_ stretch column.

    // When forwarding resize from Wn| to Fn+1| we need to be considerate of the _NoResize flag on Fn+1.
    // FIXME-TABLE: Find a way to rewrite all of this so interactions feel more consistent for the user.
    // Scenarios:
    // - F1 F2 F3  resize from F1| or F2|   --> ok: alter ->WidthRequested of Fixed column. Subsequent columns will be offset.
    // - F1 F2 F3  resize from F3|          --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered.
    // - F1 F2 W3  resize from F1| or F2|   --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered, but it doesn't make much sense as the Stretch column will always be minimal size.
    // - F1 F2 W3  resize from W3|          --> ok: no-op (disabled by Resize Rule 1)
    // - W1 W2 W3  resize from W1| or W2|   --> ok
    // - W1 W2 W3  resize from W3|          --> ok: no-op (disabled by Resize Rule 1)
    // - W1 F2 F3  resize from F3|          --> ok: no-op (disabled by Resize Rule 1)
    // - W1 F2     resize from F2|          --> ok: no-op (disabled by Resize Rule 1)
    // - W1 W2 F3  resize from W1| or W2|   --> ok
    // - W1 F2 W3  resize from W1| or F2|   --> ok
    // - F1 W2 F3  resize from W2|          --> ok
    // - F1 W3 F2  resize from W3|          --> ok
    // - W1 F2 F3  resize from W1|          --> ok: equivalent to resizing |F2. F3 will not move.
    // - W1 F2 F3  resize from F2|          --> ok
    // All resizes from a Wx columns are locking other columns.

    // Possible improvements:
    // - W1 W2 W3  resize W1|               --> to not be stuck, both W2 and W3 would stretch down. Seems possible to fix. Would be most beneficial to simplify resize of all-weighted columns.
    // - W3 F1 F2  resize W3|               --> to not be stuck past F1|, both F1 and F2 would need to stretch down, which would be lossy or ambiguous. Seems hard to fix.

    // [Resize Rule 1] Can't resize from right of right-most visible column if there is any Stretch column. Implemented in TableUpdateLayout().

    // If we have all Fixed columns OR resizing a Fixed column that doesn't come after a Stretch one, we can do an offsetting resize.
    // This is the preferred resize path
    if (column_0->Flags & ImGuiTableColumnFlags_WidthFixed)
        if (!column_1 || table->LeftMostStretchedColumn == -1 || table->Columns[table->LeftMostStretchedColumn].DisplayOrder >= column_0->DisplayOrder)
        {
            column_0->WidthRequest = column_0_width;
            table->IsSettingsDirty = true;
            return;
        }

    // We can also use previous column if there's no next one (this is used when doing an auto-fit on the right-most stretch column)
    if (column_1 == NULL)
        column_1 = (column_0->PrevEnabledColumn != -1) ? &table->Columns[column_0->PrevEnabledColumn] : NULL;
    if (column_1 == NULL)
        return;

    // Resizing from right-side of a Stretch column before a Fixed column forward sizing to left-side of fixed column.
    // (old_a + old_b == new_a + new_b) --> (new_a == old_a + old_b - new_b)
    float column_1_width = ImMax(column_1->WidthRequest - (column_0_width - column_0->WidthRequest), min_width);
    column_0_width = column_0->WidthRequest + column_1->WidthRequest - column_1_width;
    IM_ASSERT(column_0_width > 0.0f && column_1_width > 0.0f);
    column_0->WidthRequest = column_0_width;
    column_1->WidthRequest = column_1_width;
    if ((column_0->Flags | column_1->Flags) & ImGuiTableColumnFlags_WidthStretch)
        TableUpdateColumnsWeightFromWidth(table);
    table->IsSettingsDirty = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
leaq 0x748ce(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq 0x20a8(%rax), %rbx
testq %rbx, %rbx
je 0x875d8
cmpb $0x0, 0x248(%rbx)
jne 0x875d8
movl %edi, %esi
testl %edi, %edi
js 0x875f7
cmpl %esi, 0x6c(%rbx)
jle 0x875f7
movl %esi, %eax
imulq $0x68, %rax, %r14
addq 0x10(%rbx), %r14
cmpq 0x18(%rbx), %r14
jae 0x87616
movaps %xmm0, -0x20(%rbp)
movss 0xb4(%rbx), %xmm1
xorps %xmm0, %xmm0
movaps %xmm1, -0x30(%rbp)
ucomiss %xmm0, %xmm1
jbe 0x87635
movq %rbx, %rdi
callq 0x887ca
movaps %xmm0, %xmm1
movaps -0x30(%rbp), %xmm4
cmpless %xmm4, %xmm1
movaps %xmm1, %xmm2
andnps %xmm0, %xmm2
andps %xmm4, %xmm1
orps %xmm2, %xmm1
movaps -0x20(%rbp), %xmm2
minss %xmm2, %xmm1
cmpltss %xmm4, %xmm2
movaps %xmm2, %xmm0
andnps %xmm1, %xmm0
andps %xmm4, %xmm2
orps %xmm0, %xmm2
movss 0x4(%r14), %xmm0
ucomiss %xmm2, %xmm0
jne 0x874af
jnp 0x875cf
movss 0x10(%r14), %xmm0
ucomiss %xmm2, %xmm0
jne 0x874c0
jnp 0x875cf
movsbq 0x55(%r14), %rax
cmpq $-0x1, %rax
je 0x874f8
testb %al, %al
js 0x87616
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rdx
imulq $0x68, %rax, %rax
addq %rcx, %rax
cmpq %rdx, %rax
jae 0x87616
testb $0x8, (%r14)
jne 0x8752d
testq %rcx, %rcx
jne 0x87566
jmp 0x87502
testb $0x8, (%r14)
jne 0x875c2
movsbl 0x54(%r14), %esi
cmpl $-0x1, %esi
je 0x875cf
leaq 0x10(%rbx), %rdi
movaps %xmm2, -0x20(%rbp)
callq 0x8fa4c
movaps -0x30(%rbp), %xmm4
movaps -0x20(%rbp), %xmm2
movss 0x10(%r14), %xmm0
jmp 0x87566
testq %rcx, %rcx
je 0x875c2
movsbq 0x23c(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x875c2
testb %sil, %sil
js 0x87616
imulq $0x68, %rsi, %rsi
addq %rsi, %rcx
cmpq %rdx, %rcx
jae 0x87616
movb 0x52(%rcx), %cl
cmpb 0x52(%r14), %cl
jge 0x875c2
movss 0x10(%rax), %xmm1
subss %xmm0, %xmm2
movaps %xmm1, %xmm3
subss %xmm2, %xmm3
movaps %xmm4, %xmm2
cmpless %xmm3, %xmm2
andps %xmm2, %xmm3
andnps %xmm4, %xmm2
orps %xmm3, %xmm2
xorps %xmm3, %xmm3
ucomiss %xmm3, %xmm2
jbe 0x87654
addss %xmm0, %xmm1
subss %xmm2, %xmm1
ucomiss %xmm3, %xmm1
jbe 0x87654
movss %xmm1, 0x10(%r14)
movss %xmm2, 0x10(%rax)
movl (%rax), %eax
orl (%r14), %eax
testb $0x4, %al
je 0x875c8
movq %rbx, %rdi
callq 0x8bdff
jmp 0x875c8
movss %xmm2, 0x10(%r14)
movb $0x1, 0x24f(%rbx)
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x48327(%rip), %rdi     # 0xcf906
leaq 0x478a4(%rip), %rsi     # 0xcee8a
leaq 0x4834b(%rip), %rcx     # 0xcf938
movl $0x7ad, %edx            # imm = 0x7AD
callq 0xc140
leaq 0x480f6(%rip), %rdi     # 0xcf6f4
leaq 0x47885(%rip), %rsi     # 0xcee8a
leaq 0x4832c(%rip), %rcx     # 0xcf938
movl $0x7ae, %edx            # imm = 0x7AE
callq 0xc140
leaq 0x3309b(%rip), %rdi     # 0xba6b8
leaq 0x3201b(%rip), %rsi     # 0xb963f
leaq 0x330a6(%rip), %rcx     # 0xba6d1
movl $0x20e, %edx            # imm = 0x20E
callq 0xc140
leaq 0x48328(%rip), %rdi     # 0xcf964
leaq 0x47847(%rip), %rsi     # 0xcee8a
leaq 0x482ee(%rip), %rcx     # 0xcf938
movl $0x7b4, %edx            # imm = 0x7B4
callq 0xc140
leaq 0x48326(%rip), %rdi     # 0xcf981
leaq 0x47828(%rip), %rsi     # 0xcee8a
leaq 0x482cf(%rip), %rcx     # 0xcf938
movl $0x7f2, %edx            # imm = 0x7F2
callq 0xc140