// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/kmer_database.c
// Function: gt_kmer_database_flush
void gt_kmer_database_flush(GtKmerDatabase *kdb)
{
  gt_assert(kdb != NULL);
  gt_assert(kdb->sb.intervals->nextfreeGtRange ==
            kdb->sb.ids->nextfreeGtUword);

  if (kdb->sb.intervals->nextfreeGtRange != 0) {
    GtUword interval_idx;
    kdb->sb.kmer_count = 0;
    kdb->sb.offset = kdb->sb.intervals->spaceGtRange[0].start;

    for (interval_idx = 0;
         interval_idx < kdb->sb.intervals->nextfreeGtRange;
         interval_idx++) {
      GtUword startpos = kdb->sb.intervals->spaceGtRange[interval_idx].start,
              endpos = kdb->sb.intervals->spaceGtRange[interval_idx].end,
              id = kdb->sb.ids->spaceGtUword[interval_idx];
      const GtKmercode *kmercode = NULL;

      gt_kmercodeiterator_reset(kdb->sb.kmer_iter, GT_READMODE_FORWARD,
                                startpos);
      gt_assert(!gt_kmercodeiterator_inputexhausted(kdb->sb.kmer_iter));

      while ((kmercode =
              gt_kmercodeiterator_encseq_next(kdb->sb.kmer_iter)) != NULL &&
             startpos <= endpos - (kdb->sb.kmer_size - 1)) {
        if (!kmercode->definedspecialposition) {
          gt_kmer_database_add_kmer_to_sb(kdb, kmercode->code, startpos, id);
        }
        startpos++;
      }
    }
    gt_kmer_database_intervals_reset(kdb);
    gt_kmer_database_sort_sb(kdb);
    gt_kmer_database_merge(kdb);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0xf43ea
movq %rdi, %rbx
movq 0x80(%rdi), %rax
movq 0x88(%rdi), %rdx
movq 0x10(%rax), %rcx
cmpq 0x10(%rdx), %rcx
jne 0xf4418
testq %rcx, %rcx
je 0xf43a8
andq $0x0, 0xb0(%rbx)
movq (%rax), %rdx
movq (%rdx), %rdx
movq %rdx, 0xc0(%rbx)
xorl %r12d, %r12d
cmpq %rcx, %r12
jae 0xf4376
movq (%rax), %rax
movq %r12, %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %r14
movq 0x8(%rax,%rcx), %r13
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rdi
movq (%rax), %rax
movq (%rax,%r12,8), %r15
xorl %esi, %esi
movq %r14, %rdx
callq 0x19eee0
movq 0x98(%rbx), %rdi
callq 0x19f955
testb %al, %al
jne 0xf43b2
movq 0x98(%rbx), %rdi
callq 0x19f495
testq %rax, %rax
je 0xf4363
movl 0xd0(%rbx), %ecx
decl %ecx
movq %r13, %rdx
subq %rcx, %rdx
cmpq %rdx, %r14
ja 0xf4363
cmpb $0x0, (%rax)
jne 0xf435e
movq 0x8(%rax), %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0xf4446
incq %r14
jmp 0xf4323
incq %r12
movq 0x80(%rbx), %rax
movq 0x10(%rax), %rcx
jmp 0xf42d4
andq $0x0, 0x10(%rax)
movq 0x88(%rbx), %rax
andq $0x0, 0x10(%rax)
andq $0x0, 0xc8(%rbx)
movq %rbx, %rdi
callq 0xf44f3
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf4547
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x343baf(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0c50(%rip), %rsi    # 0x2e5013
leaq 0x2310f6(%rip), %rdx    # 0x3254c0
leaq 0x231095(%rip), %rcx    # 0x325466
leaq 0x23101b(%rip), %r8     # 0x3253f3
movl $0x18f, %r9d            # imm = 0x18F
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x343b77(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0c18(%rip), %rsi    # 0x2e5013
leaq 0x231058(%rip), %rdx    # 0x32545a
leaq 0x23105d(%rip), %rcx    # 0x325466
leaq 0x230fe3(%rip), %r8     # 0x3253f3
movl $0x17c, %r9d            # imm = 0x17C
jmp 0xf43de
movq 0x343b49(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f0bea(%rip), %rsi    # 0x2e5013
leaq 0x23104d(%rip), %rdx    # 0x32547d
leaq 0x23102f(%rip), %rcx    # 0x325466
leaq 0x230fb5(%rip), %r8     # 0x3253f3
movl $0x17e, %r9d            # imm = 0x17E
jmp 0xf43de