// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableGetMaxColumnWidth(ImGuiTable const*, int)
float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n)
{
    const ImGuiTableColumn* column = &table->Columns[column_n];
    float max_width = FLT_MAX;
    const float min_column_distance = table->MinColumnWidth + table->CellPaddingX * 2.0f + table->CellSpacingX1 + table->CellSpacingX2;
    if (table->Flags & ImGuiTableFlags_ScrollX)
    {
        // Frozen columns can't reach beyond visible width else scrolling will naturally break.
        if (column->DisplayOrder < table->FreezeColumnsRequest)
        {
            max_width = (table->InnerClipRect.Max.x - (table->FreezeColumnsRequest - column->DisplayOrder) * min_column_distance) - column->MinX;
            max_width = max_width - table->OuterPaddingX - table->CellPaddingX - table->CellSpacingX2;
        }
    }
    else if ((table->Flags & ImGuiTableFlags_NoKeepColumnsVisible) == 0)
    {
        // If horizontal scrolling if disabled, we apply a final lossless shrinking of columns in order to make
        // sure they are all visible. Because of this we also know that all of the columns will always fit in
        // table->WorkRect and therefore in table->InnerRect (because ScrollX is off)
        // FIXME-TABLE: This is solved incorrectly but also quite a difficult problem to fix as we also want ClipRect width to match.
        // See "table_width_distrib" and "table_width_keep_visible" tests
        max_width = table->WorkRect.Max.x - (table->ColumnsEnabledCount - column->IndexWithinEnabledSet - 1) * min_column_distance - column->MinX;
        //max_width -= table->CellSpacingX1;
        max_width -= table->CellSpacingX2;
        max_width -= table->CellPaddingX * 2.0f;
        max_width -= table->OuterPaddingX;
    }
    return max_width;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0xc(%rbp), %esi
callq 0x1373f0
movq %rax, -0x18(%rbp)
movss 0x451a9(%rip), %xmm0    # 0x171fb4
movss %xmm0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movss 0xb4(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0xbc(%rax), %xmm0
addss %xmm0, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
addss 0xc4(%rax), %xmm0
movq -0x8(%rbp), %rax
addss 0xc8(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x0, %eax
je 0x12cef9
movq -0x18(%rbp), %rax
movsbl 0x52(%rax), %eax
movq -0x8(%rbp), %rcx
movsbl 0x242(%rcx), %ecx
cmpl %ecx, %eax
jge 0x12cef4
movq -0x8(%rbp), %rax
movss 0x124(%rax), %xmm1
movq -0x8(%rbp), %rax
movsbl 0x242(%rax), %eax
movq -0x18(%rbp), %rcx
movsbl 0x52(%rcx), %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss -0x20(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x18(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
movq -0x8(%rbp), %rax
subss 0xb8(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0xbc(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0xc8(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x12cfbf
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
jne 0x12cfbd
movq -0x8(%rbp), %rax
movss 0x114(%rax), %xmm1
movq -0x8(%rbp), %rax
movsbl 0x231(%rax), %eax
movq -0x18(%rbp), %rcx
movsbl 0x53(%rcx), %ecx
subl %ecx, %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm0
movss -0x20(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x18(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movss 0xc8(%rax), %xmm1
movss -0x1c(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movss 0xbc(%rax), %xmm0
movss -0x1c(%rbp), %xmm1
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
addss %xmm0, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movss 0xb8(%rax), %xmm1
movss -0x1c(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x12cfbf
movss -0x1c(%rbp), %xmm0
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)