// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableSortSpecsBuild(ImGuiTable*)
void ImGui::TableSortSpecsBuild(ImGuiTable* table)
{
    IM_ASSERT(table->IsSortSpecsDirty);
    TableSortSpecsSanitize(table);

    // Write output
    table->SortSpecsMulti.resize(table->SortSpecsCount <= 1 ? 0 : table->SortSpecsCount);
    ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &table->SortSpecsSingle : table->SortSpecsMulti.Data;
    for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
    {
        ImGuiTableColumn* column = &table->Columns[column_n];
        if (column->SortOrder == -1)
            continue;
        IM_ASSERT(column->SortOrder < table->SortSpecsCount);
        ImGuiTableColumnSortSpecs* sort_spec = &sort_specs[column->SortOrder];
        sort_spec->ColumnUserID = column->UserID;
        sort_spec->ColumnIndex = (ImGuiTableColumnIdx)column_n;
        sort_spec->SortOrder = (ImGuiTableColumnIdx)column->SortOrder;
        sort_spec->SortDirection = column->SortDirection;
    }
    table->SortSpecs.Specs = sort_specs;
    table->SortSpecs.SpecsCount = table->SortSpecsCount;
    table->SortSpecs.SpecsDirty = true; // Mark as dirty for user
    table->IsSortSpecsDirty = false; // Mark as not dirty for us
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x24b(%rax)
je 0x12d98b
jmp 0x12d9aa
leaq 0x5f7c4(%rip), %rdi     # 0x18d156
leaq 0x5e609(%rip), %rsi     # 0x18bfa2
movl $0xa55, %edx            # imm = 0xA55
leaq 0x5f7c9(%rip), %rcx     # 0x18d16e
callq 0xd180
movq -0x8(%rbp), %rdi
callq 0x132670
movq -0x8(%rbp), %rax
addq $0x210, %rax            # imm = 0x210
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movsbl 0x230(%rax), %eax
cmpl $0x1, %eax
jg 0x12d9d8
xorl %eax, %eax
movl %eax, -0x34(%rbp)
jmp 0x12d9e6
movq -0x8(%rbp), %rax
movsbl 0x230(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x137730
movq -0x8(%rbp), %rax
movsbl 0x230(%rax), %eax
cmpl $0x0, %eax
jne 0x12da0a
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x12da41
movq -0x8(%rbp), %rax
movsbl 0x230(%rax), %eax
cmpl $0x1, %eax
jne 0x12da2a
movq -0x8(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
movq %rax, -0x48(%rbp)
jmp 0x12da39
movq -0x8(%rbp), %rax
movq 0x218(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x12db28
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x14(%rbp), %esi
callq 0xeea20
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x56(%rax), %eax
cmpl $-0x1, %eax
jne 0x12da86
jmp 0x12db1a
movq -0x20(%rbp), %rax
movsbl 0x56(%rax), %eax
movq -0x8(%rbp), %rcx
movsbl 0x230(%rcx), %ecx
cmpl %ecx, %eax
jge 0x12da9f
jmp 0x12dabe
leaq 0x5f6f6(%rip), %rdi     # 0x18d19c
leaq 0x5e4f5(%rip), %rsi     # 0x18bfa2
movl $0xa60, %edx            # imm = 0xA60
leaq 0x5f6b5(%rip), %rcx     # 0x18d16e
callq 0xd180
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movsbq 0x56(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
movsbl %al, %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x20(%rbp), %rax
movsbl 0x56(%rax), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x20(%rbp), %rax
movb 0x64(%rax), %al
andb $0x3, %al
movzbl %al, %ecx
movq -0x28(%rbp), %rax
movb %cl, 0x8(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x12da50
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x220(%rax)
movq -0x8(%rbp), %rax
movsbl 0x230(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x228(%rax)
movq -0x8(%rbp), %rax
movb $0x1, 0x22c(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x24b(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)