// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0xc(%rbp), %eax
sarl %eax
movl %eax, -0x3c(%rbp)
movl -0xc(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpl $0x2, -0x3c(%rbp)
jle 0xe86f
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xe810
jmp 0xe8ba
cmpl $0x2, -0x3c(%rbp)
jne 0xe8b8
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x10(%rcx), %eax
jbe 0xe8b8
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe8ba
cmpl $0x2, -0x40(%rbp)
jle 0xe8d6
movq -0x38(%rbp), %rdi
movl -0x40(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xe810
jmp 0xe921
cmpl $0x2, -0x40(%rbp)
jne 0xe91f
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x10(%rcx), %eax
jbe 0xe91f
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe921
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x3c(%rbp)
movb %al, -0x41(%rbp)
jle 0xe941
cmpl $0x0, -0x40(%rbp)
setg %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0xe94a
jmp 0xe9c1
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
ja 0xe98f
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x30(%rbp)
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq %rcx, (%rax)
jmp 0xe9bc
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x38(%rbp)
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq %rcx, (%rax)
jmp 0xe92c
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x40(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
shlq $0x3, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0xe9f4
jmp 0xea13
leaq 0xc9272(%rip), %rdi     # 0xd7c6d
leaq 0xc9180(%rip), %rsi     # 0xd7b82
movl $0x434, %edx            # imm = 0x434
leaq 0xc927d(%rip), %rcx     # 0xd7c8b
callq 0x6450
cmpl $0x0, -0x3c(%rbp)
jle 0xea2e
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x3c(%rbp), %rdx
shlq $0x3, %rdx
callq 0x6570
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0xc(%rbp), %eax
subl -0x40(%rbp), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x6570
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)