// File: /workspace/github_c_makefile_star2_O1/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 0xcc2e
cmpl $0x1, %eax
jne 0xcc3d
movq %r15, %rsi
movl $0x1, %edx
jmp 0xcc33
movq %r15, %rsi
xorl %edx, %edx
callq 0xce18
movq %rax, %r14
jmp 0xcc5e
movq %r15, %rsi
movl $0x1, %edx
callq 0xce18
movq %rax, %r14
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xce18
movq %rax, 0x30(%r14)
testq %r14, %r14
je 0xce09
movq %r14, %r15
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 0xccaa
imull %ebp, %r13d
testl %r13d, %r13d
je 0xccfc
movq (%rbx), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0xcc99
jmp 0xccfc
testq %r13, %r13
je 0xccfc
leaq 0x3(%r12), %rax
leaq (,%rbp,4), %rcx
leaq (,%r13,4), %rdx
movl $0x3, %esi
xorl %edi, %edi
testq %rbp, %rbp
je 0xcced
movq (%rbx), %r8
addq %rsi, %r8
xorl %r9d, %r9d
movl -0x3(%r8), %r10d
movl %r10d, -0x3(%rax,%r9,4)
incq %r9
addq %rdx, %r8
cmpq %r9, %rbp
jne 0xccd9
incq %rdi
addq %rcx, %rax
addq $0x4, %rsi
cmpq %r13, %rdi
jne 0xcccb
cmpl $0x0, (%r15)
jle 0xcd23
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 0xcd05
cmpl $0x1, 0x8(%r15)
movl 0x8(%rbx), %eax
jne 0xcd7a
imull 0xc(%rbx), %eax
testl %eax, %eax
je 0xcde8
xorl %eax, %eax
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
movl 0xc(%rbx), %ecx
imull 0x8(%rbx), %ecx
cmpq %rcx, %rax
jb 0xcd3b
jmp 0xcde8
testl %eax, %eax
je 0xcde8
xorl %eax, %eax
xorl %ecx, %ecx
movl 0xc(%rbx), %edx
testq %rdx, %rdx
je 0xcdd9
xorl %esi, %esi
movl 0x8(%rbx), %edi
imulq %rsi, %rdi
addq %rcx, %rdi
imulq %rax, %rdx
addq %r12, %rdx
movb (%rdx,%rsi,4), %r8b
movq (%rbx), %r9
movb %r8b, (%r9,%rdi,4)
movb 0x1(%rdx,%rsi,4), %r8b
movq (%rbx), %r9
movb %r8b, 0x1(%r9,%rdi,4)
movb 0x2(%rdx,%rsi,4), %r8b
movq (%rbx), %r9
movb %r8b, 0x2(%r9,%rdi,4)
movb 0x3(%rdx,%rsi,4), %dl
movq (%rbx), %r8
movb %dl, 0x3(%r8,%rdi,4)
incq %rsi
movl 0xc(%rbx), %edx
cmpq %rdx, %rsi
jb 0xcd8c
incq %rcx
movl 0x8(%rbx), %edx
addq $0x4, %rax
cmpq %rdx, %rcx
jb 0xcd82
movq 0x30(%r15), %r15
testq %r15, %r15
jne 0xcc6a
movq 0x30(%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0xcdf5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq