// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/kmer_database.c
// Function: gt_kmer_database_add_interval
void gt_kmer_database_add_interval(GtKmerDatabase *kdb,
                                   GtUword start, GtUword end,
                                   GtUword id)
{
  GtRange new;
  GtUword interval_size;

  gt_assert(kdb != NULL);
  gt_assert(start < end + 1 - (kdb->sb.kmer_size - 1));

  if (kdb->sb.intervals_kmer_count > 0) {
    GT_UNUSED GtUword prev = kdb->sb.intervals->nextfreeGtRange - 1;
    gt_assert(start > kdb->sb.intervals->spaceGtRange[prev].end);
  }

  /*
     K=5
     S         E
     0 1 2 3 4 5 6
     _________     kmer1
       _________   kmer2
     E+1-(K-1)-S = 2
   */
  interval_size = end + 1 - (kdb->sb.kmer_size - 1) - start;

  /* flush if sum is to large */
  if (kdb->sb.intervals_kmer_count != 0 &&
      interval_size + kdb->sb.intervals_kmer_count >= kdb->sb.max_nu_kmers) {
    gt_kmer_database_flush(kdb);
    kdb->sb.printed = false;
  }

  /* split overall to large, sb is empty because of code above */
  while (interval_size > kdb->sb.max_nu_kmers) {
    kdb->sb.printed = false;

    new.start = start;
    new.end = start + kdb->sb.max_nu_kmers + (kdb->sb.kmer_size - 1) - 1;

    GT_STOREINARRAY(kdb->sb.intervals, GtRange, 10, new);
    GT_STOREINARRAY(kdb->sb.ids, GtUword, 10, id);

    kdb->sb.intervals_kmer_count += kdb->sb.max_nu_kmers;
    gt_kmer_database_flush(kdb);
    interval_size -= kdb->sb.max_nu_kmers;
    start = start + kdb->sb.max_nu_kmers;
  }

  /* definitely fits, add */
  new.start = start;
  new.end = end;
  GT_STOREINARRAY(kdb->sb.intervals, GtRange, 10, new);
  GT_STOREINARRAY(kdb->sb.ids, GtUword, 10, id);
  kdb->sb.intervals_kmer_count += interval_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x1579ef
movq %rcx, %rbx
movq %rsi, %r12
movq %rdi, %r14
leaq 0x1(%rdx), %rbp
movl 0xd0(%rdi), %eax
decl %eax
movq %rbp, %rcx
subq %rax, %rcx
cmpq %rsi, %rcx
jbe 0x1579f4
movq 0xc8(%r14), %rcx
testq %rcx, %rcx
movq %rdx, (%rsp)
je 0x1577f7
movq 0x80(%r14), %rdi
movq (%rdi), %rsi
movq 0x10(%rdi), %rdi
shlq $0x4, %rdi
cmpq %r12, -0x8(%rsi,%rdi)
jae 0x157a03
addq %r12, %rax
subq %rax, %rbp
addq %rbp, %rcx
cmpq 0xa8(%r14), %rcx
jb 0x1577fd
movq %r14, %rdi
callq 0x157066
movb $0x0, 0xd4(%r14)
jmp 0x1577fd
addq %r12, %rax
subq %rax, %rbp
movq 0xa8(%r14), %r15
cmpq %r15, %rbp
jbe 0x157910
movb $0x0, 0xd4(%r14)
movl 0xd0(%r14), %r13d
movq 0x80(%r14), %rcx
movq 0x8(%rcx), %rsi
cmpq %rsi, 0x10(%rcx)
jae 0x157832
movq (%rcx), %rax
jmp 0x15785c
addq $0xa, %rsi
movq %rsi, 0x8(%rcx)
movq (%rcx), %rdi
shlq $0x4, %rsi
leaq 0x22d798(%rip), %rdx    # 0x384fe0
movl $0x1c7, %ecx            # imm = 0x1C7
callq 0x104461
movq 0x80(%r14), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x1579e5
decl %r13d
addq %r12, %r15
leaq (%r15,%r13), %rdx
decq %rdx
movq 0x10(%rcx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x10(%rcx)
shlq $0x4, %rsi
movq %r12, (%rax,%rsi)
movq %rdx, 0x8(%rax,%rsi)
movq 0x88(%r14), %rcx
movq 0x8(%rcx), %rax
cmpq %rax, 0x10(%rcx)
jae 0x1578a1
movq (%rcx), %rax
jmp 0x1578cf
leaq 0xa(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq (%rcx), %rdi
leaq 0x50(,%rax,8), %rsi
leaq 0x22d725(%rip), %rdx    # 0x384fe0
movl $0x1c8, %ecx            # imm = 0x1C8
callq 0x104461
movq 0x88(%r14), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x1579ea
movq 0x10(%rcx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x10(%rcx)
movq %rbx, (%rax,%rdx,8)
movq 0xa8(%r14), %rax
addq %rax, 0xc8(%r14)
movq %r14, %rdi
callq 0x157066
movq 0xa8(%r14), %r15
subq %r15, %rbp
addq %r15, %r12
jmp 0x157804
movq 0x80(%r14), %rcx
movq 0x8(%rcx), %rsi
cmpq %rsi, 0x10(%rcx)
jae 0x157926
movq (%rcx), %rax
jmp 0x157950
addq $0xa, %rsi
movq %rsi, 0x8(%rcx)
movq (%rcx), %rdi
shlq $0x4, %rsi
leaq 0x22d6a4(%rip), %rdx    # 0x384fe0
movl $0x1d3, %ecx            # imm = 0x1D3
callq 0x104461
movq 0x80(%r14), %rcx
movq %rax, (%rcx)
movq (%rsp), %rdi
testq %rax, %rax
je 0x1579f9
movq 0x10(%rcx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x10(%rcx)
shlq $0x4, %rdx
movq %r12, (%rax,%rdx)
movq %rdi, 0x8(%rax,%rdx)
movq 0x88(%r14), %rcx
movq 0x8(%rcx), %rax
cmpq %rax, 0x10(%rcx)
jae 0x15798c
movq (%rcx), %rax
jmp 0x1579ba
leaq 0xa(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq (%rcx), %rdi
leaq 0x50(,%rax,8), %rsi
leaq 0x22d63a(%rip), %rdx    # 0x384fe0
movl $0x1d4, %ecx            # imm = 0x1D4
callq 0x104461
movq 0x88(%r14), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x1579fe
movq 0x10(%rcx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x10(%rcx)
movq %rbx, (%rax,%rdx,8)
addq %rbp, 0xc8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4a087
callq 0x4a04e
callq 0x4a0c0
callq 0x49f6a
callq 0x4a015
callq 0x49fdc
callq 0x49fa3