// File: /workspace/github_c_makefile_star2_O2/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), %eax
testl %eax, %eax
je 0x9d53
pushq $0x1
popq %rdx
movq %rbx, %rdi
cmpl $0x1, %eax
jne 0x9d65
movq %r15, %rsi
jmp 0x9d5b
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x9f08
movq %rax, %r14
jmp 0x9d81
movq %r15, %rsi
callq 0x9f08
movq %rax, %r14
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x9f08
movq %rax, 0x30(%r14)
movq %r14, %r15
testq %r15, %r15
je 0x9ef4
movl 0x8(%rbx), %r13d
movl 0xc(%rbx), %ebp
movq %r13, %rdi
imulq %rbp, %rdi
shlq $0x2, %rdi
callq 0x1130
movq %rax, %r12
cmpl $0x1, 0x8(%r15)
jne 0x9dc8
imull %ebp, %r13d
xorl %eax, %eax
cmpq %rax, %r13
je 0x9dff
movq (%rbx), %rcx
movl (%rcx,%rax,4), %ecx
movl %ecx, (%r12,%rax,4)
incq %rax
jmp 0x9db4
leaq (,%rbp,4), %rax
movq %r12, %rcx
xorl %edx, %edx
cmpq %r13, %rdx
je 0x9dff
movq %rdx, %rsi
xorl %edi, %edi
cmpq %rdi, %rbp
je 0x9df7
movq (%rbx), %r8
movl (%r8,%rsi,4), %r8d
movl %r8d, (%rcx,%rdi,4)
incq %rdi
addq %r13, %rsi
jmp 0x9ddf
incq %rdx
addq %rax, %rcx
jmp 0x9dd5
xorl %ebp, %ebp
cmpl (%r15), %ebp
jge 0x9e20
movslq 0x4(%r15), %rax
movslq %ebp, %rcx
imulq %rax, %rcx
leaq (%r12,%rcx,4), %rdi
movq %r15, %rsi
callq *0x10(%r15)
incl %ebp
jmp 0x9e01
cmpl $0x1, 0x8(%r15)
jne 0x9e6c
xorl %eax, %eax
movl 0xc(%rbx), %ecx
imull 0x8(%rbx), %ecx
cmpq %rcx, %rax
jae 0x9edc
movb (%r12,%rax,4), %cl
movq (%rbx), %rdx
movb %cl, (%rdx,%rax,4)
movb 0x1(%r12,%rax,4), %cl
movq (%rbx), %rdx
movb %cl, 0x1(%rdx,%rax,4)
movb 0x2(%r12,%rax,4), %cl
movq (%rbx), %rdx
movb %cl, 0x2(%rdx,%rax,4)
movb 0x3(%r12,%rax,4), %cl
movq (%rbx), %rdx
movb %cl, 0x3(%rdx,%rax,4)
incq %rax
jmp 0x9e29
addq $0x3, %r12
xorl %eax, %eax
xorl %ecx, %ecx
movl 0x8(%rbx), %edx
cmpq %rdx, %rcx
jae 0x9edc
movq %r12, %rdx
xorl %esi, %esi
movl 0xc(%rbx), %edi
cmpq %rdi, %rsi
jae 0x9ed3
movl 0x8(%rbx), %r8d
imulq %rsi, %r8
addq %rcx, %r8
imulq %rax, %rdi
movb -0x3(%rdx,%rdi), %r9b
movq (%rbx), %r10
movb %r9b, (%r10,%r8,4)
movb -0x2(%rdx,%rdi), %r9b
movq (%rbx), %r10
movb %r9b, 0x1(%r10,%r8,4)
movb -0x1(%rdx,%rdi), %r9b
movq (%rbx), %r10
movb %r9b, 0x2(%r10,%r8,4)
movb (%rdx,%rdi), %dil
movq (%rbx), %r9
movb %dil, 0x3(%r9,%r8,4)
incq %rsi
addq $0x4, %rdx
jmp 0x9e81
incq %rcx
addq $0x4, %rax
jmp 0x9e74
movq 0x30(%r15), %r15
jmp 0x9d84
movq 0x30(%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %r14, %r14
jne 0x9ee5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq