// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x197fb9
movq 0x4a4018(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37e081(%rip), %rsi    # 0x516013
leaq 0x3bf809(%rip), %rdx    # 0x5577a2
leaq 0x3bf80e(%rip), %rcx    # 0x5577ae
leaq 0x3bf794(%rip), %r8     # 0x55773b
movl $0x17c, %r9d            # imm = 0x17C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x197fbb
jmp 0x197fbd
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x88(%rcx), %rcx
cmpq 0x10(%rcx), %rax
je 0x198017
movq 0x4a3fba(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37e023(%rip), %rsi    # 0x516013
leaq 0x3bf7ce(%rip), %rdx    # 0x5577c5
leaq 0x3bf7b0(%rip), %rcx    # 0x5577ae
leaq 0x3bf736(%rip), %r8     # 0x55773b
movl $0x17e, %r9d            # imm = 0x17E
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x198019
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x19821d
movq 0x30(%rsp), %rax
movq $0x0, 0xb0(%rax)
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0xc0(%rax)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x80(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jae 0x1981ff
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x88(%rax), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq 0x98(%rax), %rdi
movq 0x20(%rsp), %rdx
xorl %esi, %esi
callq 0x2ca370
movq 0x30(%rsp), %rax
movq 0x98(%rax), %rdi
callq 0x2cb510
testb $0x1, %al
jne 0x19811e
jmp 0x198156
movq 0x4a3e7b(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x37dee4(%rip), %rsi    # 0x516013
leaq 0x3bf6d2(%rip), %rdx    # 0x557808
leaq 0x3bf671(%rip), %rcx    # 0x5577ae
leaq 0x3bf5f7(%rip), %r8     # 0x55773b
movl $0x18f, %r9d            # imm = 0x18F
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x198158
jmp 0x19815a
movq 0x30(%rsp), %rax
movq 0x98(%rax), %rdi
callq 0x2cac00
movq %rax, %rcx
movq %rcx, 0x8(%rsp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x7(%rsp)
je 0x1981a6
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rdx
movl 0xd0(%rdx), %edx
subl $0x1, %edx
movl %edx, %edx
subq %rdx, %rcx
cmpq %rcx, %rax
setbe %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x1981b0
jmp 0x1981ea
movq 0x8(%rsp), %rax
testb $0x1, (%rax)
jne 0x1981d7
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
callq 0x198230
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x19815a
jmp 0x1981ec
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x198067
movq 0x30(%rsp), %rdi
callq 0x198370
movq 0x30(%rsp), %rdi
callq 0x1983b0
movq 0x30(%rsp), %rdi
callq 0x198420
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)