// File: /workspace/github_c_makefile_star2_O3/pje[P]pixelsort/sorting.c
// Function: sort
void sort(struct image * img, const context_t * ctx) {
    sort_plan_t *plan_steps;

    if(ROW == ctx->orientation) {
        plan_steps = create_sort_plan(img, ctx, ROW);
    } else if(COLUMN == ctx->orientation) {
        plan_steps = create_sort_plan(img, ctx, COLUMN);
    } else {
        plan_steps = create_sort_plan(img, ctx, ROW);
        plan_steps->next_step_ptr = create_sort_plan(img, ctx, COLUMN);
    }

    for(const sort_plan_t * step = plan_steps; NULL != step; step = step->next_step_ptr) {
        pixel_t * pixels = create_pixel_list(img, step);
        do_sort(pixels, step);
        sync_pixels(img, step, pixels);
    }

    destroy_sort_plan(plan_steps);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movl (%rsi), %edx
cmpl $0x2, %edx
jae 0xcd9d
movq %r15, %rsi
callq 0xcf82
movq %rax, %r14
testq %rax, %rax
jne 0xcdbe
jmp 0xcf73
movq %r15, %rsi
movl $0x1, %edx
callq 0xcf82
movq %rax, %r14
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xcf82
movq %rax, 0x30(%r14)
movl 0x8(%rbx), %eax
movq %r14, (%rsp)
movq %r14, %r15
movl 0x8(%r15), %r14d
movl %eax, %ebp
movl 0xc(%rbx), %r13d
movq %rbp, %rdi
imulq %r13, %rdi
shlq $0x2, %rdi
callq 0x1140
movq %rax, %r12
cmpl $0x1, %r14d
jne 0xce0a
imull %ebp, %r13d
testl %r13d, %r13d
je 0xce55
movq (%rbx), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0xcdf9
jmp 0xce55
testq %rbp, %rbp
je 0xce55
leaq (,%r13,4), %rax
leaq (,%rbp,4), %rcx
xorl %edx, %edx
movq %r12, %rsi
xorl %edi, %edi
testq %r13, %r13
je 0xce46
movq (%rbx), %r8
addq %rdx, %r8
xorl %r9d, %r9d
movl (%r8), %r10d
movl %r10d, (%rsi,%r9,4)
incq %r9
addq %rcx, %r8
cmpq %r9, %r13
jne 0xce34
incq %rdi
addq %rax, %rsi
addq $0x4, %rdx
cmpq %rbp, %rdi
jne 0xce26
cmpl $0x0, (%r15)
jle 0xce7c
xorl %r13d, %r13d
movslq 0x4(%r15), %rax
movslq %r13d, %r13
imulq %r13, %rax
leaq (%r12,%rax,4), %rdi
movq %r15, %rsi
callq *0x10(%r15)
incl %r13d
cmpl (%r15), %r13d
jl 0xce5e
cmpl $0x1, 0x8(%r15)
movl 0x8(%rbx), %eax
jne 0xced7
movl 0xc(%rbx), %ecx
imull %eax, %ecx
testl %ecx, %ecx
je 0xcf51
xorl %ecx, %ecx
movb (%r12,%rcx,4), %al
movq (%rbx), %rdx
movb %al, (%rdx,%rcx,4)
movb 0x1(%r12,%rcx,4), %al
movq (%rbx), %rdx
movb %al, 0x1(%rdx,%rcx,4)
movb 0x2(%r12,%rcx,4), %al
movq (%rbx), %rdx
movb %al, 0x2(%rdx,%rcx,4)
movb 0x3(%r12,%rcx,4), %al
movq (%rbx), %rdx
movb %al, 0x3(%rdx,%rcx,4)
incq %rcx
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %edx
imull %eax, %edx
cmpq %rdx, %rcx
jb 0xce96
jmp 0xcf51
testl %eax, %eax
je 0xcf4f
movl 0xc(%rbx), %esi
xorl %ecx, %ecx
xorl %edx, %edx
testl %esi, %esi
je 0xcf3d
movl %esi, %esi
xorl %eax, %eax
movl 0x8(%rbx), %edi
imulq %rax, %rdi
addq %rdx, %rdi
imulq %rcx, %rsi
addq %r12, %rsi
movb (%rsi,%rax,4), %r8b
movq (%rbx), %r9
movb %r8b, (%r9,%rdi,4)
movb 0x1(%rsi,%rax,4), %r8b
movq (%rbx), %r9
movb %r8b, 0x1(%r9,%rdi,4)
movb 0x2(%rsi,%rax,4), %r8b
movq (%rbx), %r9
movb %r8b, 0x2(%r9,%rdi,4)
movb 0x3(%rsi,%rax,4), %sil
movq (%rbx), %r8
movb %sil, 0x3(%r8,%rdi,4)
incq %rax
movl 0xc(%rbx), %esi
cmpq %rsi, %rax
jb 0xceea
movl 0x8(%rbx), %eax
jmp 0xcf3f
xorl %esi, %esi
incq %rdx
movl %eax, %edi
addq $0x4, %rcx
cmpq %rdi, %rdx
jb 0xcee2
jmp 0xcf51
xorl %eax, %eax
movq 0x30(%r15), %r15
testq %r15, %r15
jne 0xcdc8
movq (%rsp), %rdi
movq 0x30(%rdi), %rbx
callq 0x1030
movq %rbx, %rdi
testq %rbx, %rbx
jne 0xcf62
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq