// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/qsort_r.c
// Function: gt_qsort_r
void
gt_qsort_r(void *a, size_t n, size_t es, void *data, GtCompareWithData cmp)
{
  char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
  int swaptype, swap_cnt;
  long d, r;

  while (1)
  {
    SWAPINIT(a, es);
    swap_cnt = 0;
    if (n < 7) {
      for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
        for (pl = pm;
             pl > (char *)a && cmp(pl - es, pl, data) > 0;
             pl -= es)
          swap(pl, pl - es);
      return;
    }
    pm = (char *)a + (n / 2) * es;
    if (n > 7) {
      pl = a;
      pn = (char *)a + (n - 1) * es;
      if (n > 40) {
        d = (n / 8) * es;
        pl = med3(pl, pl + d, pl + 2 * d, cmp, data);
        pm = med3(pm - d, pm, pm + d, cmp, data);
        pn = med3(pn - 2 * d, pn - d, pn, cmp, data);
      }
      pm = med3(pl, pm, pn, cmp, data);
    }
    swap(a, pm);
    pa = pb = (char *)a + es;

    pc = pd = (char *)a + (n - 1) * es;
    for (;;) {
      while (pb <= pc && (r = cmp(pb, a, data)) <= 0) {
        if (r == 0) {
          swap_cnt = 1;
          swap(pa, pb);
          pa += es;
        }
        pb += es;
      }
      while (pb <= pc && (r = cmp(pc, a, data)) >= 0) {
        if (r == 0) {
          swap_cnt = 1;
          swap(pc, pd);
          pd -= es;
        }
        pc -= es;
      }
      if (pb > pc)
        break;
      swap(pb, pc);
      swap_cnt = 1;
      pb += es;
      pc -= es;
    }
    if (swap_cnt == 0) {  /* Switch to insertion sort */
      for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
        for (pl = pm;
             pl > (char *)a && cmp(pl - es, pl, data) > 0;
             pl -= es)
          swap(pl, pl - es);
      return;
    }

    pn = (char *)a + n * es;
    r = GT_MIN(pa - (char *)a, pb - pa);
    vecswap(a, pb - r, r);
    r = GT_MIN(pd - pc, pn - pd - es);
    vecswap(pb, pn - r, r);
    if ((r = pb - pa) > es)
      gt_qsort_r(a, r / es, es, data, cmp);
    if ((r = pd - pc) > es) {
      /* Iterate rather than recurse to save stack space */
      a = pn - r;
      n = r / es;
    }
    else
      break;
  }
/*            qsort(pn - r, r / es, es, cmp);*/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movq %rsi, %r15
movq %rdx, %rcx
movq %rdi, %r12
movq %rdx, %r9
negq %r9
xorl %edx, %edx
cmpq $0x8, %rcx
setne %dl
movl %r12d, %eax
orl %ecx, %eax
testb $0x7, %al
sete 0x7(%rsp)
movl $0x2, %eax
movl %edx, 0x6c(%rsp)
cmovel %edx, %eax
movl %eax, 0x1c(%rsp)
cmpq $0x7, %rsi
movq %rcx, 0x20(%rsp)
movq %r9, 0x38(%rsp)
jae 0x7bc03
movq %r12, %r14
jmp 0x7c26d
movslq %ecx, %rax
movq %rax, %rdx
shrq $0x3, %rdx
movq %rax, 0x80(%rsp)
incq %rax
movq %rax, 0x58(%rsp)
movq %rdx, 0x78(%rsp)
leaq 0x1(%rdx), %rax
movq %rax, 0x50(%rsp)
movq %r15, %r13
shrq %r13
imulq %rcx, %r13
addq %r12, %r13
cmpq $0x7, %r15
movq %r15, 0x30(%rsp)
je 0x7be71
leaq -0x1(%r15), %rax
imulq %rcx, %rax
addq %r12, %rax
cmpq $0x29, %r15
movq %rax, 0x28(%rsp)
jb 0x7bcc5
movq %r15, %rbp
shrq $0x3, %rbp
imulq %rcx, %rbp
leaq (%r12,%rbp), %r15
leaq (%r12,%rbp,2), %rax
movq %rax, 0x60(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq 0x10(%rsp), %rbx
callq *%rbx
movl %eax, 0x40(%rsp)
movq %r15, 0x48(%rsp)
movq %r15, %rdi
movq 0x60(%rsp), %r15
movq %r15, %rsi
movq %r14, %rdx
callq *%rbx
cmpl $0x0, 0x40(%rsp)
js 0x7bccd
testl %eax, %eax
jg 0x7bceb
movq %r12, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
cmovsq %r12, %r15
jmp 0x7bce6
movq %r12, %rbx
jmp 0x7be0b
testl %eax, %eax
js 0x7bceb
movq %r12, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
cmovnsq %r12, %r15
movq %r15, 0x48(%rsp)
movq %r13, %rdi
subq %rbp, %rdi
movq %r13, %r15
addq %rbp, %r15
movq %rdi, 0x70(%rsp)
movq %r13, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq 0x10(%rsp), %rbx
callq *%rbx
movl %eax, 0x60(%rsp)
movq %r13, %rdi
movq %r15, 0x40(%rsp)
movq %r15, %rsi
movq %r14, %rdx
callq *%rbx
cmpl $0x0, 0x60(%rsp)
js 0x7bd3f
testl %eax, %eax
jg 0x7bd62
movq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq 0x40(%rsp), %r13
movq %r13, %rsi
jmp 0x7bd53
testl %eax, %eax
js 0x7bd62
movq 0x70(%rsp), %r13
movq %r13, %rdi
movq 0x40(%rsp), %rbx
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
cmovsq %rbx, %r13
leaq (,%rbp,2), %rax
negq %rbp
movq 0x28(%rsp), %r15
movq %r15, %rdi
subq %rax, %rdi
addq %r15, %rbp
movq %rdi, 0x40(%rsp)
movq %rbp, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq 0x10(%rsp), %rbx
callq *%rbx
movl %eax, 0x60(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq *%rbx
cmpl $0x0, 0x60(%rsp)
js 0x7bdd2
testl %eax, %eax
movq 0x48(%rsp), %rbx
jg 0x7be01
movq 0x40(%rsp), %r14
movq %r14, %rdi
movq 0x28(%rsp), %r15
movq %r15, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
cmovsq %r14, %r15
jmp 0x7bdfa
testl %eax, %eax
movq 0x48(%rsp), %rbx
js 0x7be01
movq 0x40(%rsp), %r14
movq %r14, %rdi
movq 0x28(%rsp), %r15
movq %r15, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
cmovnsq %r14, %r15
movq %r15, 0x28(%rsp)
jmp 0x7be06
movq %rbp, 0x28(%rsp)
movq 0x30(%rsp), %r15
movq %rbx, 0x48(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq 0x10(%rsp), %rbx
callq *%rbx
movl %eax, %ebp
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movq %r14, %rdx
callq *%rbx
testl %ebp, %ebp
js 0x7be4e
testl %eax, %eax
jg 0x7be71
movq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq 0x28(%rsp), %r13
movq %r13, %rsi
jmp 0x7be62
testl %eax, %eax
js 0x7be71
movq 0x48(%rsp), %r13
movq %r13, %rdi
movq 0x28(%rsp), %rbx
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
cmovsq %rbx, %r13
cmpl $0x0, 0x1c(%rsp)
je 0x7bea7
testb $0x1, 0x7(%rsp)
je 0x7beb9
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
movq (%r12,%rcx), %rdx
movq (%r13,%rcx), %rsi
movq %rsi, (%r12,%rcx)
movq %rdx, (%r13,%rcx)
addq $0x8, %rcx
decq %rax
cmpq $0x1, %rax
ja 0x7be86
jmp 0x7bede
movq (%r12), %rax
movq (%r13), %rcx
movq %rcx, (%r12)
movq %rax, (%r13)
jmp 0x7bede
xorl %eax, %eax
movq 0x58(%rsp), %rcx
movb (%r12,%rax), %dl
movb (%r13,%rax), %sil
movb %sil, (%r12,%rax)
movb %dl, (%r13,%rax)
decq %rcx
incq %rax
cmpq $0x1, %rcx
jg 0x7bec0
movq 0x20(%rsp), %rax
leaq (%r12,%rax), %r14
decq %r15
imulq %rax, %r15
addq %r12, %r15
xorl %ebx, %ebx
movq %r15, %r13
movq %r14, %rbp
movq %r14, 0x28(%rsp)
cmpq %r13, %rbp
ja 0x7bf72
movq %rbp, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
jg 0x7bf72
je 0x7bf22
movq 0x20(%rsp), %rax
jmp 0x7c055
cmpl $0x0, 0x1c(%rsp)
je 0x7bf5f
testb $0x1, 0x7(%rsp)
je 0x7c024
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
movq (%r14,%rcx), %rdx
movq (%rbp,%rcx), %rsi
movq %rsi, (%r14,%rcx)
movq %rdx, (%rbp,%rcx)
addq $0x8, %rcx
decq %rax
cmpq $0x1, %rax
ja 0x7bf3b
jmp 0x7c048
movq (%r14), %rax
movq (%rbp), %rcx
movq %rcx, (%r14)
movq %rax, (%rbp)
jmp 0x7c048
cmpq %r13, %rbp
ja 0x7c0e9
movq %r13, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
testl %eax, %eax
js 0x7c05d
je 0x7bf9b
movq 0x38(%rsp), %r9
jmp 0x7c013
cmpl $0x0, 0x1c(%rsp)
movq 0x38(%rsp), %r9
je 0x7bfd6
testb $0x1, 0x7(%rsp)
je 0x7bfe6
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
movq (%r13,%rcx), %rdx
movq (%r15,%rcx), %rsi
movq %rsi, (%r13,%rcx)
movq %rdx, (%r15,%rcx)
addq $0x8, %rcx
decq %rax
cmpq $0x1, %rax
ja 0x7bfb5
jmp 0x7c00b
movq (%r13), %rax
movq (%r15), %rcx
movq %rcx, (%r13)
movq %rax, (%r15)
jmp 0x7c00b
xorl %eax, %eax
movq 0x58(%rsp), %rcx
movb (%r13,%rax), %dl
movb (%r15,%rax), %sil
movb %sil, (%r13,%rax)
movb %dl, (%r15,%rax)
decq %rcx
incq %rax
cmpq $0x1, %rcx
jg 0x7bfed
addq %r9, %r15
movl $0x1, %ebx
addq %r9, %r13
cmpq %r13, %rbp
jbe 0x7bf7b
jmp 0x7c0ee
xorl %eax, %eax
movq 0x58(%rsp), %rcx
movb (%r14,%rax), %dl
movb (%rbp,%rax), %sil
movb %sil, (%r14,%rax)
movb %dl, (%rbp,%rax)
decq %rcx
incq %rax
cmpq $0x1, %rcx
jg 0x7c02b
movq 0x20(%rsp), %rax
addq %rax, %r14
movl $0x1, %ebx
addq %rax, %rbp
jmp 0x7befe
cmpl $0x0, 0x1c(%rsp)
je 0x7c09a
testb $0x1, 0x7(%rsp)
movq 0x38(%rsp), %rdi
je 0x7c0b1
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
movq (%rbp,%rcx), %rdx
movq (%r13,%rcx), %rsi
movq %rsi, (%rbp,%rcx)
movq %rdx, (%r13,%rcx)
addq $0x8, %rcx
decq %rax
cmpq $0x1, %rax
ja 0x7c077
jmp 0x7c0d7
movq (%rbp), %rax
movq (%r13), %rcx
movq %rcx, (%rbp)
movq %rax, (%r13)
movq 0x38(%rsp), %rdi
jmp 0x7c0d7
xorl %eax, %eax
movq 0x58(%rsp), %rcx
movb (%rbp,%rax), %dl
movb (%r13,%rax), %sil
movb %sil, (%rbp,%rax)
movb %dl, (%r13,%rax)
decq %rcx
incq %rax
cmpq $0x1, %rcx
jg 0x7c0b8
addq 0x20(%rsp), %rbp
addq %rdi, %r13
movl $0x1, %ebx
jmp 0x7befe
movq 0x38(%rsp), %r9
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
imulq %rax, %rcx
leaq (%r12,%rcx), %rdx
movq %rdx, 0x30(%rsp)
testl %ebx, %ebx
je 0x7c36c
movq %rbp, %rax
subq %r14, %rax
subq %r12, %r14
cmpq %rax, %r14
cmovgeq %rax, %r14
testq %r14, %r14
jle 0x7c17b
movq %rbp, %rcx
subq %r14, %rcx
movslq %r14d, %rdx
testb $0x1, 0x7(%rsp)
je 0x7c15a
shrq $0x3, %rdx
incq %rdx
xorl %esi, %esi
movq (%r12,%rsi), %rdi
movq (%rcx,%rsi), %r8
movq %r8, (%r12,%rsi)
movq %rdi, (%rcx,%rsi)
addq $0x8, %rsi
decq %rdx
cmpq $0x1, %rdx
ja 0x7c13b
jmp 0x7c17b
incq %rdx
xorl %esi, %esi
movb (%r12,%rsi), %dil
movb (%rcx,%rsi), %r8b
movb %r8b, (%r12,%rsi)
movb %dil, (%rcx,%rsi)
decq %rdx
incq %rsi
cmpq $0x1, %rdx
jg 0x7c15f
movq %r15, %rbx
subq %r13, %rbx
addq 0x20(%rsp), %r15
movq 0x30(%rsp), %rcx
movq %rcx, %rdx
subq %r15, %rdx
cmpq %rdx, %rbx
cmovbq %rbx, %rdx
testq %rdx, %rdx
jle 0x7c1f7
subq %rdx, %rcx
movslq %edx, %rdx
testb $0x1, 0x7(%rsp)
je 0x7c1d4
shrq $0x3, %rdx
incq %rdx
xorl %esi, %esi
movq (%rbp,%rsi), %rdi
movq (%rcx,%rsi), %r8
movq %r8, (%rbp,%rsi)
movq %rdi, (%rcx,%rsi)
addq $0x8, %rsi
decq %rdx
cmpq $0x1, %rdx
ja 0x7c1b3
jmp 0x7c1f7
incq %rdx
xorl %esi, %esi
movb (%rbp,%rsi), %dil
movb (%rcx,%rsi), %r8b
movb %r8b, (%rbp,%rsi)
movb %dil, (%rcx,%rsi)
decq %rdx
incq %rsi
cmpq $0x1, %rdx
jg 0x7c1d9
movq 0x20(%rsp), %rcx
cmpq %rcx, %rax
jbe 0x7c22a
xorl %edx, %edx
divq %rcx
movq %r12, %rdi
movq %rax, %rsi
movq 0x20(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
callq 0x7bb9c
movq 0x38(%rsp), %r9
movq 0x20(%rsp), %rcx
cmpq %rcx, %rbx
jbe 0x7c451
movq 0x30(%rsp), %r14
subq %rbx, %r14
movq %rbx, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r15
movl %ecx, %eax
orl %r14d, %eax
testb $0x7, %al
movl $0x2, %eax
cmovel 0x6c(%rsp), %eax
movl %eax, 0x1c(%rsp)
sete 0x7(%rsp)
movq %r14, %r12
cmpq $0x7, %r15
jae 0x7bc2b
imulq %rcx, %r15
cmpq %rcx, %r15
jle 0x7c451
movq %r14, %r13
addq %r14, %r15
leaq (%r14,%rcx), %rbx
movslq %ecx, %rax
movq %rax, %rcx
shrq $0x3, %rcx
incq %rax
movq %rax, 0x58(%rsp)
incq %rcx
movq %rcx, 0x50(%rsp)
movq %r15, 0x30(%rsp)
cmpq %r14, %rbx
jbe 0x7c34e
movq %r13, %rbp
movq %rbx, %r15
movq %r15, %r12
addq %r9, %r15
movq %r15, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
movq 0x38(%rsp), %r9
testl %eax, %eax
jle 0x7c34e
cmpl $0x0, 0x1c(%rsp)
je 0x7c30e
cmpb $0x0, 0x7(%rsp)
je 0x7c31e
movq 0x20(%rsp), %rax
addq %rbp, %rax
movq 0x50(%rsp), %rcx
xorl %edx, %edx
movq (%rax,%rdx), %rsi
movq (%rbp,%rdx), %rdi
movq %rdi, (%rax,%rdx)
movq %rsi, (%rbp,%rdx)
addq $0x8, %rdx
decq %rcx
cmpq $0x1, %rcx
ja 0x7c2ed
jmp 0x7c342
movq (%r12), %rax
movq (%r15), %rcx
movq %rcx, (%r12)
movq %rax, (%r15)
jmp 0x7c342
xorl %eax, %eax
movq 0x58(%rsp), %rcx
movb (%r12,%rax), %dl
movb (%rbp,%rax), %sil
movb %sil, (%r12,%rax)
movb %dl, (%rbp,%rax)
decq %rcx
incq %rax
cmpq $0x1, %rcx
jg 0x7c325
addq %r9, %rbp
cmpq %r14, %r15
ja 0x7c2b2
movq 0x20(%rsp), %rax
addq %rax, %rbx
addq %rax, %r13
movq 0x30(%rsp), %r15
cmpq %r15, %rbx
jb 0x7c2a3
jmp 0x7c451
cmpq %rax, %rcx
movq 0x28(%rsp), %rbp
jle 0x7c451
incq 0x80(%rsp)
incq 0x78(%rsp)
movq %r12, %rbx
cmpq %r12, %rbp
jbe 0x7c43b
movq %rbx, %r14
movq %rbp, %r15
movq %r15, %r13
addq %r9, %r15
movq %r15, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
callq *0x10(%rsp)
movq 0x38(%rsp), %r9
testl %eax, %eax
jle 0x7c43b
cmpl $0x0, 0x1c(%rsp)
je 0x7c3f7
testb $0x1, 0x7(%rsp)
je 0x7c407
movq 0x20(%rsp), %rax
addq %r14, %rax
movq 0x78(%rsp), %rcx
xorl %edx, %edx
movq (%rax,%rdx), %rsi
movq (%r14,%rdx), %rdi
movq %rdi, (%rax,%rdx)
movq %rsi, (%r14,%rdx)
addq $0x8, %rdx
decq %rcx
cmpq $0x1, %rcx
ja 0x7c3d8
jmp 0x7c42f
movq (%r13), %rax
movq (%r15), %rcx
movq %rcx, (%r13)
movq %rax, (%r15)
jmp 0x7c42f
xorl %eax, %eax
movq 0x80(%rsp), %rcx
movb (%r13,%rax), %dl
movb (%r14,%rax), %sil
movb %sil, (%r13,%rax)
movb %dl, (%r14,%rax)
decq %rcx
incq %rax
cmpq $0x1, %rcx
jg 0x7c411
addq %r9, %r14
cmpq %r12, %r15
ja 0x7c399
movq 0x20(%rsp), %rax
addq %rax, %rbp
addq %rax, %rbx
cmpq 0x30(%rsp), %rbp
jb 0x7c38a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop