// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/firstcodes-tab.c
// Function: gt_firstcodes_remdups
GtUword gt_firstcodes_remdups(GtUword *allfirstcodes,
                                    GtFirstcodesspacelog *fcsl,
                                    GtFirstcodestab *fct,
                                    GtUword numofsequences,
                                    Gtmarksubstring *markprefix,
                                    Gtmarksubstring *marksuffix,
                                    GtArrayGtIndexwithcode **binsearchcache,
                                    unsigned int addbscache_depth,
                                    bool withdistbits,
                                    GtLogger *logger)
{
  if (numofsequences == 0)
  {
    fct->differentcodes = 0;
  } else
  {
    GtUword numofdifferentcodes = 1UL, storeidx, readidx, previouscode,
                  idx, maxdifference = 0, cachewidth, nextstorecache, lastocc,
                  storedvalue, diff, *distbits = NULL;
    unsigned int bitsformaxdifference, bitsforcount;

    previouscode = allfirstcodes[0];
    for (idx=1UL; idx < numofsequences; idx++)
    {
      GtUword currentcode = allfirstcodes[idx];
      if (previouscode != currentcode)
      {
        numofdifferentcodes++;
        if (maxdifference < currentcode - previouscode)
        {
          maxdifference = currentcode - previouscode;
        }
        previouscode = currentcode;
      }
    }
    bitsformaxdifference = gt_determinebitspervalue(maxdifference);
    fct->differencemask = (1UL << bitsformaxdifference) - 1UL;
    gt_assert(sizeof (GtUword) * CHAR_BIT >=
              (size_t) bitsformaxdifference);
    bitsforcount = (unsigned int)
                   sizeof (GtUword) * CHAR_BIT - bitsformaxdifference;
    fct->countmax = (1UL << bitsforcount) - 1UL;
    fct->shiftforcounts = bitsformaxdifference;
    gt_logger_log(logger,
                  "maximum difference of neighbored codes "GT_WU" (%u bits)",
                  maxdifference,bitsformaxdifference);
    /*
    printf("maxdifference="GT_WU",bitsformaxdifference=%u,bitsforcount=%u\n",
            maxdifference,bitsformaxdifference,bitsforcount);
    */
    gt_firstcodes_countocc_new(fcsl,fct,bitsforcount,numofsequences);
    gt_marksubstring_mark(markprefix,allfirstcodes[0]);
    gt_marksubstring_mark(marksuffix,allfirstcodes[0]);
    *binsearchcache
      = gt_firstcodes_binsearchcache_new(numofdifferentcodes,
                                         addbscache_depth,
                                         fcsl);
    cachewidth = (*binsearchcache) == NULL
                   ? 0
                   : gt_firstcodes_binsearchcache_width(*binsearchcache);
    nextstorecache = cachewidth;
    lastocc = 1UL; /* for first code */
    storedvalue = allfirstcodes[0];
    allfirstcodes[0] = 0;
    if (withdistbits)
    {
      distbits = gt_calloc((size_t) (64+1),sizeof (*distbits));
    }
    for (storeidx = 0, readidx = 1UL; readidx < numofsequences; readidx++)
    {
      GtUword readvalue = allfirstcodes[readidx];

      if (storedvalue != readvalue)
      {
        if ((*binsearchcache) != NULL && storeidx == nextstorecache)
        {
          gt_firstcodes_binsearchcache_set_index_code(*binsearchcache,
                                                      nextstorecache,
                                                      storedvalue);
          nextstorecache += cachewidth;
        }
        gt_firstcodes_countocc_set(fct,allfirstcodes,storeidx,lastocc);
        lastocc = 1UL;
        storeidx++;
        gt_assert(storedvalue < readvalue);
        diff = readvalue - storedvalue;
        if (distbits != NULL)
        {
          distbits[gt_determinebitspervalue(diff)]++;
        }
        allfirstcodes[storeidx] = diff;
        storedvalue = readvalue;
        gt_marksubstring_mark(markprefix,readvalue);
        gt_marksubstring_mark(marksuffix,readvalue);
      } else
      {
        lastocc++;
      }
    }
    if (withdistbits)
    {
      int bits;

      gt_assert(distbits != NULL);
      for (bits = 0; bits <= 64; bits++)
      {
        if (distbits[bits] > 0)
        {
          printf("%d bits: "GT_WU"\n",bits,distbits[bits]);
        }
      }
      gt_free(distbits);
    }
    gt_firstcodes_countocc_set(fct,allfirstcodes,storeidx,lastocc);
    gt_assert(numofdifferentcodes == (GtUword) (storeidx + 1));
    if (numofdifferentcodes < numofsequences)
    {
      /* reduce the memory requirement, as the duplicated elements are not
         needed */
      gt_firstcodes_countocc_resize(fcsl,fct,numofdifferentcodes);
    }
    fct->differentcodes = numofdifferentcodes;
  }
  gt_logger_log(logger,"number of different first codes="GT_WU" (%.2f%%) "
                       "in "GT_WU" sequences",
                fct->differentcodes,
                100.00 * (double) fct->differentcodes/numofsequences,
                numofsequences);
  return fct->differentcodes;
}

// Assembly:
subq $0xc8, %rsp
movq 0xe8(%rsp), %rax
movb 0xe0(%rsp), %al
movl 0xd8(%rsp), %r10d
movq 0xd0(%rsp), %r10
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %r8, 0xa0(%rsp)
movq %r9, 0x98(%rsp)
andb $0x1, %al
movb %al, 0x97(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x4bf27e
movq 0xb0(%rsp), %rax
movq $0x0, (%rax)
jmp 0x4bf84f
movq $0x1, 0x88(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x30(%rsp)
movq 0xc0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq $0x1, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jae 0x4bf33c
movq 0xc0(%rsp), %rax
movq 0x68(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x4bf327
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq 0x60(%rsp), %rax
movq 0x20(%rsp), %rcx
subq 0x70(%rsp), %rcx
cmpq %rcx, %rax
jae 0x4bf31d
movq 0x20(%rsp), %rax
subq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x4bf329
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
jmp 0x4bf2b5
movq 0x60(%rsp), %rdi
callq 0xec660
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
subq $0x1, %rcx
movq 0xb0(%rsp), %rax
movq %rcx, 0x58(%rax)
movl 0x2c(%rsp), %eax
movl %eax, %ecx
movl $0x40, %eax
cmpq %rcx, %rax
jae 0x4bf3b3
movq 0x17cc1e(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x56c87(%rip), %rsi     # 0x516013
leaq 0xf89a8(%rip), %rdx     # 0x5b7d3b
leaq 0xf89de(%rip), %rcx     # 0x5b7d78
leaq 0xf89ed(%rip), %r8      # 0x5b7d8e
movl $0x109, %r9d            # imm = 0x109
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4bf3b5
movl $0x40, %eax
subl 0x2c(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x28(%rsp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
subq $0x1, %rcx
movq 0xb0(%rsp), %rax
movq %rcx, 0x60(%rax)
movl 0x2c(%rsp), %ecx
movq 0xb0(%rsp), %rax
movl %ecx, 0x68(%rax)
movq 0xe8(%rsp), %rdi
movq 0x60(%rsp), %rdx
movl 0x2c(%rsp), %ecx
leaq 0xf899f(%rip), %rsi     # 0x5b7da9
movb $0x0, %al
callq 0xe7cd0
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movl 0x28(%rsp), %edx
movq 0xa8(%rsp), %rcx
callq 0x4bf8e0
movq 0xa0(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq (%rax), %rsi
callq 0x261080
movq 0x98(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq (%rax), %rsi
callq 0x261080
movq 0x88(%rsp), %rdi
movl 0xd8(%rsp), %esi
movq 0xb8(%rsp), %rdx
callq 0x4ba5c0
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, (%rax)
movq 0xd0(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x4bf4a3
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x4bf4b8
movq 0xd0(%rsp), %rax
movq (%rax), %rdi
callq 0x4ba7c0
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x50(%rsp)
movq $0x1, 0x48(%rsp)
movq 0xc0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0xc0(%rsp), %rax
movq $0x0, (%rax)
testb $0x1, 0x97(%rsp)
je 0x4bf51e
movl $0x41, %edi
movl $0x8, %esi
leaq 0xf887f(%rip), %rdx     # 0x5b7d8e
movl $0x125, %ecx            # imm = 0x125
callq 0xe83c0
movq %rax, 0x30(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x1, 0x78(%rsp)
movq 0x78(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jae 0x4bf6e1
movq 0xc0(%rsp), %rax
movq 0x78(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x18(%rsp), %rax
je 0x4bf6be
movq 0xd0(%rsp), %rax
cmpq $0x0, (%rax)
je 0x4bf5b2
movq 0x80(%rsp), %rax
cmpq 0x50(%rsp), %rax
jne 0x4bf5b2
movq 0xd0(%rsp), %rax
movq (%rax), %rdi
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x4ba7d0
movq 0x58(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x4bfa10
movq $0x1, 0x48(%rsp)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x18(%rsp), %rax
jb 0x4bf635
movq 0x17c99c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x56a05(%rip), %rsi     # 0x516013
leaq 0xf87c9(%rip), %rdx     # 0x5b7dde
leaq 0xf875c(%rip), %rcx     # 0x5b7d78
leaq 0xf876b(%rip), %r8      # 0x5b7d8e
movl $0x137, %r9d            # imm = 0x137
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4bf637
movq 0x18(%rsp), %rax
subq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x4bf675
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
callq 0xec660
movl %eax, %ecx
movq (%rsp), %rax
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rdx
movq 0xc0(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x261080
movq 0x98(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x261080
jmp 0x4bf6cc
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x4bf6ce
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0x4bf533
testb $0x1, 0x97(%rsp)
je 0x4bf798
jmp 0x4bf6f1
cmpq $0x0, 0x30(%rsp)
jne 0x4bf731
movq 0x17c8a0(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x56909(%rip), %rsi     # 0x516013
leaq 0xf86e5(%rip), %rdx     # 0x5b7df6
leaq 0xf8660(%rip), %rcx     # 0x5b7d78
leaq 0xf866f(%rip), %r8      # 0x5b7d8e
movl $0x14a, %r9d            # imm = 0x14A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4bf733
movl $0x0, 0x14(%rsp)
cmpl $0x40, 0x14(%rsp)
jg 0x4bf782
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jbe 0x4bf773
movl 0x14(%rsp), %esi
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0xf869b(%rip), %rdi     # 0x5b7e07
movb $0x0, %al
callq 0x19070
jmp 0x4bf775
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x4bf73b
movq 0x30(%rsp), %rdi
leaq 0xf8600(%rip), %rsi     # 0x5b7d8e
movl $0x152, %edx            # imm = 0x152
callq 0xe88c0
movq 0xb0(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x4bfa10
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
je 0x4bf80b
movq 0x17c7c6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x5682f(%rip), %rsi     # 0x516013
leaq 0xf862a(%rip), %rdx     # 0x5b7e15
leaq 0xf8586(%rip), %rcx     # 0x5b7d78
leaq 0xf8595(%rip), %r8      # 0x5b7d8e
movl $0x155, %r9d            # imm = 0x155
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4bf80d
movq 0x88(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jae 0x4bf83c
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x4bfb70
movq 0x88(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, (%rax)
movq 0xe8(%rsp), %rdi
movq 0xb0(%rsp), %rax
movq (%rax), %rdx
movq %rdx, %xmm0
movaps 0x590c2(%rip), %xmm3    # 0x518930
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x590c6(%rip), %xmm2    # 0x518940
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x5afa7(%rip), %xmm1    # 0x51a838
mulsd %xmm1, %xmm0
movq 0xa8(%rsp), %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
movq 0xa8(%rsp), %rcx
leaq 0xf8581(%rip), %rsi     # 0x5b7e45
movb $0x1, %al
callq 0xe7cd0
movq 0xb0(%rsp), %rax
movq (%rax), %rax
addq $0xc8, %rsp
retq
nop