// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/kmer_database.c
// Function: gt_kmer_database_merge
static void gt_kmer_database_merge(GtKmerDatabase *kdb)
{
  GtUword left = 0,
          right,
          new_pos,
          code,
          kmercode,
          size_sb,
          preprocessed_size,
          startpos,
          current_min_occ = GT_UNDEF_UWORD,
          current_min_code = 0,
          occ;
  bool deleted;

  gt_assert(kdb != NULL);

  size_sb = kdb->sb.kmer_count;
  gt_kmer_database_preprocess_buffer(kdb);
  preprocessed_size = kdb->sb.preprocessed_kmer_count;

  if (preprocessed_size > 0) {
    if (preprocessed_size + kdb->offset[kdb->nu_kmer_codes] > kdb->current_size)
      gt_kmer_database_increase_size(kdb);

    for (code = kdb->nu_kmer_codes;
         code > 0 && preprocessed_size != 0;
         code--) {
      left = kdb->offset[code - 1];
      right = kdb->offset[code];
      occ = right - left;

      deleted = gt_bittab_bit_is_set(kdb->deleted_positions, code - 1);

      kdb->offset[code] += preprocessed_size;

      gt_kmer_database_decode_kmer(kdb->sb.kmers[size_sb - 1].a,
                                   kmercode, startpos);
      /* add new kmer positions from buffer (last to first) where <kmercode> =
         <code> - 1 */
      while (preprocessed_size > 0 && code - 1 == kmercode && size_sb > 0) {
        if (!kdb->cutoff_is_set || !deleted) {
          new_pos = right + preprocessed_size - 1;
          kdb->positions[new_pos] = kdb->sb.offset + startpos;
          kdb->unique_ids[new_pos] = kdb->sb.kmers[size_sb - 1].b;
          preprocessed_size--;
          occ++;
          if (code - 1 == kdb->min_code)
            kdb->min_nu_occ++;
        }
        size_sb--;
        if (size_sb > 0) {
          gt_kmer_database_decode_kmer(kdb->sb.kmers[size_sb - 1].a,
                                       kmercode, startpos);
        }
      }
      if (occ != 0 && occ < current_min_occ) {
        current_min_occ = occ;
        current_min_code = code - 1;
      }
      /* move previously included kmers with <code> to the right */
      if (left < right && preprocessed_size > 0) {
        memmove(kdb->positions + (left + preprocessed_size),
                kdb->positions + left,
                (size_t) (right - left) * sizeof (*kdb->positions));
        memmove(kdb->unique_ids + (left + preprocessed_size),
                kdb->unique_ids + left,
                (size_t) (right - left) * sizeof (*kdb->unique_ids));
      }
    }
    gt_assert(preprocessed_size == 0);
    if ((current_min_occ < kdb->min_nu_occ) ||
        (kdb->min_nu_occ == 0)) {
      kdb->min_nu_occ = current_min_occ;
      kdb->min_code = current_min_code;
    }
  }
  if (kdb->prune_is_set &&
      (kdb->last_size * GT_KMER_DATABASE_CALL_PRUNE_FACTOR <=
       kdb->offset[kdb->nu_kmer_codes])) {
      gt_kmer_database_prune(kdb);
      kdb->last_size = kdb->offset[kdb->nu_kmer_codes];
  }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $-0x1, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x198484
movq 0x4a3b4d(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37dbb6(%rip), %rsi    # 0x516013
leaq 0x3bf33e(%rip), %rdx    # 0x5577a2
leaq 0x3bfccd(%rip), %rcx    # 0x558138
leaq 0x3bf2c9(%rip), %r8     # 0x55773b
movl $0x11a, %r9d            # imm = 0x11A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x198486
movq 0x60(%rsp), %rax
movq 0xb0(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x60(%rsp), %rdi
callq 0x19b6b0
movq 0x60(%rsp), %rax
movq 0xb8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jbe 0x1988be
movq 0x28(%rsp), %rax
movq 0x60(%rsp), %rcx
movq (%rcx), %rcx
movq 0x60(%rsp), %rdx
movq 0x28(%rdx), %rdx
addq (%rcx,%rdx,8), %rax
movq 0x60(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jbe 0x1984ed
movq 0x60(%rsp), %rdi
callq 0x19b9e0
movq 0x60(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x40(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x40(%rsp)
movb %al, 0x6(%rsp)
jbe 0x198516
cmpq $0x0, 0x28(%rsp)
setne %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x198523
jmp 0x198840
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
subq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x60(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x40(%rsp), %rsi
subq $0x1, %rsi
callq 0x8a780
andb $0x1, %al
movb %al, 0x7(%rsp)
movq 0x28(%rsp), %rdx
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x60(%rsp), %rax
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rax
subq $0x1, %rax
shlq $0x4, %rax
addq %rax, %rcx
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq (%rcx), %rax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x28(%rsp)
movb %al, 0x5(%rsp)
jbe 0x198620
movq 0x40(%rsp), %rcx
subq $0x1, %rcx
xorl %eax, %eax
cmpq 0x38(%rsp), %rcx
movb %al, 0x5(%rsp)
jne 0x198620
cmpq $0x0, 0x30(%rsp)
seta %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
testb $0x1, %al
jne 0x19862d
jmp 0x19875f
movq 0x60(%rsp), %rax
testb $0x1, 0x78(%rax)
je 0x198643
testb $0x1, 0x7(%rsp)
jne 0x1986ee
movq 0x50(%rsp), %rax
addq 0x28(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rax
movq 0xc0(%rax), %rdx
addq 0x20(%rsp), %rdx
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x60(%rsp), %rax
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x48(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rax
subq $0x1, %rax
movq 0x60(%rsp), %rcx
cmpq 0x68(%rcx), %rax
jne 0x1986ec
movq 0x60(%rsp), %rax
movq 0x60(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x60(%rax)
jmp 0x1986ee
movq 0x30(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jbe 0x19875a
movq 0x60(%rsp), %rax
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rax
subq $0x1, %rax
shlq $0x4, %rax
addq %rax, %rcx
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq (%rcx), %rax
movq %rax, 0x20(%rsp)
jmp 0x1985ef
cmpq $0x0, 0x8(%rsp)
je 0x19878b
movq 0x8(%rsp), %rax
cmpq 0x18(%rsp), %rax
jae 0x19878b
movq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
jae 0x19882b
cmpq $0x0, 0x28(%rsp)
jbe 0x19882b
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x58(%rsp), %rax
addq 0x28(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x58(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq 0x50(%rsp), %rdx
subq 0x58(%rsp), %rdx
shlq $0x3, %rdx
callq 0x19bf0
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x58(%rsp), %rax
addq 0x28(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x58(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq 0x50(%rsp), %rdx
subq 0x58(%rsp), %rdx
shlq $0x3, %rdx
callq 0x19bf0
jmp 0x19882d
movq 0x40(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x1984fb
jmp 0x198842
cmpq $0x0, 0x28(%rsp)
je 0x198882
movq 0x4a374f(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37d7b8(%rip), %rsi    # 0x516013
leaq 0x3bf8ed(%rip), %rdx    # 0x55814f
leaq 0x3bf8cf(%rip), %rcx    # 0x558138
leaq 0x3beecb(%rip), %r8     # 0x55773b
movl $0x151, %r9d            # imm = 0x151
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x198884
movq 0x18(%rsp), %rax
movq 0x60(%rsp), %rcx
cmpq 0x60(%rcx), %rax
jb 0x1988a0
movq 0x60(%rsp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x1988bc
movq 0x18(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x10(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x68(%rax)
jmp 0x1988be
movq 0x60(%rsp), %rax
testb $0x1, 0x7a(%rax)
je 0x198952
movq 0x60(%rsp), %rcx
movq 0x70(%rcx), %xmm1
movaps 0x380052(%rip), %xmm3   # 0x518930
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x380056(%rip), %xmm2   # 0x518940
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x3a4b07(%rip), %xmm0   # 0x53d408
mulsd %xmm0, %xmm1
movq (%rcx), %rax
movq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x198952
movq 0x60(%rsp), %rdi
callq 0x19bb00
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x60(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x70(%rax)
addq $0x68, %rsp
retq
nopw (%rax,%rax)