// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x15f353
movq %rdi, %rbx
movq 0xb0(%rdi), %r12
movq %r12, 0xb8(%rdi)
testq %r12, %r12
je 0x15eea7
xorl %r15d, %r15d
movq 0xa0(%rbx), %rax
movq %r15, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0xc(%rax), %r14d
movl $0x1, %ecx
xorl %r13d, %r13d
movq %r14, %rdx
leaq (%r15,%rcx), %rbp
cmpq %r12, %rbp
jae 0x15ee2a
movl 0x4(%rax), %edx
decq %r13
cmpq %r12, %rbp
jae 0x15ee3e
addq $0x10, %rax
incq %rcx
cmpq %rdx, %r14
je 0x15ee1e
movq 0x8(%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
jne 0x15ee4d
incq 0x40(%rbx)
subq %r13, (%rax,%r14,8)
movq 0x28(%rbx), %rcx
subq %r13, (%rax,%rcx,8)
cmpb $0x1, 0x78(%rbx)
jne 0x15ee9b
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0xd94c7
testb %al, %al
je 0x15ee9b
cmpb $0x1, 0x79(%rbx)
jne 0x15ee94
movq 0x8(%rbx), %rax
movq 0x48(%rbx), %rcx
shrq %rcx
cmpq %rcx, (%rax,%r14,8)
jae 0x15ee94
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0xd9163
jmp 0x15ee9b
addq %r13, 0xb8(%rbx)
subq %r13, %r15
cmpq %r12, %rbp
jb 0x15edfa
cmpb $0x1, 0x79(%rbx)
jne 0x15eee4
movq %rbx, %rdi
callq 0x15f88e
xorl %edx, %edx
divq 0x58(%rbx)
movq %rax, %r14
movq %rax, 0x48(%rbx)
movq 0x50(%rbx), %rax
cmpq %rax, %r14
jb 0x15eee0
movq %rbx, %rdi
callq 0x15f8c3
cmpq %rax, %r14
jae 0x15eee4
movq %rbx, %rdi
callq 0x15f8c3
movq %rax, 0x48(%rbx)
movq 0xb8(%rbx), %r13
testq %r13, %r13
je 0x15f16e
movq (%rbx), %rax
movq 0x28(%rbx), %rcx
movq (%rax,%rcx,8), %rcx
addq %r13, %rcx
movq 0x38(%rbx), %rax
cmpq %rax, %rcx
jbe 0x15ef9c
movq %rax, %xmm0
punpckldq 0x1f19c4(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1f19cc(%rip), %xmm0   # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1f1de0(%rip), %xmm1   # 0x350d18
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x1f1dd4(%rip), %xmm1   # 0x350d20
cvttsd2si %xmm1, %rsi
andq %rcx, %rsi
orq %rax, %rsi
addq 0x30(%rbx), %rsi
movq %rsi, 0x38(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rsi
leaq 0x22f44a(%rip), %r14    # 0x38e3b8
movq %r14, %rdx
movl $0xa3, %ecx
callq 0x1094e6
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movq 0x38(%rbx), %rsi
shlq $0x3, %rsi
movq %r14, %rdx
movl $0xa5, %ecx
callq 0x1094e6
movq %rax, 0x18(%rbx)
movq 0x28(%rbx), %rbp
testq %rbp, %rbp
je 0x15f147
movq $-0x1, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq %rbp, %r14
decq %rbp
movq (%rbx), %rax
movq 0x20(%rbx), %rdi
movq -0x8(%rax,%r14,8), %rcx
movq (%rax,%r14,8), %r15
movq %r15, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
subq %rcx, %r15
movq %rbp, %rsi
callq 0xd94c7
movq (%rbx), %rcx
addq %r13, (%rcx,%r14,8)
movq 0xa0(%rbx), %rcx
movq %r12, %rdi
shlq $0x4, %rdi
movq -0x10(%rcx,%rdi), %r8
movq %r8, %rdx
shrq $0x20, %rdx
movb $0x1, %r9b
cmpq %rdx, %rbp
jne 0x15f0a7
testq %r12, %r12
je 0x15f0a7
movq 0x10(%rsp), %r14
leaq -0x1(%r14), %rsi
movl %r8d, %r8d
andb 0x78(%rbx), %al
addq %rcx, %rdi
addq $-0x8, %rdi
decq %r12
movq %r12, %r10
movq %r15, %rcx
movq %r10, %r12
testb %al, %al
jne 0x15f073
leaq (%rsi,%r13), %r9
movq 0xc0(%rbx), %r10
addq %r8, %r10
movq 0x10(%rbx), %r11
movq %r10, (%r11,%r9,8)
movq (%rdi), %r10
movq 0x18(%rbx), %r11
movq %r10, (%r11,%r9,8)
decq %r13
incq %rcx
cmpq 0x68(%rbx), %rbp
jne 0x15f073
incq 0x60(%rbx)
testq %r12, %r12
je 0x15f083
movq -0x18(%rdi), %rdx
movl %edx, %r8d
shrq $0x20, %rdx
testq %r13, %r13
setne %r9b
je 0x15f0af
movq %r12, %r10
addq $-0x1, %r10
setb %r11b
cmpq %rdx, %rbp
jne 0x15f0af
addq $-0x10, %rdi
testb %r11b, %r11b
jne 0x15f03b
jmp 0x15f0af
movq %r15, %rcx
movq 0x10(%rsp), %r14
testq %rcx, %rcx
setne %al
movq 0x20(%rsp), %rsi
cmpq %rsi, %rcx
setb %dl
testb %dl, %al
cmovneq %rcx, %rsi
movq %rsi, 0x20(%rsp)
movq 0x18(%rsp), %rax
cmovneq %rbp, %rax
movq %rax, 0x18(%rsp)
cmpq 0x8(%rsp), %r14
jbe 0x15f127
testb %r9b, %r9b
je 0x15f127
movq 0x10(%rbx), %rax
movq %r15, %r14
movq 0x8(%rsp), %r15
leaq (%r15,%r13), %rcx
movq %rcx, 0x10(%rsp)
leaq (%rax,%rcx,8), %rdi
leaq (%rax,%r15,8), %rsi
shlq $0x3, %r14
movq %r14, %rdx
callq 0x17cd0
movq 0x18(%rbx), %rax
movq 0x10(%rsp), %rcx
leaq (%rax,%rcx,8), %rdi
leaq (%rax,%r15,8), %rsi
movq %r14, %rdx
callq 0x17cd0
testq %rbp, %rbp
je 0x15f135
testq %r13, %r13
jne 0x15efbb
testq %r13, %r13
sete %al
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdx
jmp 0x15f152
movq $-0x1, %rcx
xorl %eax, %eax
xorl %edx, %edx
testb %al, %al
je 0x15f358
movq 0x60(%rbx), %rax
decq %rax
cmpq %rcx, %rax
jb 0x15f16e
movq %rcx, 0x60(%rbx)
movq %rdx, 0x68(%rbx)
cmpb $0x1, 0x7a(%rbx)
jne 0x15f344
movsd 0x70(%rbx), %xmm0
movsd 0x1f175b(%rip), %xmm1   # 0x3508e0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1f1760(%rip), %xmm2   # 0x3508f0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
mulsd 0x22f208(%rip), %xmm3   # 0x38e3b0
movq (%rbx), %rcx
movq 0x28(%rbx), %rax
movsd (%rcx,%rax,8), %xmm0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
jb 0x15f344
xorl %edx, %edx
testq %rax, %rax
je 0x15f2cd
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
movq (%rbx), %rax
movq (%rax,%r14,8), %r13
movq 0x8(%rax,%r14,8), %r15
movq %r13, %rcx
subq %rbp, %rcx
movq %rcx, (%rax,%r14,8)
movq 0x8(%rbx), %rax
movq (%rax,%r14,8), %rax
cmpq 0x48(%rbx), %rax
jbe 0x15f223
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0xd94c7
xorl %edx, %edx
testb %al, %al
je 0x15f23f
testb $0x1, %r12b
movq 0x8(%rsp), %rax
cmovneq %r13, %rax
movq %rax, 0x8(%rsp)
movzbl %r12b, %r12d
cmovnel %edx, %r12d
jmp 0x15f2bb
testb $0x1, %r12b
jne 0x15f2a4
testq %rbp, %rbp
je 0x15f2a4
movq 0x8(%rsp), %rax
leaq (,%rax,8), %r12
movq 0x10(%rbx), %rsi
addq %r12, %rsi
leaq (,%rbp,8), %rcx
movq %rcx, 0x18(%rsp)
movq %rsi, %rdi
subq %rcx, %rdi
movq %r15, 0x20(%rsp)
movq %r13, %r15
subq %rax, %r15
shlq $0x3, %r15
movq %r15, %rdx
callq 0x17cd0
addq 0x18(%rbx), %r12
movq %r12, %rdi
subq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq 0x20(%rsp), %r15
callq 0x17cd0
subq %r13, %rbp
addq %r15, %rbp
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0xd913c
movb $0x1, %r12b
xorl %edx, %edx
incq %r14
cmpq 0x28(%rbx), %r14
jb 0x15f1ed
movl %r12d, %edx
jmp 0x15f2de
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
testb $0x1, %dl
jne 0x15f331
testq %rbp, %rbp
je 0x15f331
movq 0x8(%rsp), %rax
leaq (,%rax,8), %r12
movq 0x10(%rbx), %rsi
addq %r12, %rsi
movq %r15, %r13
leaq (,%rbp,8), %r15
movq %rsi, %rdi
subq %r15, %rdi
subq %rax, %r13
shlq $0x3, %r13
movq %r13, %rdx
callq 0x17cd0
addq 0x18(%rbx), %r12
movq %r12, %rdi
subq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x17cd0
movq (%rbx), %rax
subq %rbp, (%rax,%r14,8)
movq 0x28(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x70(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4ad44
callq 0x4ad0b