// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableUpdateBorders(ImGuiTable*)
void ImGui::TableUpdateBorders(ImGuiTable* table)
{
    ImGuiContext& g = *GImGui;
    IM_ASSERT(table->Flags & ImGuiTableFlags_Resizable);

    // At this point OuterRect height may be zero or under actual final height, so we rely on temporal coherency and
    // use the final height from last frame. Because this is only affecting _interaction_ with columns, it is not
    // really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height).
    // Actual columns highlight/render will be performed in EndTable() and not be affected.
    const float hit_half_width = TABLE_RESIZE_SEPARATOR_HALF_THICKNESS;
    const float hit_y1 = table->OuterRect.Min.y;
    const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table->LastOuterHeight);
    const float hit_y2_head = hit_y1 + table->LastFirstRowHeight;

    for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
    {
        if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n)))
            continue;

        const int column_n = table->DisplayOrderToIndex[order_n];
        ImGuiTableColumn* column = &table->Columns[column_n];
        if (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_))
            continue;

        // ImGuiTableFlags_NoBordersInBodyUntilResize will be honored in TableDrawBorders()
        const float border_y2_hit = (table->Flags & ImGuiTableFlags_NoBordersInBody) ? hit_y2_head : hit_y2_body;
        if ((table->Flags & ImGuiTableFlags_NoBordersInBody) && table->IsUsingHeaders == false)
            continue;

        if (table->FreezeColumnsCount > 0)
            if (column->MaxX < table->Columns[table->DisplayOrderToIndex[table->FreezeColumnsCount - 1]].MaxX)
                continue;

        ImGuiID column_id = TableGetColumnResizeID(table, column_n, table->InstanceCurrent);
        ImRect hit_rect(column->MaxX - hit_half_width, hit_y1, column->MaxX + hit_half_width, border_y2_hit);
        //GetForegroundDrawList()->AddRect(hit_rect.Min, hit_rect.Max, IM_COL32(255, 0, 0, 100));
        KeepAliveID(column_id);

        bool hovered = false, held = false;
        bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick);
        if (pressed && IsMouseDoubleClicked(0))
        {
            TableSetColumnWidthAutoSingle(table, column_n);
            ClearActiveID();
            held = hovered = false;
        }
        if (held)
        {
            if (table->LastResizedColumn == -1)
                table->ResizeLockMinContentsX2 = table->RightMostEnabledColumn != -1 ? table->Columns[table->RightMostEnabledColumn].MaxX : -FLT_MAX;
            table->ResizedColumn = (ImGuiTableColumnIdx)column_n;
            table->InstanceInteracted = table->InstanceCurrent;
        }
        if ((hovered && g.HoveredIdTimer > TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER) || held)
        {
            table->HoveredColumnBorder = (ImGuiTableColumnIdx)column_n;
            SetMouseCursor(ImGuiMouseCursor_ResizeEW);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xe5c1d(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12d33b
jmp 0x12d35a
leaq 0x5ef96(%rip), %rdi     # 0x18c2d8
leaq 0x5ec59(%rip), %rsi     # 0x18bfa2
movl $0x44b, %edx            # imm = 0x44B
leaq 0x5efac(%rip), %rcx     # 0x18c301
callq 0xd180
movss 0x453d2(%rip), %xmm0    # 0x172734
movss %xmm0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movss 0xf0(%rax), %xmm0
movss %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movss 0xf8(%rax), %xmm0
movss -0x18(%rbp), %xmm1
movq -0x8(%rbp), %rax
addss 0xcc(%rax), %xmm1
callq 0x12a620
movss %xmm0, -0x1c(%rbp)
movss -0x18(%rbp), %xmm0
movq -0x8(%rbp), %rax
addss 0xd0(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x12d677
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x24(%rbp), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x12d3f0
jmp 0x12d669
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movl -0x24(%rbp), %esi
callq 0x1370a0
movsbl (%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x28(%rbp), %esi
callq 0xeea20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x40000010, %eax       # imm = 0x40000010
cmpl $0x0, %eax
je 0x12d42f
jmp 0x12d669
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x12d44c
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
jmp 0x12d456
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x12d48a
movq -0x8(%rbp), %rax
movb 0x24c(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x12d48a
jmp 0x12d669
movq -0x8(%rbp), %rax
movsbl 0x243(%rax), %eax
cmpl $0x0, %eax
jle 0x12d4f1
movq -0x30(%rbp), %rax
movss 0xc(%rax), %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rax
movsbl 0x243(%rax), %esi
subl $0x1, %esi
callq 0x1370a0
movq -0x60(%rbp), %rdi
movsbl (%rax), %esi
callq 0xeea20
movss -0x54(%rbp), %xmm1
movss 0xc(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x12d4ef
jmp 0x12d669
jmp 0x12d4f1
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
movq -0x8(%rbp), %rax
movswl 0x78(%rax), %edx
callq 0x12db70
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movss 0xc(%rax), %xmm0
movss 0x4521b(%rip), %xmm1    # 0x172734
subss %xmm1, %xmm0
movss -0x18(%rbp), %xmm1
movq -0x30(%rbp), %rax
movss 0x45206(%rip), %xmm2    # 0x172734
addss 0xc(%rax), %xmm2
movss -0x34(%rbp), %xmm3
leaq -0x48(%rbp), %rdi
callq 0xec090
movl -0x38(%rbp), %edi
callq 0xc9a90
movb $0x0, -0x49(%rbp)
movb $0x0, -0x4a(%rbp)
movl -0x38(%rbp), %esi
leaq -0x48(%rbp), %rdi
leaq -0x49(%rbp), %rdx
leaq -0x4a(%rbp), %rcx
movl $0x1910, %r8d           # imm = 0x1910
callq 0x139df0
andb $0x1, %al
movb %al, -0x4b(%rbp)
testb $0x1, -0x4b(%rbp)
je 0x12d59c
xorl %edi, %edi
callq 0xd4ed0
testb $0x1, %al
jne 0x12d583
jmp 0x12d59c
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x12dbf0
callq 0xca040
movb $0x0, -0x49(%rbp)
movb $0x0, -0x4a(%rbp)
testb $0x1, -0x4a(%rbp)
je 0x12d629
movq -0x8(%rbp), %rax
movsbl 0x238(%rax), %eax
cmpl $-0x1, %eax
jne 0x12d60a
movq -0x8(%rbp), %rax
movsbl 0x23e(%rax), %eax
cmpl $-0x1, %eax
je 0x12d5ea
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movq -0x8(%rbp), %rax
movsbl 0x23e(%rax), %esi
callq 0xeea20
movss 0xc(%rax), %xmm0
movss %xmm0, -0x64(%rbp)
jmp 0x12d5f9
movss 0x45166(%rip), %xmm0    # 0x172758
movss %xmm0, -0x64(%rbp)
jmp 0x12d5f9
movss -0x64(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0xe4(%rax)
movl -0x28(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x237(%rax)
movq -0x8(%rbp), %rax
movw 0x78(%rax), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x7a(%rax)
testb $0x1, -0x49(%rbp)
je 0x12d648
movq -0x10(%rbp), %rax
movss 0x1b28(%rax), %xmm0
movss 0x56301(%rip), %xmm1    # 0x183944
ucomiss %xmm1, %xmm0
ja 0x12d64e
testb $0x1, -0x4a(%rbp)
je 0x12d667
movl -0x28(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x235(%rax)
movl $0x4, %edi
callq 0xd5340
jmp 0x12d669
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x12d3bc
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)