// File: /workspace/github_c_makefile_star2_O2/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
movq %rcx, %r15
movl %esi, %ebp
movq %rdi, %r9
movl %esi, %r12d
sarl %r12d
movl %esi, %r14d
subl %r12d, %r14d
movslq %r12d, %r13
cmpl $0x3, %r13d
movq %rdi, (%rsp)
jl 0xbc03
movq %r9, %rdi
movl %r12d, %esi
movq %rdx, %rbx
movq %r15, %rcx
callq 0xbbc0
movq (%rsp), %r9
jmp 0xbc2b
movq %rdx, %rbx
cmpl $0x2, %r12d
jne 0xbc2b
movq (%r9), %rcx
movq 0x8(%r9), %rax
movl 0x10(%rcx), %ecx
cmpl 0x10(%rax), %ecx
jbe 0xbc2b
movq %rax, (%r15)
movq (%r9), %rax
movq %rax, 0x8(%r9)
movq (%r15), %rax
movq %rax, (%r9)
leaq (%r9,%r13,8), %r13
cmpl $0x3, %r14d
jl 0xbc4c
movq %r13, %rdi
movl %r14d, %esi
movq %rbx, %rdx
movq %r15, %rcx
callq 0xbbc0
movq (%rsp), %r9
jmp 0xbc74
cmpl $0x2, %r14d
jne 0xbc74
movq (%r13), %rcx
movq 0x8(%r13), %rax
movl 0x10(%rcx), %ecx
cmpl 0x10(%rax), %ecx
jbe 0xbc74
movq %rax, (%r15)
movq (%r13), %rax
movq %rax, 0x8(%r13)
movq (%r15), %rax
movq %rax, (%r13)
movq (%rbx), %rdi
movq %r9, %rsi
testl %r12d, %r12d
jle 0xbcaf
testl %r14d, %r14d
jle 0xbcaf
movq (%rsi), %rax
movl 0x10(%rax), %edx
movq (%r13), %rcx
cmpl 0x10(%rcx), %edx
jbe 0xbc9f
decl %r14d
addq $0x8, %r13
movq %rcx, %rax
jmp 0xbca6
decl %r12d
addq $0x8, %rsi
movq %rax, (%rdi)
addq $0x8, %rdi
jmp 0xbc7a
movslq %r12d, %rdx
movslq %r14d, %rax
shlq $0x3, %rax
leaq (%rax,%rdx,8), %rcx
addq %rdi, %rcx
movq (%rbx), %rax
movslq %ebp, %r8
leaq (%rax,%r8,8), %r8
cmpq %r8, %rcx
jne 0xbd07
testl %r12d, %r12d
jle 0xbce4
shlq $0x3, %rdx
callq 0x6570
movq (%rsp), %r9
movq (%rbx), %rax
subl %r14d, %ebp
movslq %ebp, %rdx
shlq $0x3, %rdx
movq %r9, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6570
leaq 0x70f8d(%rip), %rdi     # 0x7cc9b
leaq 0x70e9b(%rip), %rsi     # 0x7cbb0
leaq 0x70f9d(%rip), %rcx     # 0x7ccb9
movl $0x434, %edx            # imm = 0x434
callq 0x6460