// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/jkOwnLib/genoFind.c
// Function: gfHitSort2
static void gfHitSort2(struct gfHit **ptArray, int n,
                       struct gfHit ***nosTemp, struct gfHit **nosSwap)
/* This is a fast recursive sort that uses a temporary
 * buffer (nosTemp) that has to be as big as the array
 * that is being sorted. */
{
    struct gfHit **tmp, **pt1, **pt2;
    int n1, n2;

    /* Divide area to sort in two. */
    n1 = (n>>1);
    n2 = n - n1;
    pt1 = ptArray;
    pt2 =  ptArray + n1;

    /* Sort each area separately.  Handle small case (2 or less elements)
     * here.  Otherwise recurse to sort. */
    if (n1 > 2)
        gfHitSort2(pt1, n1, nosTemp, nosSwap);
    else if (n1 == 2 && pt1[0]->diagonal > pt1[1]->diagonal)
    {
        *nosSwap = pt1[1];
        pt1[1]   = pt1[0];
        pt1[0]   = *nosSwap;
    }
    if (n2 > 2)
        gfHitSort2(pt2, n2, nosTemp, nosSwap);
    else if (n2 == 2 && pt2[0]->diagonal > pt2[1]->diagonal)
    {
        *nosSwap = pt2[1];
        pt2[1]   = pt2[0];
        pt2[0]   = *nosSwap;
    }

    /* At this point both halves are internally sorted.
     * Do a merge-sort between two halves copying to temp
     * buffer.  Then copy back sorted result to main buffer. */
    tmp = *nosTemp;
    while (n1 > 0 && n2 > 0)
    {
        if ((*pt1)->diagonal <= (*pt2)->diagonal)
        {
            --n1;
            *tmp++ = *pt1++;
        }
        else
        {
            --n2;
            *tmp++ = *pt2++;
        }
    }
    /* One or both sides are now fully merged. */
    assert(tmp + n1 + n2 == *nosTemp + n);

    /* If some of first side left to merge copy it to end of temp buf. */
    if (n1 > 0)
        memcpy(tmp, pt1, n1 * sizeof(*tmp));

    /* If some of second side left to merge, we finesse it here:
     * simply refrain from copying over it as we copy back temp buf. */
    memcpy(ptArray, *nosTemp, (n - n2) * sizeof(*ptArray));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %r14
movl %esi, %r12d
sarl %r12d
movl %esi, %r15d
subl %r12d, %r15d
movslq %r12d, %r13
cmpl $0x3, %r13d
movq %rdx, (%rsp)
jl 0xdcdf
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %ebx
movq %rcx, %rbp
callq 0xdc9f
movq %rbp, %rcx
movl %ebx, %ebp
jmp 0xdd04
cmpl $0x2, %r12d
jne 0xdd04
movq (%r14), %rdx
movq 0x8(%r14), %rax
movl 0x10(%rdx), %edx
cmpl 0x10(%rax), %edx
jbe 0xdd04
movq %rax, (%rcx)
movq (%r14), %rax
movq %rax, 0x8(%r14)
movq (%rcx), %rax
movq %rax, (%r14)
leaq (%r14,%r13,8), %r13
cmpl $0x3, %r15d
jl 0xdd22
movq %r13, %rdi
movl %r15d, %esi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0xdc9f
jmp 0xdd4e
cmpl $0x2, %r15d
movq (%rsp), %rbx
jne 0xdd4e
movq (%r13), %rdx
movq 0x8(%r13), %rax
movl 0x10(%rdx), %edx
cmpl 0x10(%rax), %edx
jbe 0xdd4e
movq %rax, (%rcx)
movq (%r13), %rax
movq %rax, 0x8(%r13)
movq (%rcx), %rax
movq %rax, (%r13)
movq (%rbx), %rdi
testl %r12d, %r12d
setg %al
testl %r15d, %r15d
setg %cl
andb %al, %cl
movq %r14, %rsi
cmpb $0x1, %cl
jne 0xdd9d
movq (%rsi), %rax
movl 0x10(%rax), %edx
movq (%r13), %rcx
cmpl 0x10(%rcx), %edx
jbe 0xdd82
decl %r15d
addq $0x8, %r13
movq %rcx, %rax
jmp 0xdd89
decl %r12d
addq $0x8, %rsi
movq %rax, (%rdi)
addq $0x8, %rdi
testl %r12d, %r12d
setg %al
jle 0xdd9d
testl %r15d, %r15d
jg 0xdd67
movslq %r12d, %rdx
leaq (%rdi,%rdx,8), %rcx
movslq %r15d, %r8
leaq (%rcx,%r8,8), %rcx
movslq %ebp, %r8
shlq $0x3, %r8
addq (%rbx), %r8
cmpq %r8, %rcx
jne 0xddea
testb %al, %al
je 0xddc7
shlq $0x3, %rdx
callq 0x6570
movq (%rbx), %rsi
subl %r15d, %ebp
movslq %ebp, %rdx
shlq $0x3, %rdx
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6570
leaq 0x7feca(%rip), %rdi     # 0x8dcbb
leaq 0x7fdd8(%rip), %rsi     # 0x8dbd0
leaq 0x7feda(%rip), %rcx     # 0x8dcd9
movl $0x434, %edx            # imm = 0x434
callq 0x6460