// File: /workspace/github_c_makefile_star2_O2/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 0xf4a9f
movq %rdi, %rbx
movq 0xb0(%rdi), %r12
movq %r12, 0xb8(%rdi)
testq %r12, %r12
je 0xf4636
xorl %r15d, %r15d
cmpq %r12, %r15
jae 0xf4636
movq 0xa0(%rbx), %rax
movq %r15, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0xc(%rax), %r14d
xorl %r13d, %r13d
movq %r14, %rcx
cmpq %r12, %r15
jae 0xf45c4
cmpq %rcx, %r14
jne 0xf45c4
incq %r15
movq %r14, %rcx
cmpq %r12, %r15
jae 0xf45bb
movl 0x4(%rax), %ecx
addq $0x10, %rax
decq %r13
jmp 0xf45a3
movq 0x8(%rbx), %rax
movq (%rax,%r14,8), %rcx
testq %rcx, %rcx
jne 0xf45d9
incq 0x40(%rbx)
movq (%rax,%r14,8), %rcx
subq %r13, %rcx
movq %rcx, (%rax,%r14,8)
movq 0x28(%rbx), %rcx
subq %r13, (%rax,%rcx,8)
cmpb $0x1, 0x78(%rbx)
jne 0xf457b
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x5e839
testb %al, %al
je 0xf457b
cmpb $0x1, 0x79(%rbx)
jne 0xf462a
movq 0x8(%rbx), %rax
movq 0x48(%rbx), %rcx
shrq %rcx
cmpq %rcx, (%rax,%r14,8)
jae 0xf462a
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x5e199
jmp 0xf457b
addq %r13, 0xb8(%rbx)
jmp 0xf457b
cmpb $0x1, 0x79(%rbx)
jne 0xf4673
movq %rbx, %rdi
callq 0xf549d
xorl %edx, %edx
divq 0x58(%rbx)
movq %rax, %r14
movq %rax, 0x48(%rbx)
movq 0x50(%rbx), %rax
cmpq %rax, %r14
jb 0xf466f
movq %rbx, %rdi
callq 0xf552e
cmpq %rax, %r14
jae 0xf4673
movq %rbx, %rdi
callq 0xf552e
movq %rax, 0x48(%rbx)
movq 0xb8(%rbx), %r13
testq %r13, %r13
je 0xf48d3
movq (%rbx), %rax
movq 0x28(%rbx), %rdx
movq (%rax,%rdx,8), %rcx
addq %r13, %rcx
movq 0x38(%rbx), %rax
cmpq %rax, %rcx
jbe 0xf472f
movq %rax, %xmm0
punpckldq 0x1f3235(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1f323d(%rip), %xmm0   # 0x2e78f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1f3651(%rip), %xmm1   # 0x2e7d18
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x1f3645(%rip), %xmm1   # 0x2e7d20
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 0x230cf6(%rip), %r14    # 0x3253f3
movq %r14, %rdx
movl $0xa3, %ecx
callq 0x93472
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movq 0x38(%rbx), %rsi
shlq $0x3, %rsi
movq %r14, %rdx
movl $0xa5, %ecx
callq 0x93472
movq %rax, 0x18(%rbx)
movq 0x28(%rbx), %rdx
pushq $-0x1
popq %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
testq %rdx, %rdx
je 0xf48ac
testq %r13, %r13
je 0xf48ac
leaq -0x1(%rdx), %r14
movq (%rbx), %rax
movq 0x20(%rbx), %rdi
movq -0x8(%rax,%rdx,8), %rcx
movq (%rax,%rdx,8), %rbp
movq %rbp, %r15
movq %rcx, (%rsp)
subq %rcx, %r15
movq %r14, %rsi
movq %rdx, 0x8(%rsp)
callq 0x5e839
movq (%rbx), %rcx
movq 0x8(%rsp), %rdx
addq %r13, (%rcx,%rdx,8)
movq 0xa0(%rbx), %rcx
movq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rdi
addq $-0x10, %rdi
movq %rbp, 0x8(%rsp)
leaq -0x1(%rbp), %rsi
addq $-0x10, %rcx
movq %r15, 0x20(%rsp)
movq (%rdi), %r9
movl %r9d, %r8d
shrq $0x20, %r9
movq %r12, %rdi
shlq $0x4, %rdi
addq %rcx, %rdi
testq %r13, %r13
je 0xf4819
cmpq %r9, %r14
jne 0xf4819
testq %r12, %r12
je 0xf4819
testb %al, 0x78(%rbx)
jne 0xf480b
leaq (%rsi,%r13), %r9
movq 0xc0(%rbx), %r10
addq %r8, %r10
movq 0x10(%rbx), %r11
movq %r10, (%r11,%r9,8)
movq 0x8(%rdi), %r10
movq 0x18(%rbx), %r11
movq %r10, (%r11,%r9,8)
decq %r13
incq %r15
cmpq 0x68(%rbx), %r14
jne 0xf480b
incq 0x60(%rbx)
addq $-0x10, %rdi
movq %r14, %r9
decq %r12
je 0xf47c5
jmp 0xf47b1
testq %r15, %r15
setne %al
movq 0x18(%rsp), %rsi
cmpq %rsi, %r15
setb %cl
testb %cl, %al
cmovneq %r15, %rsi
movq %rsi, 0x18(%rsp)
movq 0x10(%rsp), %rax
cmovneq %r14, %rax
movq %rax, 0x10(%rsp)
movq %r14, %rdx
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
jbe 0xf4740
movq %r14, %rdx
testq %r13, %r13
je 0xf4740
movq 0x10(%rbx), %rax
movq 0x20(%rsp), %rbp
movq (%rsp), %r15
leaq (%r15,%r13), %rcx
movq %rcx, 0x8(%rsp)
leaq (%rax,%rcx,8), %rdi
leaq (%rax,%r15,8), %rsi
shlq $0x3, %rbp
movq %rbp, %rdx
callq 0x17c50
movq 0x18(%rbx), %rax
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %rdi
leaq (%rax,%r15,8), %rsi
movq %rbp, %rdx
callq 0x17c50
movq %r14, %rdx
jmp 0xf4740
testq %r13, %r13
jne 0xf4acd
movq 0x60(%rbx), %rax
decq %rax
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
jb 0xf48d3
movq %rcx, 0x60(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rbx)
cmpb $0x1, 0x7a(%rbx)
jne 0xf4a90
movsd 0x70(%rbx), %xmm0
movsd 0x1f2ff6(%rip), %xmm1   # 0x2e78e0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1f2ffb(%rip), %xmm2   # 0x2e78f0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
mulsd 0x2173eb(%rip), %xmm3   # 0x30bcf8
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 0xf4a90
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r14d, %r14d
movq $0x0, (%rsp)
xorl %r12d, %r12d
cmpq %rax, %r14
jae 0xf4a2a
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 0xf4986
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x5e839
testb %al, %al
je 0xf49a5
testb $0x1, %r12b
movq (%rsp), %rax
cmovneq %r13, %rax
movq %rax, (%rsp)
movzbl %r12b, %r12d
movl $0x0, %eax
cmovnel %eax, %r12d
jmp 0xf4a1e
testb $0x1, %r12b
jne 0xf4a09
testq %rbp, %rbp
je 0xf4a09
movq (%rsp), %rax
leaq (,%rax,8), %r12
movq 0x10(%rbx), %rsi
addq %r12, %rsi
leaq (,%rbp,8), %rcx
movq %rcx, 0x10(%rsp)
movq %rsi, %rdi
subq %rcx, %rdi
movq %r15, 0x18(%rsp)
movq %r13, %r15
subq %rax, %r15
shlq $0x3, %r15
movq %r15, %rdx
callq 0x17c50
addq 0x18(%rbx), %r12
movq %r12, %rdi
subq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq 0x18(%rsp), %r15
callq 0x17c50
subq %r13, %rbp
addq %r15, %rbp
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x5e143
movb $0x1, %r12b
movq 0x28(%rbx), %rax
incq %r14
jmp 0xf4949
testb $0x1, %r12b
jne 0xf4a7d
testq %rbp, %rbp
je 0xf4a7d
movq (%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 0x17c50
addq 0x18(%rbx), %r12
movq %r12, %rdi
subq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x17c50
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
movq 0x3434c2(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0563(%rip), %rsi    # 0x2e5013
leaq 0x2309a3(%rip), %rdx    # 0x32545a
leaq 0x231332(%rip), %rcx    # 0x325df0
leaq 0x23092e(%rip), %r8     # 0x3253f3
movl $0x11a, %r9d            # imm = 0x11A
jmp 0xf4af9
movq 0x343494(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0535(%rip), %rsi    # 0x2e5013
leaq 0x231322(%rip), %rdx    # 0x325e07
leaq 0x231304(%rip), %rcx    # 0x325df0
leaq 0x230900(%rip), %r8     # 0x3253f3
movl $0x151, %r9d            # imm = 0x151
xorl %eax, %eax
callq 0x17a50
callq 0x17390