// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableSetColumnSortDirection(int, int, bool)
void ImGui::TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs)
{
    ImGuiContext& g = *GImGui;
    ImGuiTable* table = g.CurrentTable;

    if (!(table->Flags & ImGuiTableFlags_SortMulti))
        append_to_sort_specs = false;
    if (!(table->Flags & ImGuiTableFlags_SortTristate))
        IM_ASSERT(sort_direction != ImGuiSortDirection_None);

    ImGuiTableColumnIdx sort_order_max = 0;
    if (append_to_sort_specs)
        for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
            sort_order_max = ImMax(sort_order_max, table->Columns[other_column_n].SortOrder);

    ImGuiTableColumn* column = &table->Columns[column_n];
    column->SortDirection = (ImU8)sort_direction;
    if (column->SortDirection == ImGuiSortDirection_None)
        column->SortOrder = -1;
    else if (column->SortOrder == -1 || !append_to_sort_specs)
        column->SortOrder = append_to_sort_specs ? sort_order_max + 1 : 0;

    for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
    {
        ImGuiTableColumn* other_column = &table->Columns[other_column_n];
        if (other_column != column && !append_to_sort_specs)
            other_column->SortOrder = -1;
        TableFixColumnSortDirection(table, other_column);
    }
    table->IsSettingsDirty = true;
    table->IsSortSpecsDirty = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %dl, %al
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
leaq 0xe0ab4(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x20a8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x4000000, %eax        # imm = 0x4000000
cmpl $0x0, %eax
jne 0x1324b7
movb $0x0, -0x9(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x8000000, %eax        # imm = 0x8000000
cmpl $0x0, %eax
jne 0x1324f1
cmpl $0x0, -0x8(%rbp)
je 0x1324d0
jmp 0x1324ef
leaq 0x5ab5b(%rip), %rdi     # 0x18d032
leaq 0x59ac4(%rip), %rsi     # 0x18bfa2
movl $0x9f8, %edx            # imm = 0x9F8
leaq 0x5ab72(%rip), %rcx     # 0x18d05c
callq 0xd180
jmp 0x1324f1
movb $0x0, -0x21(%rbp)
testb $0x1, -0x9(%rbp)
je 0x132543
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x132541
movb -0x21(%rbp), %al
movb %al, -0x41(%rbp)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
movl -0x28(%rbp), %esi
callq 0xeea20
movb -0x41(%rbp), %cl
movsbl %cl, %edi
movsbl 0x56(%rax), %esi
callq 0x132640
movb %al, -0x21(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x132502
jmp 0x132543
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
movl -0x4(%rbp), %esi
callq 0xeea20
movq %rax, -0x30(%rbp)
movl -0x8(%rbp), %eax
movb %al, %dl
movq -0x30(%rbp), %rax
movb 0x64(%rax), %cl
andb $0x3, %dl
andb $-0x4, %cl
orb %dl, %cl
movb %cl, 0x64(%rax)
movq -0x30(%rbp), %rax
movb 0x64(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x132589
movq -0x30(%rbp), %rax
movb $-0x1, 0x56(%rax)
jmp 0x1325c3
movq -0x30(%rbp), %rax
movsbl 0x56(%rax), %eax
cmpl $-0x1, %eax
je 0x13259c
testb $0x1, -0x9(%rbp)
jne 0x1325c1
testb $0x1, -0x9(%rbp)
je 0x1325ae
movsbl -0x21(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1325b5
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x1325b5
movl -0x48(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x56(%rax)
jmp 0x1325c3
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x13261a
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
movl -0x34(%rbp), %esi
callq 0xeea20
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x132602
testb $0x1, -0x9(%rbp)
jne 0x132602
movq -0x40(%rbp), %rax
movb $-0x1, 0x56(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1322a0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1325ca
movq -0x20(%rbp), %rax
movb $0x1, 0x24f(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x24b(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)