// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/sfx-copysort.c
// Function: gt_copysort_derivesorting
void gt_copysort_derivesorting(const GtBucketspec2 *bucketspec2,
                               GtSuffixsortspace *suffixsortspace,
                               GtLogger *logger)
{
  GtUword hardwork = 0, *targetoffset;
  unsigned int idx, idxsource, source, second;

  targetoffset = gt_malloc(sizeof (*targetoffset) * bucketspec2->numofchars);
  for (idxsource = 0; idxsource<bucketspec2->numofchars; idxsource++)
  {
    source = bucketspec2->order[idxsource];
    for (second = 0; second < bucketspec2->numofchars; second++)
    {
      if (!bucketspec2->subbuckettab[source][second].sorted && source != second)
      {
        gt_assert(bucketspec2->subbuckettab[source][second].hardworktodo);
        gt_logger_log(logger,"hard work for %u %u",source,second);
        hardwork += getendidx(bucketspec2,source,second) -
                    getstartidx(bucketspec2,source,second);
        bucketspec2->subbuckettab[source][second].sorted = true;
      } else
      {
        gt_assert(!bucketspec2->subbuckettab[source][second].hardworktodo);
      }
    }
    if (getstartidx(bucketspec2,source,0) <
        getstartidx(bucketspec2,source,source))
    {
      for (idx = 0; idx < bucketspec2->numofchars; idx++)
      {
        targetoffset[idx] = getstartidx(bucketspec2,idx,source);
      }
      gt_copysort_forwardderive(bucketspec2,
                    suffixsortspace,
                    targetoffset,
                    source,
                    getstartidx(bucketspec2,source,0));
    }
    if (getendidx(bucketspec2,source,source) <
        getendidx(bucketspec2,source,bucketspec2->numofchars))
    {
      for (idx = 0; idx < bucketspec2->numofchars; idx++)
      {
        /* do not need to assert that getendidx(idx,source) > 0, as later the
           value stored in targetoffset is incremented */
        targetoffset[idx] = getendidx(bucketspec2,idx,source) - 1;
      }
      gt_assert(getendidx(bucketspec2,source,bucketspec2->numofchars) > 0);
      gt_copysort_backwardderive(bucketspec2,
                                 suffixsortspace,
                                 targetoffset,
                                 source,
                                 getendidx(bucketspec2,source,
                                           bucketspec2->numofchars) - 1);
    }
    for (idx = 0; idx < bucketspec2->numofchars; idx++)
    {
      bucketspec2->subbuckettab[idx][source].sorted = true;
    }
    bucketspec2->superbuckettab[source].sorted = true;
  }
  gt_free(targetoffset);
  gt_logger_log(logger,"hardwork = "GT_WU" (%.2f)",
                hardwork,
                (double) hardwork/gt_encseq_total_length(bucketspec2->encseq));
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq $0x0, 0xa8(%rsp)
movq 0xc0(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
leaq 0x2cd4a3(%rip), %rsi    # 0x589406
movl $0x1d8, %edx            # imm = 0x1D8
callq 0xe80f0
movq %rax, 0xa0(%rsp)
movl $0x0, 0x98(%rsp)
movl 0x98(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x2bc4d6
movq 0xc0(%rsp), %rax
movq 0x20(%rax), %rax
movl 0x98(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x94(%rsp)
movl $0x0, 0x90(%rsp)
movl 0x90(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x2bc1ac
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
movl 0x94(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x90(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
testb $0x1, 0x1(%rax)
jne 0x2bc12c
movl 0x94(%rsp), %eax
cmpl 0x90(%rsp), %eax
je 0x2bc12c
jmp 0x2bc01d
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
movl 0x94(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x90(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
testb $0x1, (%rax)
jne 0x2bc07f
movq 0x37ff52(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x259fbb(%rip), %rsi    # 0x516013
leaq 0x2cd3ef(%rip), %rdx    # 0x58944e
leaq 0x2cd3b9(%rip), %rcx    # 0x58941f
leaq 0x2cd399(%rip), %r8     # 0x589406
movl $0x1e0, %r9d            # imm = 0x1E0
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2bc081
movq 0xb0(%rsp), %rdi
movl 0x94(%rsp), %edx
movl 0x90(%rsp), %ecx
leaq 0x2cd39b(%rip), %rsi    # 0x589439
movb $0x0, %al
callq 0xe7cd0
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x90(%rsp), %edx
callq 0x2bc5a0
movq %rax, 0x88(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x90(%rsp), %edx
callq 0x2bc6a0
movq %rax, %rcx
movq 0x88(%rsp), %rax
subq %rcx, %rax
addq 0xa8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
movl 0x94(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x90(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x1, 0x1(%rax)
jmp 0x2bc194
jmp 0x2bc12e
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
movl 0x94(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x90(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
testb $0x1, (%rax)
je 0x2bc190
movq 0x37fe41(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x259eaa(%rip), %rsi    # 0x516013
leaq 0x2cd2dd(%rip), %rdx    # 0x58944d
leaq 0x2cd2a8(%rip), %rcx    # 0x58941f
leaq 0x2cd288(%rip), %r8     # 0x589406
movl $0x1e7, %r9d            # imm = 0x1E7
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2bc192
jmp 0x2bc194
jmp 0x2bc196
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x2bbfc0
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
xorl %edx, %edx
callq 0x2bc6a0
movq %rax, 0x80(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x94(%rsp), %edx
callq 0x2bc6a0
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
jae 0x2bc2bf
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x2bc25c
movq 0xc0(%rsp), %rdi
movl 0x9c(%rsp), %esi
movl 0x94(%rsp), %edx
callq 0x2bc6a0
movq %rax, %rdx
movq 0xa0(%rsp), %rax
movl 0x9c(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x2bc204
movq 0xc0(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x7c(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
xorl %edx, %edx
callq 0x2bc6a0
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movl 0x7c(%rsp), %ecx
movq %rax, %r8
callq 0x2bc7b0
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x94(%rsp), %edx
callq 0x2bc5a0
movq %rax, 0x58(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movq 0xc0(%rsp), %rax
movl 0x14(%rax), %edx
callq 0x2bc5a0
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jae 0x2bc447
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x2bc376
movq 0xc0(%rsp), %rdi
movl 0x9c(%rsp), %esi
movl 0x94(%rsp), %edx
callq 0x2bc5a0
movq %rax, %rdx
subq $0x1, %rdx
movq 0xa0(%rsp), %rax
movl 0x9c(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x2bc31a
jmp 0x2bc378
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movq 0xc0(%rsp), %rax
movl 0x14(%rax), %edx
callq 0x2bc5a0
cmpq $0x0, %rax
ja 0x2bc3d5
movq 0x37fbfc(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x259c65(%rip), %rsi    # 0x516013
leaq 0x2cd0d0(%rip), %rdx    # 0x589485
leaq 0x2cd063(%rip), %rcx    # 0x58941f
leaq 0x2cd043(%rip), %r8     # 0x589406
movl $0x200, %r9d            # imm = 0x200
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2bc3d7
movq 0xc0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x94(%rsp), %esi
movq 0xc0(%rsp), %rax
movl 0x14(%rax), %edx
callq 0x2bc5a0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movl 0x54(%rsp), %ecx
movq %rax, %r8
subq $0x1, %r8
callq 0x2bca00
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x2bc4a2
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
movl 0x9c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x94(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x1, 0x1(%rax)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x2bc452
movq 0xc0(%rsp), %rax
movq 0x38(%rax), %rax
movl 0x94(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x1, 0x1(%rax)
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x2bbf80
movq 0xa0(%rsp), %rdi
leaq 0x2ccf21(%rip), %rsi    # 0x589406
movl $0x20e, %edx            # imm = 0x20E
callq 0xe88c0
movq 0xb0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rax, %xmm0
movaps 0x25c41b(%rip), %xmm1   # 0x518930
movaps %xmm1, (%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x25c41b(%rip), %xmm1   # 0x518940
movaps %xmm1, 0x10(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0xc0(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0xa9d00
movaps (%rsp), %xmm3
movaps 0x10(%rsp), %xmm2
movsd 0x20(%rsp), %xmm0
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x2ccf33(%rip), %rsi    # 0x5894bf
movb $0x1, %al
callq 0xe7cd0
addq $0xc8, %rsp
retq
nopl (%rax,%rax)